• Advertisement
Sign in to follow this  

Strange 'bug'.

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

Ok, so i'm just trying to desplay the teapot mesh on the screen... Dose anyone know what would cause this? I just need a place to start looking. all i have is my one light and this teapot (loaded from a .x file). Photobucket same thing when i used a monkeyhead... Photobucket This is how it should look (loaded with the SDK's viewer)... Photobucket

Share this post


Link to post
Share on other sites
Advertisement
Yeah, definitely a Z-buffer issue, but I don't think back-face culling has anything to do with it.

Are you creating a depth buffer (EnableAutoDepthStencil=TRUE in your present params when you create the device)? What depth-buffer format are you using? And what are your near and far clip planes set to? Your near plane should be as far as possible (And certainly not zero, that won't work), and your far clip plane should be as near as possible.

Share this post


Link to post
Share on other sites
Quote:
Original post by DarkPsychosis
Looks a little like Z-Buffer reading is off and that back-face culling is set correctly.


how dose one check on that?

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Yeah, definitely a Z-buffer issue, but I don't think back-face culling has anything to do with it.

Are you creating a depth buffer (EnableAutoDepthStencil=TRUE in your present params when you create the device)? What depth-buffer format are you using? And what are your near and far clip planes set to? Your near plane should be as far as possible (And certainly not zero, that won't work), and your far clip plane should be as near as possible.



ok, first off... i have EnableAutoDepthStencil = false. my NearPlane is .1 and my far plane is 100.

Share this post


Link to post
Share on other sites
ok... i THINK it's working.

what i did was i set:
EnableAutoDepthStencil = true;
AutoDepthStencilFormat = DepthFormat.D16;

and when i cleared my scene i also cleared the Z-buffer with:
DXdevice1.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0);
DXdevice1.Clear(ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);

Is this the 'correct' way to clear the z-buffer?

---EDIT---
oh... oops: i guess the 'correct' way is...
DXdevice1.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);

Share this post


Link to post
Share on other sites
EnableAutoDepthStencil = false

this wants to be, for example:

    EnableAutoDepthStencil = true
    AutoDepthStencilFormat = D3DFMT_D16;

The Depth buffer is what you use to determine the depth of each pixel in framebuffer, without it the renderer doesn't know that one pixel should be in front of another. The "D3DFMT_D16" refers to the bit-depth of the depth buffer, obviously the higher that number the better but D3DFMT_D16 is a "safe" choice to use these days as pretty much any gfx card will have it.

Before depth buffers (long ago when I started coding) you used to have to depth sort all of your polygons before you rendered them. This is called the "painters algorithm" and the depth buffer avoids this overhead for simple scenes.

You might want to do a little bit of reading up about it.

Good luck.

Andy

[edited] to include depth format.

Share this post


Link to post
Share on other sites
Quote:
Original post by Neon_C
ok... i THINK it's working.

what i did was i set:
EnableAutoDepthStencil = true;
AutoDepthStencilFormat = DepthFormat.D16;

and when i cleared my scene i also cleared the Z-buffer with:
DXdevice1.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0);
DXdevice1.Clear(ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);

Is this the 'correct' way to clear the z-buffer?

---EDIT---
oh... oops: i guess the 'correct' way is...
DXdevice1.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);
Yup, exactly. You should really check that the depth buffer format is compatible with your backbuffer format too (CheckDepthStencilMatch). If you have EnableAutoDepthStencil set to false, then D3D won't create a Z-buffer for you; you're effectively telling D3D you'll create one yourself.

Share this post


Link to post
Share on other sites
Quote:
Original post by NineYearCycle
Zbuffer

[edited] to include depth format.


Thanks.
- I think i've got it figured out now. I havnt done any 3d programming sence highschool (wrote a bad flight sim in C++ and Asimbly on a 386sx). i'm still trying to wrap my head around the d3d api.


Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Neon_C
ok... i THINK it's working.

what i did was i set:
EnableAutoDepthStencil = true;
AutoDepthStencilFormat = DepthFormat.D16;

and when i cleared my scene i also cleared the Z-buffer with:
DXdevice1.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0);
DXdevice1.Clear(ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);

Is this the 'correct' way to clear the z-buffer?

---EDIT---
oh... oops: i guess the 'correct' way is...
DXdevice1.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);
Yup, exactly. You should really check that the depth buffer format is compatible with your backbuffer format too (CheckDepthStencilMatch). If you have EnableAutoDepthStencil set to false, then D3D won't create a Z-buffer for you; you're effectively telling D3D you'll create one yourself.

Awesome... Thanks for all your help!

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
I don't think back-face culling has anything to do with it.


Neither do, I just wanted to ensure it was eliminated as a target for investigation.

As a quick check I suggest just bashing the D3D device with these three.

Device->SetRenderState(D3DRS_ZENABLE, TRUE);
Device->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
Device->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATEREQUAL);

Mind, this should really just be for testing. Messing with the Render State all the time is a really quick way to write very slow code.

Share this post


Link to post
Share on other sites
Note to self..

Don't take so long writing a reply that by the time you click 'reply' it's been answered 20 times already (and more effectively).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement