How to render Volumetric Light Scattering Post Process to an RTT correctly?

Hello!
I’m trying to render god rays to an rtt but I couldn’t get it working. The PG should display a cube and create an rtt with the sphere and the god rays.

If I add the rtt camera to the activeCameras it renders correctly but it renders on the page too, obviously. RTT with god rays:
image

If I don’t add it, it renders the rtt but without god rays. Incorrect RTT without god rays:
image

https://playground.babylonjs.com/#C4AYA8#3

Any help here?

Thank you!

EDIT: Have an idea. Maybe it will work with multiple scenes. Gonna try it.

1 Like

I tried taking a look at it, using rtt.addPostProcess: Basic pipeline | Babylon.js Playground (babylonjs.com) It worked with the Black and White PP, but not the God Rays one :frowning:

2 Likes

It is working with two scenes:
https://playground.babylonjs.com/#C4AYA8#6

4 Likes

Should I promote this to a bug?

Let me ping @sebavan first to check :wink:

1 Like

Can I expect mentionable performance penalty when using two scenes or it’s not worth mentioning it?

No this is almost transparent

1 Like

I ll have a look in my morning tomorrow at max but I do agree it sounds weird !!!

This is a chicken and egg issue…

Basically the scattering post process uses an RTT internally so the internal RTT would also need to be on the RTT list and its internal meshes list need to have the correct one too:

https://playground.babylonjs.com/#C4AYA8#10

2 Likes

Thanks a lot! I bow you master! :vulcan_salute:

@sebavan :slight_smile: I’m still fighting to get this working properly in my scenario. If I set the resulting RTT into a reflectionTexture it stops working and the god rays are gone.

// line 57
https://playground.babylonjs.com/#C4AYA8#14

I’ve figured out that if I clone the RTT before setting it to the reflectionTexture property the RTT is rendered correctly but the reflection doesn’t reflect the god rays. Is there a way to set it up properly or is this getting too complicated to maintain and should choose the multiple scenes solution instead?

The approach with multiple scenes works well:
https://playground.babylonjs.com/#C4AYA8#13

Thank you very much!

You should not use it as a reflection texture cause it is a 2d texture.

Emissive texture would be the way to go.

https://playground.babylonjs.com/#C4AYA8#15

The volumetric light scattering pp is definitely not meant to be use as a render target due to its internal use of meshes and extra rtt. The double scene approach would be the best option here.

1 Like

Thank you for helping me understand how these things works! :vulcan_salute:

1 Like