Jump to content
  • Advertisement
Sign in to follow this  
Mastadex

faces appearing in weird order?!

This topic is 5131 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

Im drawin a bunch of cubes right next to eachother, with a bit of space in between them. the space is really small but noticable from a far distance. when i rotate these cubes around one axis, I can see that some of the faces of cubes above that are drawn ontop of other cubes which are infront. Is this a video card problem or did I forget to set something in the render state?

Share this post


Link to post
Share on other sites
Advertisement
either you are not using z-buffer (i.e turned off) or you have a z-fighting problem. Try changing the "near" value to as large value as you can tolerate. set "far" to 10000.0f or something.

Share this post


Link to post
Share on other sites
My far is already at 10000.0f and my near value is a 0.0001f.

i do have the z-buffer enabled and my aspect is currently set at D3DXToRadian(35.0), which is like a 35mm camera (i think). this only happens when I see the cubes on a certain angle. could it be the models themselves????

Share this post


Link to post
Share on other sites
Change your near to something like 1.0f, or the largest value you can handle.

The ratio between your near and far planes should be the smallest possible - right now you've got 10000/0.0001 which is HUGE :D I'd suggest changing your near plan to at least 1.0 and moving your far plan as close as you can handle. Then you'll have say 1000/1 which will give you much better results!

Although this may not fix your problem its still definatly worth doing because it will help later!

Share this post


Link to post
Share on other sites
You say you have the Z buffer enabled. Just in case, there are a few steps to having a Z buffer working correctly. That said, yeah, a near plane that small is bound to cause trouble.

1. In your create device call, in the presentation parameters, set EnableAutoDepthStencil to true, and set AutoDepthStencilFormat to something like D3DFMT_D16 or D3DFMT_D24X8.

2. On your device, ensure Z is enabled. pDev->SetRenderState(D3DRS_ZENABLE, true); You can also ensure ZWRITEENABLE is true, and ZFUNC is D3DCMP_LESSEQUAL, though these *should* default correctly. Be aware that other code, like a font system displaying FPS, may disable your Z buffer. Ensure you get yourself back to a known state after calling other code.

3. In your clear command you need to ask for depth to be cleared, and you want it set to 1.0f. For example: pDev->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x123456, 1.0f, 0);

4. If you setup viewports, you want to ensure you've setup the MinZ as 0.0f and MaxZ as 1.0f, unless you have good reason to adjust these values.

Share this post


Link to post
Share on other sites
Ok I narrowed down the FOV to 3000.0/1.0. so far i think it worked. The thing is that I need to see everything up to a point and 3000 seems to be a minimum limit. thanks tho.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mastadex
Ok I narrowed down the FOV to 3000.0/1.0. so far i think it worked. The thing is that I need to see everything up to a point and 3000 seems to be a minimum limit. thanks tho.


Did you try increasing the precision of your depth buffer to 24 bits (ntnet skimmed over this)? Right now, you are most likely creating your depth buffer with 16-bit precision (AutoDepthStencilFormat is set to D3DFMT_D16). Try changing it to 24-bit precision (D3DFMT_D24X8) and you should see better results.

Share this post


Link to post
Share on other sites
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!