Skip to main content
gamedev.net
🔒 Locked

Primitive ordering

Started by Stephen R 5 replies 500+ views
Original Post
Stephen R
Stephen R
I'm trying to render a cube except the when I draw it, instead of sorting by depth, it sorts the tris by the order they appear in my index buffer. Here's a screenie: As you can see the box doesn't look very much like a box. It is probably just a render state setting, but I can't find the correct one. edit: bad tag [edited by - stro on April 25, 2004 1:51:59 PM]
cavemanbob
cavemanbob
Turn depth stenciling or depth buffering on, it should clear that problem up.

[edited by - cavemanbob on April 25, 2004 2:07:59 PM]
Stephen R
Stephen R
Well I set EnableAutoDepthStencil to true, and AutoDepthStencilFormat to D3DFMT_D16. It now comes up with this very odd screen. Here''s another screenie.



I really have no idea what is happening here.
Supernat02
Supernat02
Did you turn the Z buffer on?

SetRenderState(D3DRS_ZENABLE, TRUE);

Chris
Chris ByersMicrosoft DirectX MVP - 2005
S1CA
S1CA
quote:
Original post by stro
Well I set EnableAutoDepthStencil to true, and AutoDepthStencilFormat to D3DFMT_D16. It now comes up with this very odd screen. Here''s another screenie.



I really have no idea what is happening here.


1) Make sure you specify D3DCLEAR_ZBUFFER for your IDirect3DDevice*::Clear(..) call.

2) Check that the near clip plane of your projection matrix is greater than 0 (higher is better - improves the linearity of Z space in the Z buffer).

3) Likewise, check that the far clip plane of your projection matrix isn''t stupidly high given the units your scene uses (i.e. if you''re using 1 unit = 1 metre, don''t have the far plane at 1,000,000).

4) Don''t fiddle with the DEPTHBIAS render states unless you need to.


Simon O''Connor
Game Programmer &
Microsoft DirectX MVP
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Stephen R
Stephen R
Yes, I set D3DRS_ZENABLE true. I tried clearing the ZBuffer at the beginning of each frame but that just stopped anything from being displayed at all.
Stephen R
Stephen R
Wait, its fixed.

All I had to do was set the ZBuffer clear depth to 1.0f. It now renders perfectly.

Thanks a million to all who helped

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.