Reflection probe cubetexture

Unfortunately, this is going to be very hard to reproduce in a babylonjs playground, b.c we use a custom shader, but please bear with me.

We generate a cube texture from the current scene using a camera in the middle of the room, and then point it in the six direction of the cube. Everything about that seems good. The edge seem to line up. as you can see from attached photos. We sample from that cube texture in the shader to do reflections. However, as you can see from the first image, the reflection appears warped where images cross from the -y plane to the +x plane (or the -x, +z, or -z plane). Are there any settings on the cube textures, or approaches to creating the cube texture, that we can do to avoid this warping effect where you can tell that the reflection cubemap switches planes?



@Evgeni_Popov our genius shader dev might have an idea ?

Are you using the ReflectionProbe class to generate the reflection cube? If not, can you try with it? If it works with the ReflectionProbe, it means you are not generating the cube correctly: you can look at the ReflectionProbe code to see how it is done there.

Also, you say you use a custom shader: are you able to switch to the standard or PBR material to see if it works there? If yes, it means you are not using the right coordinates to sample the cube texture. You can also have a look to the Babylon source code to see how it’s done.

We are not using reflectino probe directly, but we stole your source code around generating the render target texture within it.

I will have to try swapping that out for the reflection probe itself and see if we missed something in translation.

So to you, this is a solvable problem? Someone else told me that this is just an inherent flaw with cube textures and its not fixable

I’m not sure it will work without any distortion whatever the view point…

However, why not simply using a mirror texture?

That seems easier to me and less taxing on performance (only a single texture to generate and not 6 as you need for a cube texture).

It is less taxing on performance initially, but effects frame rate more because you have to re-generate the texture anytime the camera moves. With the reflection probe, we re-generate it only when the scene changes, which is far less frequent in our application

Plus we have some curved reflective surfaces, so we would need both reflection probe and then mirror textures for the flat surfaces, correct?

Indeed, I wasn’t be able to avoid distortion with cube maps, even using local cubemaps:
https://playground.babylonjs.com/#41RLQ9#1

I think that even if your reflective surfaces are curved, you should be able to generate a texture from a planar mirror and apply this texture to the curved surfaces: depending on the surfaces, it is an approximation that could work.

Thank you, this gives me a good place to start