Is flipEnvMap really needed?

First of all, first post here! :slight_smile:

I’ve been working on a custom multi-faceted glass ShaderMaterial these days (link) and while working on it, I almost lost my mind (as a graphics programmer does on a daily basis) trying to understand why my refraction/reflection code was being flipped… Until I found out about flipEnvMap!

Why was this implemented in the first place? Shouldn’t panorama and cube maps be sampled with the same ray? I’ve read through source a bit and it seems to be this way to not break old examples (link).

If this is the case, I think this is the wrong approach as some technical debt is being created (which is confusing advanced developers that want to play around with cube refraction/reflection, not just me), instead of fixing the old examples.

The code to fix this in your custom shaders is not too complex, but the path to figure out that the cube map was being flipped and your math is not wrong still scares me when I think about it…


Since this topic caused some confusion in the past, we’ve decided to clarify things when refactoring the internal processing of WebGLCubeRenderTarget. The CubeTexture class has now a flag which controls the flip and it comes with a detailed documentation:

1 Like