Jump to content
  • Advertisement
Sign in to follow this  
Andr

OpenGL Quad tree Tesselation issue at edges

Recommended Posts

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: 

image.thumb.png.ee12f85fa1bf5cbf603539f499fcc8ef.png

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?

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!