15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    NV_depth_clamp
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_NV_depth_clamp
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Mark J. Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciNotice
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Copyright NVIDIA Corporation, 2001.
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ciStatus
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    Shipping
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciVersion
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    Last Modified Date:  2003/01/08
245bd8deadSopenharmony_ci    NVIDIA Revision:     1
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ciNumber
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ci    260
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ciDependencies
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ci    Written based on the wording of the OpenGL 1.2.1 specification.
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ciOverview
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    Conventional OpenGL clips geometric primitives to a clip volume
375bd8deadSopenharmony_ci    with six faces, two of which are the near and far clip planes.
385bd8deadSopenharmony_ci    Clipping to the near and far planes of the clip volume ensures that
395bd8deadSopenharmony_ci    interpolated depth values (after the depth range transform) must be
405bd8deadSopenharmony_ci    in the [0,1] range.
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    In some rendering applications such as shadow volumes, it is useful
435bd8deadSopenharmony_ci    to allow line and polygon primitives to be rasterized without
445bd8deadSopenharmony_ci    clipping the primitive to the near or far clip volume planes (side
455bd8deadSopenharmony_ci    clip volume planes clip normally).  Without the near and far clip
465bd8deadSopenharmony_ci    planes, rasterization (pixel coverage determination) in X and Y
475bd8deadSopenharmony_ci    can proceed normally if we ignore the near and far clip planes.
485bd8deadSopenharmony_ci    The one major issue is that fragments of a  primitive may extend
495bd8deadSopenharmony_ci    beyond the conventional window space depth range for depth values
505bd8deadSopenharmony_ci    (typically the range [0,1]).  Rather than discarding fragments that
515bd8deadSopenharmony_ci    defy the window space depth range (effectively what near and far
525bd8deadSopenharmony_ci    plane clipping accomplish), the depth values can be clamped to the
535bd8deadSopenharmony_ci    current depth range.
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    This extension provides exactly such functionality.  This
565bd8deadSopenharmony_ci    functionality is useful to obviate the need for near plane capping
575bd8deadSopenharmony_ci    of stenciled shadow volumes.  The functionality may also be useful
585bd8deadSopenharmony_ci    for rendering geometry "beyond" the far plane if an alternative
595bd8deadSopenharmony_ci    algorithm (rather than depth testing) for hidden surface removal is
605bd8deadSopenharmony_ci    applied to such geometry (specifically, the painter's algorithm).
615bd8deadSopenharmony_ci    Similar situations at the near clip plane can be avoided at the
625bd8deadSopenharmony_ci    near clip plane where apparently solid objects can be "seen through"
635bd8deadSopenharmony_ci    if they intersect the near clip plane.
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ciIssues
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    Another way to specify this functionality is to describe it in terms
685bd8deadSopenharmony_ci    of generating the equivalent capping geometry that would need to be
695bd8deadSopenharmony_ci    drawn at the near or far clip plane to have the same effect as not
705bd8deadSopenharmony_ci    clipping to the near and far clip planes and clamping interpolated
715bd8deadSopenharmony_ci    depth values outside the window-space depth range.  Should the
725bd8deadSopenharmony_ci    functionality be described this way?
735bd8deadSopenharmony_ci
745bd8deadSopenharmony_ci      RESOLUTION:  No.  Describing the functionality as capping is
755bd8deadSopenharmony_ci      fairly involved.  Eliminating far and near plane clipping and
765bd8deadSopenharmony_ci      clamping interpolated depth values to the depth range is much
775bd8deadSopenharmony_ci      simpler to specify.
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci    Should depth clamping affect points or just line and polygon geometric
805bd8deadSopenharmony_ci    primitives?
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ci      RESOLUTION:  All geometric primitives are affected by depth
835bd8deadSopenharmony_ci      clamping.
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci      In the case of points, if you render a point "in front of" the
865bd8deadSopenharmony_ci      near clip plane, it should be rendered with the zw value min(n,f)
875bd8deadSopenharmony_ci      where n and f are the near and far depth range values if depth
885bd8deadSopenharmony_ci      clamping is enabled.  Similarly, a point "behind" the far clip
895bd8deadSopenharmony_ci      plane should be rendered with the zw value max(n,f).
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    How should the setting of the raster position function when depth
925bd8deadSopenharmony_ci    clamping is enabled?
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ci      RESOLUTION:  When setting the raster position, clamp the raster
955bd8deadSopenharmony_ci      position zw to the range [min(n,f),max(n,f)] where n and f are
965bd8deadSopenharmony_ci      the near and far depth range values.
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci      This rule ensures that the raster position zw will never be outside
995bd8deadSopenharmony_ci      the [0,1] range (because n and far are clamped to the [0,1] range).
1005bd8deadSopenharmony_ci      We specify the raster position to be updated this way because
1015bd8deadSopenharmony_ci      otherwise a raster position zw could be specified outside the [0,1]
1025bd8deadSopenharmony_ci      range when depth clamping is enabled, but then if depth clamping
1035bd8deadSopenharmony_ci      is subsequently disabled, that out-of-range raster position zw
1045bd8deadSopenharmony_ci      could not be written to the depth buffer.
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ci      This semantic can make for some unexpected semantics that are
1075bd8deadSopenharmony_ci      described here.  Say that depth clamping is enabled and the raster
1085bd8deadSopenharmony_ci      position is set to point behind the far clip plane such that the
1095bd8deadSopenharmony_ci      pre-clamped zw is 2.5.  Because depth clamping is enabled the
1105bd8deadSopenharmony_ci      raster position zw is clamped to the current near and far depth
1115bd8deadSopenharmony_ci      range values.  Say these values are 0.1 and 0.9.  So 2.5 is clamped
1125bd8deadSopenharmony_ci      to 0.9.
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ci      Now consider what happens if a bitmap (or image rectangle) is
1155bd8deadSopenharmony_ci      rendered with depth testing enabled under various situations.
1165bd8deadSopenharmony_ci      If depth clamping remains enabled and the depth range is unchanged,
1175bd8deadSopenharmony_ci      the bitmap fragments are generated with a zw of 0.9.
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci      However, if depth range is subsequently set to 0.2 and 0.8 and
1205bd8deadSopenharmony_ci      depth clamping is enabled, the bitmap fragments will have their
1215bd8deadSopenharmony_ci      zw depth component clamped to 0.8.  But if the depth range was
1225bd8deadSopenharmony_ci      changed to 0.2 and 0.8 but depth range clamped is disabled, the
1235bd8deadSopenharmony_ci      bitmap fragments will have a 0.9 zw depth component since then
1245bd8deadSopenharmony_ci      the depth clamping is then not applied.
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    What push/pop attrib bits should affect the depth clamp enable?
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci      RESOLUTION:  GL_ENABLE_BIT and GL_TRANSFORM_BIT.
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci    How does depth clamping interact with depth replace operations (say
1315bd8deadSopenharmony_ci    from NV_texture_shader)?
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ci      RESOLUTION:  The depth clamp operation occurs as part of the depth
1345bd8deadSopenharmony_ci      test so depth clamping occurs AFTER any depth replace operation
1355bd8deadSopenharmony_ci      in the pipeline.  A depth replace operation can reassign the
1365bd8deadSopenharmony_ci      fragment's zw, but depth clamping if enabled will subsequently
1375bd8deadSopenharmony_ci      clamp this new zw.
1385bd8deadSopenharmony_ci
1395bd8deadSopenharmony_ci    Does depth clamping affect read/draw/copy pixels operations involving
1405bd8deadSopenharmony_ci    depth component pixels?
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci      RESOLUTION:  No.
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    Does depth clamping occur after polygon offset?
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci      RESOLUTION:  Yes.  Depth clamping occurs immediately before the
1475bd8deadSopenharmony_ci      depth test.
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    Can fragments with wc<=0 be generated when this extension is supported?
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci      RESOLUTION:  No.  The core OpenGL specification (section 2.11) is
1525bd8deadSopenharmony_ci      worded to allow the possibility of generating fragments where wc<=0.
1535bd8deadSopenharmony_ci      These should never be generated when this extension is supported.
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ciNew Procedures and Functions
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    None
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ciNew Tokens
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci    Accepted by the <cap> parameter of Enable, Disable, and IsEnabled,
1625bd8deadSopenharmony_ci    and by the <pname> parameter of GetBooleanv, GetIntegerv,
1635bd8deadSopenharmony_ci    GetFloatv, and GetDoublev:
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci        DEPTH_CLAMP_NV                                0x864F
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation)
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci --  Section 2.11 "Clipping"
1705bd8deadSopenharmony_ci 
1715bd8deadSopenharmony_ci    Add to the end of the 3rd paragraph:
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    "Depth clamping is enabled with the generic Enable command and
1745bd8deadSopenharmony_ci    disabled with the Disable command.  The value of the argument to
1755bd8deadSopenharmony_ci    either command is DEPTH_CLAMP_NV.  If depth clamping is enabled, the
1765bd8deadSopenharmony_ci    "-wc <= zc <= wc" plane equation are ignored by video volume clipping
1775bd8deadSopenharmony_ci    (effectively, there is no near or far plane clipping)."
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    Change the 8th paragraph to indicate that only wc>0 fragments should
1805bd8deadSopenharmony_ci    be generated rather than even allowing the posibility that wc<=0
1815bd8deadSopenharmony_ci    fragments may be generated:
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ci    "A line segment or polygon whose vertices have wc values of differing
1845bd8deadSopenharmony_ci    signs may generate multiple connected components after clipping.
1855bd8deadSopenharmony_ci    GL implementations are not required to handle this situation.
1865bd8deadSopenharmony_ci    That is, only the portion of the primitive that lies in the region
1875bd8deadSopenharmony_ci    of wc>0 should be produced by clipping."
1885bd8deadSopenharmony_ci
1895bd8deadSopenharmony_ci --  Section 2.12 "Current Raster Position"
1905bd8deadSopenharmony_ci 
1915bd8deadSopenharmony_ci    Add to the end of the 4th paragraph:
1925bd8deadSopenharmony_ci
1935bd8deadSopenharmony_ci    "If depth clamping (see section 2.11) is enabled, then raster position
1945bd8deadSopenharmony_ci    zw is first clamped as follows.  If the raster postition's wc>0,
1955bd8deadSopenharmony_ci    then zw is clamped the range [min(n,f),max(n,f)] where n and f are
1965bd8deadSopenharmony_ci    the current near and far depth range values (see section 2.10.1)."
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization)
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci    None
2015bd8deadSopenharmony_ci
2025bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment Operations
2035bd8deadSopenharmony_ciand the Framebuffer)
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci --  Section 4.1.5 "Depth buffer test"
2065bd8deadSopenharmony_ci 
2075bd8deadSopenharmony_ci    Add to the end of the 2nd paragraph:
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    "If depth clamping (see section 2.11) is enabled, before the incoming
2105bd8deadSopenharmony_ci    fragment's zw is compared, zw must first be clamped as follows: If the
2115bd8deadSopenharmony_ci    fragment's wc>0, then zw is clamped to the range [min(n,f),max(n,f)]
2125bd8deadSopenharmony_ci    where n and f are the current near and far depth range values (see
2135bd8deadSopenharmony_ci    section 2.10.1)."
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
2165bd8deadSopenharmony_ci
2175bd8deadSopenharmony_ci    None
2185bd8deadSopenharmony_ci
2195bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.2.1 Specification (State and State Requests)
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci    None
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    None
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ciGLX Protocol
2285bd8deadSopenharmony_ci
2295bd8deadSopenharmony_ci    None
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ciErrors
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci    None
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ciNew State
2365bd8deadSopenharmony_ci
2375bd8deadSopenharmony_ci(table 6.7)
2385bd8deadSopenharmony_ciGet Value       Type  Get Command  Initial Value  Description     Sec      Attribute
2395bd8deadSopenharmony_ci--------------  ----  -----------  -------------  --------------  ------   ----------------
2405bd8deadSopenharmony_ciDEPTH_CLAMP_NV  B     IsEnabled    False          Depth clamping  2.10.2   transform/enable
2415bd8deadSopenharmony_ci                                                  on/off
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ciNew Implementation Dependent State
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci    None
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ciRevision History
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci    None
250