About Depth Bounds Test (DBT) and its application in CE3

Source: Internet
Author: User

Depth Bounds Test (DBT)Depth Bounds Test (Depth range detection), which is the feature of the graphics card after the Nvdia GeForce 6 Series (GPU Programming Guide GeForce 8 and 9 Series), not the features of DirectX. Therefore, in the graphical analysis tool such as nsight and pix, it is not visible to the settings. The function of Depth Bounds test is to allow the programmer to make additional pixel discard before the blend render target. This extension adds a new, fragment-by-one test, logically, after the scissor test, in front of the alpha test, the DBT holds the depth value stored at the input fragment coordinate (XW,YW) position, Compared to the user-defined maximum and minimum depth values, if the saved depth value is outside the user-defined range, then the input fragment will be discard off, and unlike the alpha test, DBT does not depend on the depth value of the fragment in the window space. DBT does not rely on the depth value of the output from the pixel shader, but is judged based on the depth position previously saved in the render target.
    • The logic of DBT is behind Scissor test, alpha testing front
    • The Min/max value is clamp between [0, 1] and the illegal value is converted to 0.
    • DBT will be opened when the following conditions are true
      • Min < max
      • Min > 1 and max<1
      • Depth values are used in shader.
About API usage, take CE3 as an example
voidCd3d9renderer::setdepthboundtest (floatFmin,floatFMax,BOOLbenable) {    if(benable) {M_pd3ddevice->setrenderstate (D3DRS_ADAPTIVETESS_X,MAKEFOURCC ('N','V','D','B')); M_pd3ddevice->setrenderstate (d3drs_adaptivetess_z,* (dword*) &fmin); M_pd3ddevice->setrenderstate (d3drs_adaptivetess_w,* (dword*) &FMax); }    Else//Disable depth bound test{M_pd3ddevice->setrenderstate (D3drs_adaptivetess_x,0); }}  

The main use of DBT is two, an example is in the OpenGL extension document example can be used to optimize the stenciled shadow volume rendering

For example, a stack with attenuation and other light sources, can be in the XY window space is bounded by the rectangle, and the traditional scissor test, you can put the rectangle inside the Shadow volume fragment are discard off, ensuring that the shadow is outside the XY range of the Windows window of the light source. andstenciledIt does not matter when the part of the growth or decrease deviates from the fragment of the scissor, because the illumination of the light source outside the scissor area can indeed be completely attenuated. In other words, scissor test can be used to render theScissor outside.Shadow Volume Fragments Directdiscard, which improves performance and eliminates the need to focus on pixels that are not eventually imaged by the attenuated light source. the optimization of the scissor can be used when updating the rendering stenciled shadow volumes (Increase or decrease stencil buffer), and increase the illumination distribution with attenuated light sources. when using DBT, we can also use a similar method to calculate the Z-boundary (Zmin,zmax) of the final illumination information of the attenuation light source in the window space, unless the depth value of the pixel is in this range [Zmin, Zmax], otherwise the illumination of the light can be predetermined and this pixel is irrelevant. Alternatively, the illuminated pixels are far enough in front or rear to attenuate the light source so that the illumination on the pixel is completely attenuated. DBT can do this kind of testing. Another use is the delay rendering like CE3, because the light is converted to the screen space, so in the light processing of the object, you can refer to the previous write light depth, screen space, not in the light depth of the pixel in the range of the DBT clipping off. in CE3.4, it is mostly used in some flat space processing, which eliminates the alpha test step and the extra pixel padding
generate SCENEDIFFUSEACC, using DBT can save the sky part of the pixel to judge and fill theGenerate AOCd3d9renderer::generateao
    1. Setdepthboundtest (0. F,0.9999f,true);

      Rain effect
      Cd3d9renderer::fx_deferredrainlayer ()

CONSTVEC4 vdepthbounds =cdeferredshading::instance (). Getlightdepthbounds (Rainvolparams.m_vworldpos, Rainvolparams.m_fradius); Setdepthboundtest (Max (vdepthbounds.x, Fminz), Min (vdepthbounds.z, fmaxz),true);

Snow effect
Cd3d9renderer::fx_deferredsnowlayer ()

CONSTVEC4 vdepthbounds =cdeferredshading::instance (). Getlightdepthbounds (Snowvolparams.m_vworldpos, Snowvolparams.m_fradius); Setdepthboundtest (Max (vdepthbounds.x, Fminz), Min (vdepthbounds.z, fmaxz),true);

Delay Light Shading
Cdeferredshading::lightpass

    1. VEC4 pdepthbounds =getlightdepthbounds (pDL); Rd->setdepthboundtest (pdepthbounds.x, Pdepthbounds.z,  True);

      Delayed coloring of IBL
      Cdeferredshading::D Eferredcubemappass

    1. VEC4 pdepthbounds =getlightdepthbounds (pDL); Rd->setdepthboundtest (pdepthbounds.x, Pdepthbounds.z,  True);

      Screen Space Reflection
      Cdeferredshading::screenspacereflectionpass

    1. Rd->setdepthboundtest (0.0f,0.9999f,true);

      Cdeferredshading::D Irectionalocclusionpass ()

    2. Cdeferredshading::D Irectionalocclusionpass ()

      Shadow handling
      Cdeferredshading::shadowlightpasses ()

    1. VEC4 pdepthbounds =getlightdepthbounds (& Light); Rd->setdepthboundtest (pdepthbounds.x, Pdepthbounds.z,true);

      In order to ignore the sky part in the drawing.
      void Cdeferredshading::render ()

LPV IlluminationCrelightpropagationvolume::D eferredapply ()
if (crenderer::cv_r_deferredshadingdepthboundstest) {    =cdeferredshading::instance (). Getlightdepthbounds (Rrendsettings.m_pos, m_fdistance);    Rd->setdepthboundtest (pdepthbounds.x, pdepthbounds.z,true); // Skip Skyonly for GI}

The modification method is also relatively simple, close the cv_r_deferredshadingdepthboundstest, or add clip in the shader to discard off pixels, or with alpha test instead, but these two methods on the mobile platform taboo, So we need further testing to get results.

About Depth Bounds Test (DBT) and its application in CE3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.