Closed bryanedds closed 1 week ago
I'm pretty sure the issue is something else and more general than with the terrain.
I'm starting to suspect it has something to do with the way we contrive tangents and binormals in fragment shaders -
// compute spatial converters
vec3 q1 = dFdx(positionOut.xyz);
vec3 q2 = dFdy(positionOut.xyz);
vec2 st1 = dFdx(texCoordsOut);
vec2 st2 = dFdy(texCoordsOut);
vec3 tangent = normalize(q1 * st2.t - q2 * st1.t);
vec3 binormal = -normalize(cross(normal, tangent));
mat3 toWorld = mat3(tangent, binormal, normal);
mat3 toTangent = transpose(toWorld);
This convenience approach means we don't have to pass in tangent data, but perhaps its the cause of these extreme close-up rendering artifacts.
Actually, this might originate from the PBR algos we employ. Additionally, we've made the issue basically invisible from increasing the near plane distance from 1/16m to 1/8m, so closing.
Zoom extremely close to terrain to see this sort of pattern -
I'm guessing this is due to floating point precision issues in code like here -
https://github.com/bryanedds/Nu/blob/93c57aed68250c181b4fc8016d46002d6d052d55/Nu/Nu.Gaia/Assets/Default/PhysicallyBasedDeferredTerrain.glsl#L140-L145