Hi ! I’m trying to create a ShaderMaterial passing the current scene’s rendered result to the textureSampler.
shaderMaterial.setTexture("textureSampler", <pass current framebuffer texture >);
I’m not exactly sure where to get the texture from. I seem to recall its meant to be protected from access ?? sorry, memory is foggy. Does anyone have any clues ?
In case the texture is not meant for access, I’d like to ask how I can sample the pixel color of the current scene’s current camera result in my shaderMaterial as that is what the texture was meant for.
You can create a custom render target texture and render the scene (meaning all the meshes) in it, then pass this RTT to your shader. The drawback is that you will effectively render the scene twice.
You can also use a “pass” post process and use Effect.setTextureFromPostProcess(...) to pass the texture to your shader.
As you can see from the PG, I have a simple bathtub setup and the water color control to depth working. But the water mesh isn’t showing the texture of the objects behind it. To do so, I have to pass the current framebuffer to the shader and mix the result with the water color params. I have trouble passing the framebuffer texture to the shaderMaterial.
The post process route does not accommodate vertex shader which I have. If I uncomment lines 114 & 141, I get the depth map showing up on my water mesh indicating the framebuffer texture not going thru. If I rty to load it thru shaderMaterial.setTexture, console throws TypeError: this._textures[A].isReady is not a function
How can I check the ready state of the texture before passing into the shader?
Ive been there! Looks like something I could whip up for you pretty quick. Just now getting off for the night but Ill help tomorrow for sure. Get some rest after your surgery.
well, you did WAY WAY too much ! Many thanks !
I did mine slightly differently cos keeping the vertex shader is a must. I’ll integrate yours and post in Demos. Cheers!