Reflection Probe Workflow when multiple materials in the scene need reflections

I have a scene with 3 meshes - walls, floor and a sphere. I create a reflection probe cubetexture from middle of the room with all 3 meshes added.

Now if i want the ground and wall to have reflection texture = above probe.cubetexture it wont work because of circular dependency. A workaround will be to create multiple probes one for each mesh. I guess its not too bad if you use probe.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE; but there’s gotta be a better way to prevent all those probes and cubetextures of say hundreds of meshes eating up resources.

Is there a better way to achieve this?

You should not set the reflection texture on the wall/floor/sphere until the probe cube texture is generated, to avoid this circular dependency problem. This assumes the probe is static (calculated only once), but this is the most common usage of probes.

You can also use SSR if your use case allows:

@Evgeni_Popov unfortunately that does not work as you can see in this repro on playground

The console errors with :
[.WebGL-0x1080bf28100] GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.

You must wait for the cube texture to be rendered. You can do it like this:

1 Like

Thanks @Evgeni_Popov the cyclic dependency is no longer showing. It worked.

I will make one small change to your code . In line 59 in addition to checking if the cube texture is ready for rendering, we also need to check if the scene is ready for rendering

scene.isReady()

The reasoning is on this thread. Why does my reflection probe see nothing? *Update* Just not the skymap? - #8 by Pryme8

After doing this my scene started working as expected. Otherwise, the reflection textures were missing most of the meshes.

1 Like