Good evening.
I’m still a big newbie when it comes to shaders, and I’ve been hitting my head against a wall lately. I’ve been trying to convert a Parallax Occlusion Mapping shader from using model UV coordinates to using worldspace coordinates.
Problem is, the shader uses the tangent in calculating… stuff. So when the UV of the textures don’t match the UV the tangent was from, well, stuff breaks completely. What should I put in place of the tangent to make it work with the position and not the UV? I am aware that the tangent points to the direction where U increases, and the bi-tangent points to the direction where V increases, but that’s about where my knowledge of the subject ends.
This is how I’m doing the position based UV:
float2 uv = IN.vertex.xz;
uv += float2(IN.normal.x, IN.normal.z) * IN.vertex.y;
uv *= 0.25;