I am rendering an FFT ocean using a quadTree. The T-junction problems seem to be eliminated but i am getting some weird pattern beween the edges of tiles of the same size as per the attached image. The same colour means that the tile has the same (world) size:
As you can see, the edges between tiles are quite noticeably distorted and will distort the textures on top.
I am using the following code to calculate the tesselation LOD (sphere LOD)
vec2 eyeToScreen(vec4 p)
{
vec4 r = pMatrix * p; // to clip space
r.xy /= r.w; // project
r.xy = r.xy*0.5 + 0.5; // to NDC
r.xy *= Viewport; // to pixels
return r.xy;
}
float dlodSphere(vec4 p0, vec4 p1, float sideLength)
{
vec4 center = 0.5 * (p0 + p1);
vec4 view0 = vMatrix * center;
vec4 view1 = view0;
view1.x += sideLength;//distance(p0, p1);
vec2 screen0 = eyeToScreen(view0);
vec2 screen1 = eyeToScreen(view1);
float d = distance(screen0, screen1);
// triSize is desired pixels per tri edge
float t = clamp(d / triSize, 2, 64);
// Clamp to the nearest larger power of two. Any power of two works; larger means that we don't lose detail.
float logTess = ceil(log2(t));
return pow(2, logTess);
}
If i change the tesselation to a fixed 64 it all looks okay so it has to be a problem in the Tesselation level calculated above. Anything that looks off in those functions?