15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_depth_clamp
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_depth_clamp
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Jon Leech (jon 'at' alumni.caltech.edu)
125bd8deadSopenharmony_ci    Mark J. Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com)
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ciNotice
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ci    Copyright (c) 2009-2013 The Khronos Group Inc. Copyright terms at
175bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ciSpecification Update Policy
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
225bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
235bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
245bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
255bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
265bd8deadSopenharmony_ci    described in more detail at
275bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciStatus
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    Complete. Approved by the ARB on July 3, 2009.
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciVersion
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    Version 3, 2009/08/02.
365bd8deadSopenharmony_ci    Based on NV_depth_clamp version 4, modified 2003/01/08.
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ciNumber
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    ARB Extension #61
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ciDependencies
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci    Written based on the wording of the OpenGL 3.1 specification.
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    ARB_compatibility affects the behavior of this extension.
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ciOverview
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    Conventional OpenGL clips geometric primitives to a clip volume
515bd8deadSopenharmony_ci    with six faces, two of which are the near and far clip planes.
525bd8deadSopenharmony_ci    Clipping to the near and far planes of the clip volume ensures that
535bd8deadSopenharmony_ci    interpolated depth values (after the depth range transform) must be
545bd8deadSopenharmony_ci    in the [0,1] range.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    In some rendering applications such as shadow volumes, it is useful
575bd8deadSopenharmony_ci    to allow line and polygon primitives to be rasterized without
585bd8deadSopenharmony_ci    clipping the primitive to the near or far clip volume planes (side
595bd8deadSopenharmony_ci    clip volume planes clip normally).  Without the near and far clip
605bd8deadSopenharmony_ci    planes, rasterization (pixel coverage determination) in X and Y
615bd8deadSopenharmony_ci    can proceed normally if we ignore the near and far clip planes.
625bd8deadSopenharmony_ci    The one major issue is that fragments of a  primitive may extend
635bd8deadSopenharmony_ci    beyond the conventional window space depth range for depth values
645bd8deadSopenharmony_ci    (typically the range [0,1]).  Rather than discarding fragments that
655bd8deadSopenharmony_ci    defy the window space depth range (effectively what near and far
665bd8deadSopenharmony_ci    plane clipping accomplish), the depth values can be clamped to the
675bd8deadSopenharmony_ci    current depth range.
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci    This extension provides exactly such functionality.  This
705bd8deadSopenharmony_ci    functionality is useful to obviate the need for near plane capping
715bd8deadSopenharmony_ci    of stenciled shadow volumes.  The functionality may also be useful
725bd8deadSopenharmony_ci    for rendering geometry "beyond" the far plane if an alternative
735bd8deadSopenharmony_ci    algorithm (rather than depth testing) for hidden surface removal is
745bd8deadSopenharmony_ci    applied to such geometry (specifically, the painter's algorithm).
755bd8deadSopenharmony_ci    Similar situations at the near clip plane can be avoided at the
765bd8deadSopenharmony_ci    near clip plane where apparently solid objects can be "seen through"
775bd8deadSopenharmony_ci    if they intersect the near clip plane.
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ciIssues
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    Another way to specify this functionality is to describe it in terms
825bd8deadSopenharmony_ci    of generating the equivalent capping geometry that would need to be
835bd8deadSopenharmony_ci    drawn at the near or far clip plane to have the same effect as not
845bd8deadSopenharmony_ci    clipping to the near and far clip planes and clamping interpolated
855bd8deadSopenharmony_ci    depth values outside the window-space depth range.  Should the
865bd8deadSopenharmony_ci    functionality be described this way?
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci      RESOLUTION:  No.  Describing the functionality as capping is
895bd8deadSopenharmony_ci      fairly involved.  Eliminating far and near plane clipping and
905bd8deadSopenharmony_ci      clamping interpolated depth values to the depth range is much
915bd8deadSopenharmony_ci      simpler to specify.
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci    Should depth clamping affect points or just line and polygon geometric
945bd8deadSopenharmony_ci    primitives?
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci      RESOLUTION:  All geometric primitives are affected by depth
975bd8deadSopenharmony_ci      clamping.
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci      In the case of points, if you render a point "in front of" the
1005bd8deadSopenharmony_ci      near clip plane, it should be rendered with the zw value min(n,f)
1015bd8deadSopenharmony_ci      where n and f are the near and far depth range values if depth
1025bd8deadSopenharmony_ci      clamping is enabled.  Similarly, a point "behind" the far clip
1035bd8deadSopenharmony_ci      plane should be rendered with the zw value max(n,f).
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci    How should the setting of the raster position function when depth
1065bd8deadSopenharmony_ci    clamping is enabled?
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci      RESOLUTION:  When setting the raster position, clamp the raster
1095bd8deadSopenharmony_ci      position zw to the range [min(n,f),max(n,f)] where n and f are
1105bd8deadSopenharmony_ci      the near and far depth range values.
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci      This rule ensures that the raster position zw will never be outside
1135bd8deadSopenharmony_ci      the [0,1] range (because n and far are clamped to the [0,1] range).
1145bd8deadSopenharmony_ci      We specify the raster position to be updated this way because
1155bd8deadSopenharmony_ci      otherwise a raster position zw could be specified outside the [0,1]
1165bd8deadSopenharmony_ci      range when depth clamping is enabled, but then if depth clamping
1175bd8deadSopenharmony_ci      is subsequently disabled, that out-of-range raster position zw
1185bd8deadSopenharmony_ci      could not be written to the depth buffer.
1195bd8deadSopenharmony_ci
1205bd8deadSopenharmony_ci      This semantic can make for some unexpected semantics that are
1215bd8deadSopenharmony_ci      described here.  Say that depth clamping is enabled and the raster
1225bd8deadSopenharmony_ci      position is set to point behind the far clip plane such that the
1235bd8deadSopenharmony_ci      pre-clamped zw is 2.5.  Because depth clamping is enabled the
1245bd8deadSopenharmony_ci      raster position zw is clamped to the current near and far depth
1255bd8deadSopenharmony_ci      range values.  Say these values are 0.1 and 0.9.  So 2.5 is clamped
1265bd8deadSopenharmony_ci      to 0.9.
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci      Now consider what happens if a bitmap (or image rectangle) is
1295bd8deadSopenharmony_ci      rendered with depth testing enabled under various situations.
1305bd8deadSopenharmony_ci      If depth clamping remains enabled and the depth range is unchanged,
1315bd8deadSopenharmony_ci      the bitmap fragments are generated with a zw of 0.9.
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ci      However, if depth range is subsequently set to 0.2 and 0.8 and
1345bd8deadSopenharmony_ci      depth clamping is enabled, the bitmap fragments will have their
1355bd8deadSopenharmony_ci      zw depth component clamped to 0.8.  But if the depth range was
1365bd8deadSopenharmony_ci      changed to 0.2 and 0.8 but depth range clamped is disabled, the
1375bd8deadSopenharmony_ci      bitmap fragments will have a 0.9 zw depth component since then
1385bd8deadSopenharmony_ci      the depth clamping is then not applied.
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci    What push/pop attrib bits should affect the depth clamp enable?
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci      RESOLUTION:  GL_ENABLE_BIT and GL_TRANSFORM_BIT.
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    How does depth clamping interact with depth replace operations (say
1455bd8deadSopenharmony_ci    from NV_texture_shader)?
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci      RESOLUTION:  The depth clamp operation occurs as part of the depth
1485bd8deadSopenharmony_ci      test so depth clamping occurs AFTER any depth replace operation
1495bd8deadSopenharmony_ci      in the pipeline.  A depth replace operation can reassign the
1505bd8deadSopenharmony_ci      fragment's zw, but depth clamping if enabled will subsequently
1515bd8deadSopenharmony_ci      clamp this new zw.
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci    Does depth clamping affect read/draw/copy pixels operations involving
1545bd8deadSopenharmony_ci    depth component pixels?
1555bd8deadSopenharmony_ci
1565bd8deadSopenharmony_ci      RESOLUTION:  No.
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ci    Does depth clamping occur after polygon offset?
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ci      RESOLUTION:  Yes.  Depth clamping occurs immediately before the
1615bd8deadSopenharmony_ci      depth test.
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    Can fragments with wc<=0 be generated when this extension is supported?
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci      RESOLUTION: No. The OpenGL Specification was revised in 2006/08 to
1665bd8deadSopenharmony_ci      remove explicit references to w_c <= 0, since the clip volume test
1675bd8deadSopenharmony_ci      disallows all such vertices. Corresponding language has been
1685bd8deadSopenharmony_ci      removed from this extension specification as well. Such fragments
1695bd8deadSopenharmony_ci      should never be generated.
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ciNew Procedures and Functions
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    None
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ciNew Tokens
1765bd8deadSopenharmony_ci
1775bd8deadSopenharmony_ci    Accepted by the <cap> parameter of Enable, Disable, and IsEnabled,
1785bd8deadSopenharmony_ci    and by the <pname> parameter of GetBooleanv, GetIntegerv,
1795bd8deadSopenharmony_ci    GetFloatv, and GetDoublev:
1805bd8deadSopenharmony_ci
1815bd8deadSopenharmony_ci        DEPTH_CLAMP                                   0x864F
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.1 Specification (OpenGL Operation)
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci --  Section 2.17 "Clipping"
1865bd8deadSopenharmony_ci
1875bd8deadSopenharmony_ci    Add to the end of the 3rd paragraph:
1885bd8deadSopenharmony_ci
1895bd8deadSopenharmony_ci    "Depth clamping is enabled with the generic Enable command and
1905bd8deadSopenharmony_ci    disabled with the Disable command. The value of the argument to
1915bd8deadSopenharmony_ci    either command is DEPTH_CLAMP. If depth clamping is enabled, the
1925bd8deadSopenharmony_ci    "-w_c <= z_c <= w_c" plane equation are ignored by view volume
1935bd8deadSopenharmony_ci    clipping (effectively, there is no near or far plane clipping)."
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ci    If and only if the ARB_compatibility extension is supported:
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci --  Section 2.22 "Current Raster Position"
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci    Add to the end of the 4th paragraph:
2015bd8deadSopenharmony_ci
2025bd8deadSopenharmony_ci    "If depth clamping (see section 2.11) is enabled, then raster
2035bd8deadSopenharmony_ci    position z_w is first clamped to the range [min(n,f),max(n,f)],
2045bd8deadSopenharmony_ci    where n and f are the current near and far depth range values (see
2055bd8deadSopenharmony_ci    section 2.12.1)."
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 3.1 Specification (Rasterization)
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    None
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 3.1 Specification (Per-Fragment Operations
2125bd8deadSopenharmony_ciand the Framebuffer)
2135bd8deadSopenharmony_ci
2145bd8deadSopenharmony_ci --  Section 4.1.5 "Depth buffer test"
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ci    Add to the end of the 2nd paragraph:
2175bd8deadSopenharmony_ci
2185bd8deadSopenharmony_ci    "If depth clamping (see section 2.17) is enabled, before the
2195bd8deadSopenharmony_ci    incoming fragment's z_w is compared z_w is clamped to the range
2205bd8deadSopenharmony_ci    [min(n,f),max(n,f)], where n and f are the current near and far
2215bd8deadSopenharmony_ci    depth range values (see section 2.12.1)."
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 3.1 Specification (Special Functions)
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    None
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 3.1 Specification (State and State Requests)
2285bd8deadSopenharmony_ci
2295bd8deadSopenharmony_ci    None
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci    None
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ciGLX Protocol
2365bd8deadSopenharmony_ci
2375bd8deadSopenharmony_ci    None
2385bd8deadSopenharmony_ci
2395bd8deadSopenharmony_ciErrors
2405bd8deadSopenharmony_ci
2415bd8deadSopenharmony_ci    None
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ciNew State
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ciAdd to table 6.7, transformation state
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ciGet Value       Type  Get Command  Initial Value  Description     Sec      Attribute
2485bd8deadSopenharmony_ci--------------  ----  -----------  -------------  --------------  ------   ----------------
2495bd8deadSopenharmony_ciDEPTH_CLAMP     B     IsEnabled    False          Depth clamping  2.12.2   transform/enable
2505bd8deadSopenharmony_ci                                                  on/off
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ciNew Implementation Dependent State
2535bd8deadSopenharmony_ci
2545bd8deadSopenharmony_ci    None
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ciInteractions with ARB_compatibility
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    If ARB_compatibility is not supported, the language about current
2595bd8deadSopenharmony_ci    raster position in section 2.22 is removed.
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ciRevision History
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ci    Version 1, 2009/05/14 (Jon Leech) - rewrite NV_depth_clamp against
2645bd8deadSopenharmony_ci    OpenGL 3.1 instead of OpenGL 1.2.1. Clarify which functionality only
2655bd8deadSopenharmony_ci    applies to GL 3.1 + ARB_compatibility. Remove NV suffix and assign
2665bd8deadSopenharmony_ci    ARB extension string in preparation for inclusion in OpenGL 3.2.
2675bd8deadSopenharmony_ci
2685bd8deadSopenharmony_ci    Version 2, 2009/05/15 (Jon Leech) - Note interaction with
2695bd8deadSopenharmony_ci    ARB_compatibility.
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci    Version 3, 2009/07/01 (Jon Leech) - Match core 3.2 spec updates,
2725bd8deadSopenharmony_ci    removing w_c <= 0 language. Update corresponding issue to note this
2735bd8deadSopenharmony_ci    was done to the core spec in 2006/08.
2745bd8deadSopenharmony_ci
2755bd8deadSopenharmony_ci    Version 4, 2009/08/02 (Jon Leech) - Assign ARB extension number.
276