Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / Depthbuffering on GPU (using CG) Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

March 08, 2005, 02:47 PM


I need to draw splats, with blending (gaussian filtering). Overlapping splats should only be blended if and only if their z-distance is sufficiently small. To do this on hardware, I'm using a 2-pass rendering approach.

This is the plan :
First pass
- draw depth image with small depth offset
- perform depth tests and updates (but no color updates)

Second pass
- draw splats, performing depth tests (but no updates)

(This should work, because it's based on a point rendering paper)

The implementation part is of course where I'm stuck. This is what I have so far :

  3. //enable depthbuffer updates
  4. glEnable(GL_DEPTH_TEST);
  5. //no color updates
  8. drawScene();
  11. //disable depthbuffer updates (make it readonly)
  12. glDisable(GL_DEPTH_TEST);
  13. //enable color updates
  14. glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
  16. drawScene();

The rendering of the blended splats works fine. My problem is that I don't know how to add the small depth offset during the first pass.

Any help is very much appreciated! I hope someone can push me in the right direction :)

PS: I think I have to use a cg fragment shader during the first pass. I looked for information on using cg & depthbuffers, but I can't find anything usefull :(


March 08, 2005, 03:52 PM

No need for CG or other shaders. Just use EXT_polygon_offset.

Christian Sigg

March 08, 2005, 04:43 PM

Hi Cygnus,

As far as I know, adjusting the depth range (glDepthRange) is much faster than using a polygon offset. At least on NVIDIA cards, but I would guess ATI is the same.



March 09, 2005, 10:34 AM

Thanks Reedbeta and Christian for your replies!

Reedbeta: It seems that that extension is exactly what I need, thanks again! ;)
Christian Sigg: How would I do that then? glDepthRange is only for setting the near and far-plane, right? And I need to add a small constant offset to every z-value.

This thread contains 4 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.