Culling error or z-buffer?

Started by
9 comments, last by evolutional 20 years, 8 months ago
I have D3D doing calculating my z-buffer for me. Meshes are just placed in the scene as I created them (no manual z ordering YET - but should it make a difference?) and i keep getting this weirdness happening on running the demo. The first image is showing that the surfaces are showing properly from this angle. However, on this second image the surface I have marked on in red is completely transparent. I don't think it's a normalisation problem but I am willing to recreate this model again as so far it is very simple, however if this is going to be a recurring issue, I don't want to have to keep making the models again to test. it hasn't occurred on any other models YET. Looking at the image again, it seems that the error is not with the highlighter surface, but the mesh NEXT to it. It is showing over the top of model in the foreground. Is this a z-buffer issue? I am posting here to see if anyone else has had similar problems to this, if so - what was it and how did you overcome it? My thoughts are that it is either: a) a normalisation error on the model (but I don't think so) b) a z-buffering problem - curable maybe by manually ordering the objects? c) a culling problem in the rendering - unlikely d) something I've not thought about Any ideas people? EDIT: Damned images [edited by - downgraded on August 10, 2003 6:25:21 PM]
Advertisement
You could try disabling backface culling, just to eliminate it (or polygon winding-related problems) as the cause.
Done and...



It all goes screwy.

Everything, even the models that were previously fine.

Is this a Z-buffer thing?

Also... If my camera looks straight down (eg:, imagine if it''s at 0,50,0 looking at 0,0,0) I get nothing rendered. I have to offset the z co-ord of the camera by a tiny fraction to see anything. Is this related maybe?
Just a thought - are you clearing your z-buffer? Forgetting this may (will) cause a real mess. Also, try to turn off any lighting.
quote:Original post by downgraded
If my camera looks straight down (eg:, imagine if it''s at 0,50,0 looking at 0,0,0) I get nothing rendered.


if you are using the wretched lookat functions as "camera" then you should have a look at the docs and see how the function works. obviously your "up" cant be the same as your "forward". imagine a stick pointing out of your head and then look straight down. if this stick would still be pointing at your ceiling then youd be in quite some pain (despite the one already caused by having a stick in ones head). now take two more, stick one in your right ear and one in your mouth. those are the three vectors you need (or in this case, that lookat tries to calculate). no matter how you twist your head, the can NEVER point in the same or opposite directions.

about that bug. if disabling backface culling is resulting in chaos, then something must be completely wrong. disable any form of culling and add it step by step to see where the problem appears.

f@dzhttp://festini.device-zero.de
This program should not occur when using z-buffering. Try the following:

- Anywhere in your game, do you disable z-buffering? (like for particle effects) and forget to turn it on again? It might be that you render the left part first, the disable z-buffering and the render the right part.

- Try again with backface culling. The reason you got the mess on your last shot is because you got the drawing order wrong. What you see in the last screenshot is that you only render the backfaces. You should ony render the front faces. Thjere''s probabley a command in D3D to reverse the drawing order from counterclockwise (CCW) to clockwise (CW) or to switch between backface culling and frontface culling.

- Make sure you clear the z-buffer every frame at the same time you clear the color buffer.

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

quote:Original post by Sander
- Try again with backface culling. The reason you got the mess on your last shot is because you got the drawing order wrong. What you see in the last screenshot is that you only render the backfaces. You should ony render the front faces. Thjere''s probabley a command in D3D to reverse the drawing order from counterclockwise (CCW) to clockwise (CW) or to switch between backface culling and frontface culling.


Disabling backface culling shouldn''t cause a mess if Z-buffering is working correctly - it is only unoptimal because unnecessary polygons are drawn.
Okay, I've poked around to no avail.

In the last shot you see, Z buffering is enabled and the cullmode is set to CULL_NONE and yes, it's drawing only the backfaces.

The Z-buffer is being cleared each frame and it's always enabled. I really don't understand what the problem is

In regards to the 'wretched' Lookat function, yes I am using that. Would calculating the view matrix by hand solve the problems mentioned in regards to this?

I'll have a look into the vertex buffering of the objects, it may lie in there *shrug*. I'm sort of running out of options here. I am, however, suprised it ONLY happens on my NEW model.

EDIT: It happens on a new model too (just a cube). I am wondering if the problem is created by the camera problem I mentioned previously? If so, would calculating the view matrix by hand help? I always though that the Lookatfunction just sped things up and didn't create weirdness.

[edited by - downgraded on August 11, 2003 7:00:40 AM]
quote:Original post by Anonymous Poster
Disabling backface culling shouldn''t cause a mess if Z-buffering is working correctly - it is only unoptimal because unnecessary polygons are drawn.


I know but it might shed some light on the cause of the problem. The screenshot I was referring to is the one from his last post, in which he showed the results of this backface culling, where all is black. The 3D card doesn''t use the normals for backface culling. It only uses them for lighting. So when you draw something clockwise and set the normal in the counterclockwise order (like his models apparentaly do) you''ll get all the black shapes. They get drawn because they are front faces (CW drawing order) with their normals pointing away (in CCW order).

Anyway, I still think it''s a clearing problem or some wrong settings in the z-buffer tests. The missing polygon gets renderen alright (liik at the second screenshot poster) but the black inside polygon connected to the right part of the model is rendered over it, as if it passes the z-test where it should fail. Also, I see some z-fighting artifacts I think (look just below the arrow. The stippeled line on the black surface).


Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

The thing you thought was an artifact is actually my texture. The game I''m making has working extures (if you couldn''t tell) so the texture is actually just the UV map with ''INNER FACE'' written on it - the text is causing the line you see.

I''m going to sit down and hammer the entire drawing thing tonight so I''ll see what I can do. *shrug.

I hate problems like these though!

This topic is closed to new replies.

Advertisement