Hey guys,
I’m working on a HLSL shader to use latitude-longitude maps as environment maps (because I can’t use cubemaps) and I’m encountering some issues with the seams, whether I try to do it in the vertex shader or the pixel shader:
The problem is that between the last point (UV~=0.9) and the first point (UV=0.0), the GPU is trying to interpolate the value between 0.9 and 0.0 instead of using 0.9 and 1.0, so the entire texture gets squashed between those two points.
Here is the code I use:
output.x = atan2(normal.x,normal.z) / 3.14159265;
output.y = -normal.y;
output= output* 0.5 + 0.5;
I suspect the issue is coming from the atan2() function, but I’m not really sure what alternatives I can use…
Cheers.