Hi computer graphics masters, I experience my first Z fighting, so I don't really know how to handle it.
I firstly searched for posts and advises on both osgforum and google. My problem: I'm working on projective texture mapping through a shader. I do an offscreen rendering to get an image of my Z-buffer. Then I pass interpolated vertex coordinates from the vertex shader to fragment. I project these coordinates in the texture. As I don't want occluded fragments to be textured I compare their distance from the center of projection to the corresponding Z-buffer value. Of course I correct the value according the formula you can find here: http://www.cs.unc.edu/~geom/HOFF/techrep/openglz.html If the projective-camera-space-z-value is bigger than the z-buffer-value I color it in red, else I texture it. Here's a screenshot: [Image: http://img7.hostingpics.net/pics/748304Z_fighting_1.png ] (http://www.hostingpics.net/viewer.php?id=748304Z_fighting_1.png) If I just add one to my z-buffer-value, I get this: [Image: http://img7.hostingpics.net/pics/161394Z_fighting_2.png ] (http://www.hostingpics.net/viewer.php?id=161394Z_fighting_2.png) Which is almost what I want. I thought this was due to the unavoidable imprecision of the Z-buffer. Thus I tried to add the imprecision of the z buffer to the z depth_component value: abs ( z*z / ( 2^(bits_of_z_buffer) * (znear*zfar/(znear-zfar) ) - z ) ) But it didn't resolve the error. Is this problem known by some of you? Thank you in advance! Cheers, Maxime ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15219#15219 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

