Jump to content
  • Advertisement
Sign in to follow this  

depth layer number

This topic is 2161 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


In other words, during rendering, many fragments happens in one pixel, ...

In principle: Each render (geometry/depth) pass writes its color into a texture, and a final pass blends the textures into the final image. Because each rendering targets a specific texture and is to be set-up accordingly, the correspondences are a-priorily known, and the texture will receive color for a specific depth layer only.


... but one remains to be the final color due to depth test.

If just one color would remain due to depth test in the end, then depth peeling would not be needed at all.


obvioursly, render times and times again to get a more "deeper" image and finaly see if there are any shading pixel is one way.

The very first render pass finds all the geometry that is at most in front. It is comparable to a standard rendering pass, because the fragments with the nearest depth win. The second render pass finds all geometry that is behind geometry found by the first pass. And so on. As soon as a pass has not found geometry, any following pass will also find nothing. So we have a progressive refinement with each pass, and already the first pass gives you results. It usually makes no sense to look for very deep layers. Dependent on the use case, it may already be enough to make 3 or 4 passes.


BTW: If your question is based on a specific implementation detail, then please tell us about.

Share this post

Link to post
Share on other sites

I don't konw this meaning.

It means that although a scene may have 20 depth layers, it is seldom meaningful to actually render them all. E.g. if each layer has a transparency of 75%, then the 10-th layer has an effect of 5.6% only, and the 20-th layer has an effect of 0.3%. However, if you want to render a deep image (i.e. without especially considering transparency), then ignore this argument.


My question is that, I want a number of depth images to represents a scene. However, I don't know how much the layer number is.  ...

The perhaps fastest approach would be to render the geometry without writing color or depth. Then in the fragment shader increment a counter for each fragment for which the shader is invoked (gl_FragCoord.xy). The stencil buffer can probably be used for this, or perhaps an offscreen integer render target (details need to be investigated). Doing so requires a single pass.


The above approach can be extended if only transparent layers in front of opaque geometry should be counted. Then render the opaque geometry as usual, and perform the above counting with the depth buffer left from opaque geometry.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!