Why they fight?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Why they fight?

Post by Vsk »

A-ha, gotcha!.:D
Well, seriouly, I got some z-fitghtin and I don't know hot to solved.
I have my terrain and over it a put a squad with a texture to make the tank track print.
But it seems sometimes that the z-distance is not well calculate and the terrain sometimes occlude the print.
What are the technics to solve this kind of fighting?

Thanks ins advance.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Playing with camera near and far plane can help.
LittleGiant
Posts: 15
Joined: Wed Jun 02, 2004 1:53 am

Post by LittleGiant »

If you make sure your tank treads are draw after your terrain, you could disable the z compare on the material. However this could easily cause issues with tank treads on the back of a hill side.

Your best bet is to likely add some epsilon to the positions of the geometry for the treads so that the floating point inaccuracy isn't significant enough to give you z compare "fights".
LittleGiant
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess we have to make the polygon offset a material property, in order to simplify decal like rendering. I'll check this.
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

arras wrote:Playing with camera near and far plane can help.
What values do you sugests?

I actualy using 0.01f for near value, and 10000 for far. My scale is 5 unitis 1 meter.

Your best bet is to likely add some epsilon to the positions of the geometry for the treads so that the floating point inaccuracy isn't significant enough to give you z compare "fights".
I don't understand quite well what do you recommed to do.
Do you mean like separating more the squad from the terrain?
if so, already is quite separted them (but not su much to view floating over the terrain).

Thanks.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

http://www.sjbaker.org/steve/omniv/love ... uffer.html

Code: Select all

  z_buffer_value = (1<<N) * ( a + b / z )

  Where:

     N = number of bits of Z precision
     a = zFar / ( zFar - zNear )
     b = zFar * zNear / ( zNear - zFar )
     z = distance from the eye to the object

  ...and z_buffer_value is an integer.
use that code to find the optimal values
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Very good. Thanks
Post Reply