Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Draw Order Issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 ShadowMan777   Members   -  Reputation: 361

Like
0Likes
Like

Posted 14 March 2013 - 11:47 PM

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.



Sponsor:

#2 Steve_Segreto   Crossbones+   -  Reputation: 1540

Like
0Likes
Like

Posted 15 March 2013 - 12:46 AM

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.



#3 ShadowMan777   Members   -  Reputation: 361

Like
0Likes
Like

Posted 15 March 2013 - 12:57 AM

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. 



#4 Steve_Segreto   Crossbones+   -  Reputation: 1540

Like
0Likes
Like

Posted 15 March 2013 - 01:08 AM

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.



#5 Inukai   Members   -  Reputation: 1297

Like
0Likes
Like

Posted 15 March 2013 - 01:19 AM

Have you enabled the DepthBuffer?



#6 ShadowMan777   Members   -  Reputation: 361

Like
0Likes
Like

Posted 15 March 2013 - 01:33 AM

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.


Edited by ShadowMan777, 15 March 2013 - 01:39 AM.


#7 Poigahn   Crossbones+   -  Reputation: 520

Like
0Likes
Like

Posted 15 March 2013 - 02:10 AM

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 !!


#8 ShadowMan777   Members   -  Reputation: 361

Like
0Likes
Like

Posted 15 March 2013 - 02:58 AM

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.



#9 NightCreature83   Crossbones+   -  Reputation: 2934

Like
0Likes
Like

Posted 15 March 2013 - 03:18 AM

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, Mad Max

#10 phil_t   Crossbones+   -  Reputation: 3948

Like
0Likes
Like

Posted 15 March 2013 - 03:23 AM

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

#11 ShadowMan777   Members   -  Reputation: 361

Like
0Likes
Like

Posted 15 March 2013 - 04:03 PM

How big am I allowed to have my far plane without causing issues? My far plane right now is 40,000, and if I set it super low and get close to the sphere there doesn't seem to be issues.



#12 mhagain   Crossbones+   -  Reputation: 8141

Like
0Likes
Like

Posted 15 March 2013 - 05:27 PM

It's not how big your far plane is but the ratio between your far plane and your near plane that matter.  The easiest fix is to push your near plane out a little - if increasing it to say 10 or so resolves the issue, then you've just confirmed that a value of 1 is much too small for you.

 

There's a useful depth buffer precision calculator at http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html which will let you plug in some values and see how much precision you lose: with near 1 and far 30000 (and assuming a 24-bit depth buffer) the smallest depth separation you can resolve at the mid-range (15000) is a little over 13 units; increase near to 10 and this becomes 1.3 units - much better.

 

This, by the way, gets considerably worse if you're using a 16-bit depth buffer; with near 1 and far 30000 your smallest resolvable separation is now close to 2800 units!!!  Quite nasty indeed.

 

So two main things here - firstly, prefer to use a 24-bit depth buffer (which shouldn't be a problem as all hardware from at least the past 10 years or more will support one), and get that near plane pushed out as far as you can reasonably tolerate it - you're very probably going to find that this will be a lot farther than you think right now.


Edited by mhagain, 15 March 2013 - 05:29 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#13 ShadowMan777   Members   -  Reputation: 361

Like
0Likes
Like

Posted 15 March 2013 - 07:02 PM

Thanks for the info and that calculator. I finally fixed the issue. Apparently I had a DepthBias set to 1 somewhere at some point. Thanks for all the help and information everyone.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS