   Problem using : glDepthFunc(GL_EQUAL);
  hi, (sorry about my poor english, i''m from quebec)So I''m making a 3D engine. I want to have mark on walls. (decals) So for doing that, I want to draw my decals exactly on the wall and use Depth func set to GL_EQUAL. That''s mean that I only want to view the part on the mark that is on my wall (GL_EQUAL to another surface). But GL_EQUAL work very good if my mark is exactly the same size of my wall. (like I made for my static shadow). But my decal is tinest than my wall. And GL_EQUAL don''t want to work correctly. I see it, but if I turn my view, I lost some part of it. (like Half Life with not suported card).Can someone help me please ?thx    Troa Technologies.(real time ray tracing shadow : DK 3d engine)  
  The problem you''re experiencing is due to floating point imprecision. To get the effect you want, you''re going to have to use a different approach. Multitexturing is probably the ideal solution, though there are other approaches.  ;  GL_EQUAL (or GL_NOTEQUAL) are very evil compare functions. They should never be used in normal depth buffer operation (they are handy for a few very special effects though). The problem is, as Myopic Rhino pointed out, floating point precision. Your 3D coordinates are floating point, and undergo lots of transformations when sending them down the pipeline, so that you''ll get inaccuracies. Additionally, floating point numbers themselves have a limited precision range. So, if you draw a large quad (eg. a wall), the depth buffer will fill with certain values. If you draw further geometry on the same plane as the wall, then it cannot be guaranteed, that the z position of a pixel will be exactly at the same value than the one of the original wall. It could be a tiny little bit infront or behind it. But since it''s not equal anymore, your GL_EQUAL operator will cull it away. This leads to the visually very unpleasant effect you experienced, that''s commonly called ''z-tearing''. How to overcome this problem ? The best solution is what Myopic suggested: multitexturing. Unfortunately, this is not always simple, esp. if you are a beginner. But there are other methods you can try:First, *never* use a direct compare on floating point numbers. Since OpenGL does not support an ''approximate'' compare operator (unfortunately, would be very nice), you can start by using GL_LEQUAL (or GL_GEQUAL, depends on how you setup your depth buffer). That way, pixels floating slightely above the wall will already be drawn. But you still have the problem of pixels floating behind the wall.You can try using the glPolygonOffset() command for that. It is used to ''shift'' your decal out of it''s original plane a tiny little bit, so that all z-values are infront of the wall. The amount you have to shift depends on how much accuracy problems you have, you''ll need to try around a bit with the values.Just one more thing: polygon offset has a somewhat negative reputation amongst lots of OpenGL programmers, since it is seen as a kind of dirty ''hack''. That''s not true. If well parametrized, it can be extremly useful. However, I would recommend you to have a look at multitexturing as soon as you can, since that''s definitely the optimum solution./ Yann  