Polygons not respecting their depth order

Started by
5 comments, last by RaptorZero 20 years ago
Hey ya all, i''m creating a program to load a .smd(decompiled half-life model) file with animations and so far i can get a model without textures to load up. Ok here comes the problem: when i look at the model from a close distance its allright, but when i start going farther it becomes strange. Some polygons that should be behind others start to jump over theese others (eg: one leg of the character appears through the other) and there is a ''saw'' effect at the connection of some faces. How can I fix that? The faces normals are OK (i''m using lighting and everything is good and the inner part of the model is cull''ed) Thanx for reading this and if you''re having this same problem post here too...
error C2065: 'signature' : undeclared identifier
Advertisement
What''s the distance of the far and near clipping plane? And what are the dimensions of you model? I guess that your clipping volume is too large compared to the model size, so z-fighting may occur.
My model is actualy a pig that would fit in a 100x300x200 (width x lenth x heigth) box and the near and far clipping are 0.1f near and 2000.0f far, like this:

gluPerspective(45.0f, width / height, 0.1f, 2000.0f);
error C2065: 'signature' : undeclared identifier
Set the near clipping plane to a higher value and the far to a lower, this will increase detail in higher depths.

EDIT: what you are dealing with is indeed z-fighting, set the near clip plane to a higher value and it will be solved (a value like 0.5 will be a great improvement)

[edited by - Tree Penguin on March 28, 2004 4:25:55 PM]
I''ve done what you sugested, i''ve set the near clipping plane to 0.5f and it still had the same problem, only this time i had to be much farther for that to happen... So I changed the near clip to 1.0f and then to 1.5f and now everything''s fine!
So the higher I set the near clipping plane, the farther I can go from the model without that "z-fighting", right?

And one last question: Do you think that scaling the model(making it smaller) would help in some way?

Ok thanx a lot man, you''re great(!), in 15 minutes I''ve completely solved this anoying problem!

PS: forgive any english mistakes, I''m not american :D
error C2065: 'signature' : undeclared identifier
another thing.
Your model scale is slightly to big, because the z-buffer is not linear so at a distance the difference between two z-levels is alot greater than if it''s close to the nearplane.
By bringing the scale down you can draw the model closer to the nearplane thus you can get a better resolution.

I recently did some graphics for a project in the scale 1m=100.0f, and it required a sign on a wall(a single polygon with a texture on it), and even though it was slightly offset from the wall it started flashing when i moved away from it at a fairly close distance.
But because the scale was at 100 when i moved about 30 meters away from it the z value was then at around 3000(and at that distnace there is not much resolution left in z space), and if z goes from 1 to 10000 you can start to see where this is going.

a good scale is 1.0f=1 meter.
and personaly, i wouldn''t want to face a 200 meter high pig.

---------------------------------
For an overdose of l33tness, flashbang.nu
Ok, I''ll scale the pig (I''ll make my app divide all the coords by 100 when precaching the model) so it looks like an average pig not some giant mutant pig

Thanx for everything guys, cya!
error C2065: 'signature' : undeclared identifier

This topic is closed to new replies.

Advertisement