Draw Order Issue

Started by
11 comments, last by ChristOwnsMe 11 years, 1 month ago

I am rendering a planet of cubes, and I am having Z issues and I cannot figure out why. Here is an image.

http://imgbin.org/index.php?page=image&id=12134

As you can see int he center of the image, I can see inside the sphere, when I should be seeing the shell of the sphere.

I am using XNA to render this. My near value is 1f and far value is 30,000f, so I cannot figure out why things disappear at the mid range.Any ideas on how to debug this? Thank you.

Advertisement

Are you sure its a z-fighting issue? Could be that you have cullmode set to none and the winding order of your cubes is wrong.

Cullmode is set to none. I thought that is what I should do if I wanted all sides of a cube to display? The outside of the sphere disappears if I move to one side of the spear as well.

If you are saying the sphere's are being rendered inside out, I would first play with the cullmode until they appear correct and then play with the winding order of the triangles until you get the correct result with no cullmode set.

Have you enabled the DepthBuffer?

I do have the depth buffer enabled. The sphere looks normal from the front. As I move around the sphere, the shell starts to slowly fade away,and when I am at the sides, I can see the "inside" of the sphere, or rather the other side of the sphere. My cullmode is set to none. I thought this is what would make it so this issue didn't happen and no polygon would be culled. Am I missing something? I've tried CullMode.None, Clockwise, and Counterclockwise, and the issue is the same.

This may be obvious to you all, but this doesn't happen with wireframe. Just thought I'd add that.

You may have a visual perception problem. Depending upon the scale of the objects, both may be renderd properly, however, because of how the are constructed, ( color and scope ) you think that you are no seeing what you want.

You may want to do some additional testing. I would try a couple of test.

1 - Color either the cube or the sphere a solid color.

2 - move the camerea to do a fly by of the cube. Based upon your stated distance, there should be blank space between the teo entities.from

3 - From what I am seeing, the sphere is obviously larger than the cube, So I would check the scale of each object, this may be causing your overlap. If the sphere is to large, then it naturaley extend beyond the intended space.

4 - I do like the effect. I think it looks very cool.

Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!

I should mention I am using PolyVox to generate the voxels. This is a 16^3 voxel volume. Each cube is a cube that represents 1 voxel in the volume.The vertices for the cubes are generated in PolyVox and then used in XNA. Here are some more images to help point out the issue more.

Image 1: The sphere looks fine. Looking at it from the front left.

http://imgbin.org/index.php?page=image&id=12135

Image 2:Moving further forward you can start to see the cubes disappearing at the TOP RIGHT of the sphere and you are able to see the other side of the sphere.

http://imgbin.org/index.php?page=image&id=12136

Image 3: The closest hull of the sphere is now gone and you can see the other side of the sphere.

http://imgbin.org/index.php?page=image&id=12137

This is with CullMode.None on, and depth buffer enabled. I have tried changing the winding order of the vertices to no avail.

What is your depth function set to because if that is set to pass always you can have depth on but draw order will still interfere with it. You most likely want the depth function to be set to smaller.

CullModeNone will draw all polygons btw regardless of winding of vertices only CW and CCW care about winding order and you should switch to one of them in the end as it can help your framerate.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Also double-check to make sure you actually have a depth buffer (DepthFormat.Depth24 or DepthFormat.Depth24Stencil8 when you create your backbuffer/rendertarget).

This topic is closed to new replies.

Advertisement