Hi,
I’m trying to implement a example that iterates on a modified version of an input texture over time.
I start with the following shader material:
// Create the plane geometry
var geometry = new THREE.PlaneBufferGeometry(2, 2);
// Define the shader uniforms
uniforms = {
u_time : {
type : "f",
value : 0.0
},
u_resolution : {
type : "v2",
value : new THREE.Vector2(window.innerWidth, window.innerHeight)
.multiplyScalar(window.devicePixelRatio)
},
u_mouse : {
type : "v2",
value : new THREE.Vector2()
},
u_texture : {
type : "t",
value : null
}
};
// Create the shader material
var material = new THREE.ShaderMaterial({
uniforms : uniforms,
vertexShader : document.getElementById("vertexShader").textContent,
fragmentShader : document.getElementById("fragmentShader").textContent
});
And then my idea is to pass to u_texture the rendered screen from the previous frame.
renderer.render(scene, camera, renderTarget);
renderer.render(scene, camera);
uniforms.u_texture.value = renderTarget.texture;
This produces the following error:
GL ERROR :GL_INVALID_OPERATION : glDrawElements: Source and destination textures of the draw are the same.
I also, don’t like it because i need to render the same scene twice. My question is, is there a way to put the rendered scene into a texture that I can pass to the next frame iteration?
Something like:
renderer.render(scene, camera);
uniforms.u_texture.value = renderer.getScreenTexture();
Thank you for your help!