Custom shaders in RTT and Post Process

I have a scene with just one object for which I want to achieve special effects.

I need to render the scene to texture (RTT) with with custom shaders(for special effects).

  1. Only the Diffuse component (Store as texture 1)
  2. Only the Specular component(Store as texture 2)

Then I need to do custom Post processing on texture 1 and 2 in a custom post-process shader. And ultimately render the scene to a quad, the combined texture 3 after post process is done.

I need help with how to proceed.

I have started exploring RTT https://playground.babylonjs.com/#R9FFCP#3
How can I use a custom shader with RTT ?

You need to create a multi render target texture to be able to write on two textures at the same time. This PG can help you: https://playground.babylonjs.com/#XSNYAU#23

If you want to use standard or PBR materials and reuse the diffuse/albedo + specular components of these materials, you’ll need to write a material plugin and inject your code in the right place.

Creating a post-process that uses both textures is the easy part, you’ll just need to pass both textures to your post-process like any other normal texture (effect.setTexture(...)).

1 Like