Archived

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

RaptorZero

Polygons not respecting their depth order

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites