Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Psychocatt

'CullMode' or 'The Man With X-Ray Vison!'

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

I am just learning about 3D programming and tried the tutorial from wazoo (www.wazooenterprises.com). I got it to where it displays and rotates the box, but I get some strange effects. I put in lpD3DD->SetRenderState(D3DCULLMODE, D3DCULL_NONE) and when it draws the box, it seems like it draws the sides first, then the top(or lid) and then the bottom. The end effect is that bottom and the top cover up the sides. However, if I turn the cull mode to D3DCULL_CCW or just comment out the line, it all appears just fine. Maybe I am misunderstanding what the D3DCULL_NONE is supposed to do. Maybe my videocard just isn''t that great, but I would like to know if anyone knows why this maybe happening and what the correct/best way to fix it is. Thank you for your time! "I kinda think, therefore, I kinda... am?"

Share this post


Link to post
Share on other sites
Advertisement
Well I''m not a D3D programmer, but if you''re getting the faces of your box looking wrong then perhaps you need to enable the Z-buffer?

I assume D3DCULL_NONE means don''t perform backface culling.

Share this post


Link to post
Share on other sites
um... D3DCULL_CCW is the default mode set by Direct3D, so to set it into that mode won''t have any effect. (hence: no difference if you comment it out or not)...


lurkie

Share this post


Link to post
Share on other sites
That would explane why I get the same effect when I use D3DCULL_CCW and comment out the line, but what about with D3DCULL_NONE? I still don't get why it does what it does. I have posted a picture with side by side comparisons on my site,http://psychocatt.sphosting.com/cube.html
Maybe I just didn't explane it clear enough, since I don't really understand what is happening. Thanks for your time!

"I kinda think, therefore, I kinda... am?"

Edited by - Psychocatt on November 27, 2000 3:35:24 PM

Share this post


Link to post
Share on other sites
I don''t know if the Z-buffer is enabled or not. Like I said, I''m just starting learning. I am doing the tutorial at wazoo''s website. http://www.wazooenterprises.com/tutorials/tutorial1-D3D8.asp
I don''t see anything about the Z-buffer. There is only information about the vertex and index buffer. I have heard about the z buffer(and a w buffer) but I don''t really know anything about them. I would like to learn about 3D, but I don''t really know if I am ready. Maybe I should just stick to 2D for now.

"I kinda think, therefore, I kinda... am?"

Share this post


Link to post
Share on other sites
Backface culling means that the GPU (or whatever) doesn't draw the faces that aren't facing the camera.

This is done by checking if the normal of the face points towards or away from the camera.

The CCW and CW (counter clock wise, resp clock wise), tell D3D in what order your vertices are defined. If you just draw a triangle on a piece of paper, you have no way of knowing which is the front and which is the back side (it's just 3 points). By being consistent in the way that the vertices of in face as ordered, D3D knows which side is front and which side is back.

What happens when you turn off back face culling (D3DCULL_NONE) is that you tell D3D not to throw away any triangles, regardless of the direction they are facing. The triangles will be drawn in the order they are given, without any rejection (due to bfc), which means that sometimes it will look okay, and sometimes not.

Z-Buffer will solve this for you. A Z-buffer is just an array (the same size as the screen) that holds the value of the closest point to the camera for each pixel. Before drawing a new pixel, D3D will check if the pixel it is about to draw is closer than the one in the z-buffer, if it is, it will draw the pixel, and update the z-buffer, otherwise it will just skip the pixel all together..

Hope this helps,
Magnus

Edited by - dooz on November 28, 2000 4:13:17 AM

Share this post


Link to post
Share on other sites
Hmmm....

Definately a Z buffer problem.

If you are using Dx8, you just enable the Z Buffer, but you must create it and stuff yourself in Dx7 or earlier.

The reason for the odd display is the rendering order. If culling is off, all polygons are drawn (probably the face you are looking at first). With culling on (its on by default), the "backwards" polygons(from your persepective, top and sides) are not drawn.

Either leave Culling on, or simply enable the Z buffer. If you need further help with the Z buffer, feel free to ask

Thanks,
Etnu

Sometimes I think I know what I really don''t, but then again usually I do know what I don''t, but just don''t realize it, maybe its because I am so young, but then again it could be because I am insane.

Share this post


Link to post
Share on other sites
Ok, I looked up some information on buffers in the SDK docs. I would think that I could enable the z-buffer by calling SetRenderState( D3DRS_ZENABLE, TRUE) to enable it and then I could change how it calculates this by calling SetRenderState with D3DRS_ZFUNC. The SDK help did mention somthing about a w-buffer and I have heard it mentioned before, but the explanation didn''t realy go into detail. Is this similar to the z-buffer or is it better? I though in 3D there were only 3 dimensions. Thanks for your time!

"I kinda think, therefore, I kinda... am?"

Share this post


Link to post
Share on other sites
Since Z-Buffering is disabled, the faces are not being ordered and so the invisible faces are sometimes rendered in front of the visible ones. If you enable back face culling, this will not happen any more for convex objects without Z-Buffering and will also speed up your rendering. You should also enable Z-Buffering so that objects are rendered with respect to each other correctly.



Please state the nature of the debugging emergency.


sharewaregames.20m.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!