I unsolved the thread prefix again, because need some more help after all…
it seems like the videos are not perfectly synched. It looks good on some frames, but not all.
for example - here is a screenshot from my test in the gameengine
[ATTACH=CONFIG]384706[/ATTACH]
and here is a render of the same frame
[ATTACH=CONFIG]384707[/ATTACH]
Here is the code (that I just copied and pasted and changed some names (probably in some wrong way…))
I tried a delay sensor and also an always sensor to combine with the python controller.
import bge
from bge import texture
from bge import logic
cont = logic.getCurrentController()
obj = cont.owner
# the creation of the texture must be done once: save the
# texture object in an attribute of bge.logic module makes it persistent
if not hasattr(logic, 'video'):
# identify a static texture by name
matID = bge.texture.materialID(obj, "MAMaterial")
texID = 0
#matID = texture.materialID(obj, 'IMcol0001.png')
# create a dynamic texture that will replace the static texture
logic.video = texture.Texture(obj, matID, texID)
# define a source of image for the texture, here a movie
movie = logic.expandPath('//col0001-0100.mov')
logic.video.source = texture.VideoFFmpeg(movie)
logic.video.source.scale = True
logic.video.source.repeat = -1
# quick off the movie, but it wont play in the background
logic.video.source.play()
if not hasattr(logic, 'video2'):
# identify a static texture by name
matID = bge.texture.materialID(obj, "MAMaterial")
texID2 = 1
#matID = texture.materialID(obj, 'IMalpha0001.png')
# create a dynamic texture that will replace the static texture
logic.video2 = texture.Texture(obj, matID, texID2)
# define a source of image for the texture, here a movie
movie = logic.expandPath('//alpha0001-0100.mov')
logic.video2.source = texture.VideoFFmpeg(movie)
logic.video2.source.scale = True
logic.video2.source.repeat = -1
# quick off the movie, but it wont play in the background
logic.video2.source.play()
# you need to call this function every frame to ensure update of the texture.
logic.video.refresh(True)
logic.video2.refresh(True)
I also found the FilterBlueScreen() as another way to get transparent videotextures but I don´t really know how to make it transparent.
If I have a blue background - it just change it to white, so I need to add something to make it transparent, but… I am a noob
[ATTACH=CONFIG]384709[/ATTACH]
import bge
from bge import texture
from bge import logic
cont = logic.getCurrentController()
obj = cont.owner
# the creation of the texture must be done once: save the
# texture object in an attribute of bge.logic module makes it persistent
if not hasattr(logic, 'video'):
# identify a static texture by name
matID = bge.texture.materialID(obj, "MAMaterial")
texID = 0
#matID = texture.materialID(obj, 'IMcol0001.png')
# create a dynamic texture that will replace the static texture
logic.video = texture.Texture(obj, matID, texID)
# define a source of image for the texture, here a movie
movie = logic.expandPath('//blueBG.mov')
logic.video.source = texture.VideoFFmpeg(movie)
logic.video.source.filter = bge.texture.FilterBlueScreen()
logic.video.source.scale = True
logic.video.source.repeat = -1
# quick off the movie, but it wont play in the background
logic.video.source.play()
# you need to call this function every frame to ensure update of the texture.
logic.video.refresh(True)
Difficult, but fun this part of Blender!
Edit: The FilterBlueScreen() worked perfect. It was just me mixing up videos.
So I don´t need 2 separate videotextures anymore. Will mark this solved again