   how to shift the depth buffer(depth values) away a bit from the camera
  hello guys,i'm trying to implement a point based rendering method. the method is consisted of two passes. during the first pass, the object is rendered to the depth buffer, and the depth buffer should be moved away from the camera to avoid certain artifact. question is how this can be accomplished? my idea is to write a frag shader and write to the gl_FragDepth by hand. but i kinda doubt about this idea, because think of two fragments(pixels), A and B, and suppose A has a depth 0.5 and B has a depth 0.55. and if i want to shift the depth buffer away from the screen by 0.1. suppose i draw B first, i then write to the depth buffer 0.55-0.1=0.45, and then i draw A. since A has a larger depth value than the shifted depth value of B, A will come in front of B, although it should be occluded by B.i don't know if i have some misunderstanding of the graphics pipeline, cause i thought that the depth test should come before the fragment shader, as the depth test can filter out fragments that are occluded. in this way, the computation required for rendering can be reduced. however, in this case, any change of the depth value during the fragment shader will alter the rendering behavior of the incoming fragments.and i just happened to see this post http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=242246they said that the depth test comes after the fragment shader. that kinda makes sense to me, as the fragment shader should be executed in parallel, if two execution try to write to the same depth buffer address, that will be a problem. so each pixel must have its own depth value, and then pixels are composed during the next stage. in that case, my idea of shifting the depth value individually in the fragment shader should work.but is there any other way of doing this?i really shouldn't mess up "pixels" and "fragments"   
  glPolygonOffset(1,0.1);glEnable(GL_POLYGON_OFFSET_FILL);play around with the values   ;  The PolygonOffset function only works with polygons. You can perform some kind of shift using DepthRange for all kinds of objects. For instance :glDepthRange(0, 0.9);// draw objects that should be closer hereglDepthRange(0.1, 1);// draw objects that should be farther hereAlso, to answer to your depth test question, yes the depth is tested *after* the fragment shader. However, if you don't specify a gl_FragDepth output in your fragment shader, this means you use the default depth computation, and most graphics card will be able to optimize it and cull fragments earlier thanks to algorithms such as "early-Z" so that some fragments will not be computed at all because the graphics card will know beforehand that the fragment would fail the depth test anyways. So, in some way, there is a hidden depth test that occurs *before* the fragment shader.   