I would say it’s not the ultimate solution, but a concept. If you have any ideas of how to improve the code of the shader, feel free to post it here or PM me
envMap projection breaks on faces not aligned with camera directional axis, much like what happens on my texture projection question.
edit: Oh, I know why.
The same thing happens on every envMap. You just can’t notice on @prisoner849’s example because the number of segments on each face of the box is a lot higher, so the effect is less noticeable. But if you test the same thing on a regular boxGeometry with just 2 faces on each side, you get the same distortion.
The way to fix that is by calculating the texture UV projection inside the fragmentShader using interpolated worldcoordinates, but that should add a really big overhead, not sure if it’s worth.
Yea you generally have that issue with low tesselation, using some for the inner faces would improve it again, maybe there is a generally better fix though.
Actually environemnt maps don’t use UVs, they use the normal, i just noticed prisoner used a MeshLambertMaterial which only calculates the reflection normal per vertex, a Standard/MeshPhongMaterial fixes this.
Actually environemnt maps don’t use UVs, they use the normal, i just noticed prisoner used a MeshLambertMaterial which only calculates the reflection normal per vertex, a Standard/MeshPhongMaterial fixes this.
Oh, I see. Good catch!
You’ve updated the code to use correct normals and it’s working fine
Actually there is much pratical use for it, i used this technique before for a dynamic scene to add a little bevel/rounding to the boxes. On GPU it saves you geometry buffers and processing cost otherwise done with JS, for a lot boxes with varying or dynamically changing sizes it is quite more efficient.