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: enter image description here

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?

EDIT 1: I traced back the problem to a problem with the normals which get distorted at the edges. However it still doesn't explain why is undertesselating at some edges.

EDIT 2: False alarm, when i get closer to the distorted area, it tesselates more and then distortion goes away

  • \$\begingroup\$ Where do you calculate the uv? \$\endgroup\$ – Bálint Mar 22 at 6:42
  • \$\begingroup\$ The uvs are calculated in the vertex shader (using the origin and dimensions) and passed along the pipeline. I dont believe its the UVs because with the tesselation set to a fixed value it works fine. I can provide the code if needed but its pretty simple. The lines in the picture are also distorted at the edges and those dont use the uv's coordinates \$\endgroup\$ – André Ferreira Mar 22 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.