First, a huge thank you to all involved in developing threejs.
Is it currently possible to set up a material that samples the envMap at a single point and uses that color on the entire triangular face, so that the reflective envMap also looks flat? Playing with minFilter, magFilter, flatShade doesn’t work, since the reflections are calculated correctly and/or interpolated, no matter what.
As to the sampling point, I think to get the shading consistent between adjoining coplanar faces, the natural method would be to reflect the camera incident ray off the face normal at the point sitting in the center of the envMap, so that the sampling doesn’t depend on spatial position of the face, just its face normal.
If currently not possible, can I get some advice on maybe if/how I can attempt to modify an existing shader model, keeping in mind I am a complete novice to shaders but don’t mind diving in, if it is feasible to accomplish what I tried to explain. Thank you.
If you imagine the geometry of this problem, it is natural that the reflection vector will be different for each fragment, even though all the fragment have the same normal( due to the fact that fragment position is getting interpolated by the rasterizer). So, if you want the same reflection vector for all the fragments of a triangle, one way could be to calculate the centroid of the triangle, and send it as a vertex attribute. Now since you have set the centroid position for each vertex, and for all the vertices of a triangle it would be the same, the rasterizer will give the same position for all the fragments corresponding to a triangle. You can use this to calculate the reflection vector.
May i ask, what is your actual use case? Or what kind of visual effect do you try to achieve? TBH, I’ve never seen this kind of “environment mapping”.
Yeah, even I wanted to know the same thing
Thank you. I pretty much did what you described, but did not use the triangle centroid, or any model point at all, since that would result in coplanar triangles being shaded differently, and anyway, my goal was to visualize the spatial orientation of faces, irrespective of their positions, using various criteria. Kind of a more flexible normal map that optionally depends on the view direction as well, for flat faceted (STL) models and uses user supplied analysis maps. As such, I used the normal direction in conjunction with camera vector in the vertex shader to calculate the color.