In WebGPU, cannot use a ReflectionProbe that includes itself in the renderList as a reflectionTexture

This works in WebGL2, but causes an error in WebGPU.

I checked the WebGPU status page and this forum, but it didn’t seem to mention this.

Here is minimum repro: https://playground.babylonjs.com/#KA93U#1727

Please let me know if this is a known issue or limitation.

Actual scenario:
There is a room surrounded by walls and furnished with various pieces of furniture. To create an environment map of the interior of this room, I place a single ReflectionProbe at the center of the room and add the walls and furniture to the renderList.
I then use the cubeTexture generated by that ReflectionProbe as the reflectionTexture for the walls and each piece of furniture.
This allows us to represent the room’s general reflections without having to prepare environment textures in advance (since the colors of the walls and the types and placement of the furniture change dynamically, it is difficult to prepare textures beforehand).
Instead of using a single ReflectionProbe, if we were to set up individual ReflectionProbes (covering everything except themselves) for each wall and piece of furniture, we could achieve more accurate reflections and avoid this error. However, I don’t think this is practical for performance reasons.

Thank you for maintaining this great framework!

This is not supported, you can’t read from a texture you are currently writing to.

It’s not a limitation of WebGPU, it’s also not supported by WebGL:

1 Like

Thank you for confirming. Is there a workaround?

Unfortunately there’s no workaround, it’s a limitation of the underlying backend/GPU/drivers, not Babylon.

Thank you. If I have time, I’d like to contribute to improving the documentation on this point. (I’m sorry if this has already been mentioned and I missed it.)

So in my VR world project, I had this exact issue. The most practical solution I came to is to set a temporary good environment map in the scene that is somewhat similar in lighting as what your scene has while baking the probe (I made one that is similar to the rooms I was making and saved that for later temporary use). But you will notice a change in lighting as it is being baked ofc. What you can do is to reload a baked env map as a temporary one you bake a new one, the most important thing is that they are never the same map.

Note also that you really shouldn’t use the probe cube texture directly as env for your PBR materials, as all your objects will act as if they have roughness 0 since the cube map does not have mipmaps which is how roughness is “faked” in PBR materials. Babylonjs has a tool for making these although it is a bit slow:

EnvironmentTextureTools.CreateEnvTextureAsync(probe.cubeTexture).then(((buffer: ArrayBuffer) => { ...});

My plan was to experiment with baking these in a separate worker thread or off-client - on my server.

2 Likes

Feel free to help improve our documentation!

To do so, simply visit a page in the documentation repository (for example: Babylon.js docs) and click the “Edit this page on GitHub” icon located at the bottom right of the page:

Once you’ve edited the page, simply save it to automatically create a pull request on GitHub.

2 Likes