Sign in to follow this  

z buffer resolution for huge environments.

This topic is 3493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to solve this problem in my planet renderer. The scene is so huge that the standard z-buffer resolution is not high enough even when I best fit the near and far planes around the objects being drawn. The planet is 8000 units in radius, and the player needs to be able to get within 0.1 units of the surface. This causes problems at the intersection between the ocean and land polygons, and they flicker. The solution I am currently using is to split the scene into a near and far set, drawing far set, clearing the depth buffer, then drawing the near set. Any objects that overlap the plane between near and far set are added to both sets and hence drawn twice. The problem I am getting with this (aside from having to draw some objects twice, which is incurring a problematic state switching penalty) is that I don't get a perfect seam at the join between the near and far sets. I have to compensate for this by forcing a slight overlap. This would be okay except that objects that use alpha blending are making the seam obvious. Any ideas on how to fix this problem, or a different approach? Thanks!

Share this post


Link to post
Share on other sites
What about splitting your view into several layers and then just combine textures.

Cascade should look like:
Closest objects (0.1 - 5000)
Further objects (5000 - 25000)
Furthest objects (25000 - 250000)

This solution doesn't make your scene perfect (but it'll have less flickering), and the more layers you use, the higher quality will the solution be (and the more CPU/GPU power you need).

Share this post


Link to post
Share on other sites
Thanks for the reply.
The problem I am having with splitting the scene is that at the split plane gaps appear unless I force a bit of overlap in the frustums. But when I add overlap, the objects that use alpha blending show the overlap as a slightly darker band. How would your solution fix that? It seems like you are saying just add another layer, but I don't see how that would help?
What do you mean by combine textures? atm I am not rendering each layer to a different texture, I am just rendering the layers back to front, with a depth clear between the layers.

Share this post


Link to post
Share on other sites
Using a geometry clipping plane at the boundary might help resolve the overlap problem. That way no polygons that cross the boundary will render the same fragment (screen-space pixel) twice.

Share this post


Link to post
Share on other sites
Quote:
Original post by Fibonacci One
While I haven't actually tested this myself, it seems like the technique described here http://www.mvps.org/directx/articles/linear_z/linearz.htm might be a good solution for you.


linky [wink]

I agree, this technique indeed helps out.

Share this post


Link to post
Share on other sites
1) Have you tried W-buffering?
2) Have you tried old-school algorithms?

I will expand the old-school (not much though):
Basically, Z buffering isn't needed if everything is rendered from back to front perfectly (though, you may get lower performance).
The problem lies in overlapped triangles. Those overlapped triangles were cutted in several triangles (usually 2) and rendered separately to avoid this problem. This is a very oooold technique, but might work in your case. Also is much less efficient than Z/W Buffering (because the triangles need to be sliced each frame)

2bis) Use the old-school algo to slice the overlapping parts in the different layers, while keep using Z buffering for everything else.

3) Have you tried using a pixel shader to blend those overlapped parts? I'm talking about a modified version of this technique (note it says it is for SM 4.0, but it can be written for SM 3.0 too). Use that technique to just blend the "slight overlap" you say.

4) Draw the farest objects as billboards using RTT and don't bother.

5) Use pixel shader yourself to implement a custom Z buffer, using two R32F textures to split a 64-bit float (or integer?) value. You would need to render the scene multiple times. This isn't easy though, as far as I know pixel shaders natively support up to 32-bit operations. And would be slow too.

Cheers
Dark Sylinc

Share this post


Link to post
Share on other sites
Thanks alot for the replies. The linear scale z-buffer looks very promising, I will try that first I think, it only requires changes to my projection matrix, and adding a line to each vertex shader.
@Matias:
Theres no way I can sort my entire scene using painters algo, its more than 100,000 tris! I did try sorting just the objects, then rendering using the z-buffer in two passes, far then near, but some of the objects that need to be in the near set are _still_ to large for decent z-buffer resolution.
I can't fully solve the problem with billboard as the main distant object is the planet sphere, which is stitched tightly to the geometry clipmap which is a close object. The stitching would break if I tried to billboard the planet.
As for the soft-particle method, I'm not sure (from my brief read of the pdf) how to use that to fix my immediate problem, but I am going to apply it to my particle renderer!

Share this post


Link to post
Share on other sites

This topic is 3493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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