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…


I think that this is just tech debt, and it’s probably not easy to pinpoint the reason why.

My suspicion is that the shader material system is not as robust as you might expect. It may not be obvious what kind of glsl you will end up with, and it seems that the renderer is generating more and more glsl.

I’m curious about this topic as well.