-
-
Notifications
You must be signed in to change notification settings - Fork 113
Description
I've been trying to write a shader that would use 2 samplers, one coming from the current video frame I'm using as a base, and one from a previous frame.
I hacked my way into adding }).onVideoFrameCallback((metadata, texture) => to the loader so I can get the last modified frame, store the frame used 30frames ago and I'd like to reuse that texture in my shader via an uniform sampler2D.
However, I'm getting stuck making the texture available. I tried to clone the texture instance, rename it to match the new sampler uniform (altTexture) and tried to force the uniform binding but without any luck:
const altTexture = new Texture(texture.renderer);
Object.assign(altTexture, texture);
altTexture._sampler.name = "altTexture";
altTexture._textureMatrix.name = "altTextureMatrix";
videoPlane.textures[1] = altTexture;
videoPlane.textures[1]._setTextureUniforms();
I realize I could use another video element as a source, but I'm exploring interesting glitching effects and would prefer to have fun with the one texture.
Is it something that is currently doable and I just missed a step? If it's not doable, coud you point me towards a potential hack/solution? I'd be more than happy to contribute back if that's something that would be interesting to the project.