• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    NV_depth_clamp
4
5Name Strings
6
7    GL_NV_depth_clamp
8
9Contact
10
11    Mark J. Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com)
12
13Notice
14
15    Copyright NVIDIA Corporation, 2001.
16
17Status
18
19    Shipping
20
21Version
22
23    Last Modified Date:  2003/01/08
24    NVIDIA Revision:     1
25
26Number
27
28    260
29
30Dependencies
31
32    Written based on the wording of the OpenGL 1.2.1 specification.
33
34Overview
35
36    Conventional OpenGL clips geometric primitives to a clip volume
37    with six faces, two of which are the near and far clip planes.
38    Clipping to the near and far planes of the clip volume ensures that
39    interpolated depth values (after the depth range transform) must be
40    in the [0,1] range.
41
42    In some rendering applications such as shadow volumes, it is useful
43    to allow line and polygon primitives to be rasterized without
44    clipping the primitive to the near or far clip volume planes (side
45    clip volume planes clip normally).  Without the near and far clip
46    planes, rasterization (pixel coverage determination) in X and Y
47    can proceed normally if we ignore the near and far clip planes.
48    The one major issue is that fragments of a  primitive may extend
49    beyond the conventional window space depth range for depth values
50    (typically the range [0,1]).  Rather than discarding fragments that
51    defy the window space depth range (effectively what near and far
52    plane clipping accomplish), the depth values can be clamped to the
53    current depth range.
54
55    This extension provides exactly such functionality.  This
56    functionality is useful to obviate the need for near plane capping
57    of stenciled shadow volumes.  The functionality may also be useful
58    for rendering geometry "beyond" the far plane if an alternative
59    algorithm (rather than depth testing) for hidden surface removal is
60    applied to such geometry (specifically, the painter's algorithm).
61    Similar situations at the near clip plane can be avoided at the
62    near clip plane where apparently solid objects can be "seen through"
63    if they intersect the near clip plane.
64
65Issues
66
67    Another way to specify this functionality is to describe it in terms
68    of generating the equivalent capping geometry that would need to be
69    drawn at the near or far clip plane to have the same effect as not
70    clipping to the near and far clip planes and clamping interpolated
71    depth values outside the window-space depth range.  Should the
72    functionality be described this way?
73
74      RESOLUTION:  No.  Describing the functionality as capping is
75      fairly involved.  Eliminating far and near plane clipping and
76      clamping interpolated depth values to the depth range is much
77      simpler to specify.
78
79    Should depth clamping affect points or just line and polygon geometric
80    primitives?
81
82      RESOLUTION:  All geometric primitives are affected by depth
83      clamping.
84
85      In the case of points, if you render a point "in front of" the
86      near clip plane, it should be rendered with the zw value min(n,f)
87      where n and f are the near and far depth range values if depth
88      clamping is enabled.  Similarly, a point "behind" the far clip
89      plane should be rendered with the zw value max(n,f).
90
91    How should the setting of the raster position function when depth
92    clamping is enabled?
93
94      RESOLUTION:  When setting the raster position, clamp the raster
95      position zw to the range [min(n,f),max(n,f)] where n and f are
96      the near and far depth range values.
97
98      This rule ensures that the raster position zw will never be outside
99      the [0,1] range (because n and far are clamped to the [0,1] range).
100      We specify the raster position to be updated this way because
101      otherwise a raster position zw could be specified outside the [0,1]
102      range when depth clamping is enabled, but then if depth clamping
103      is subsequently disabled, that out-of-range raster position zw
104      could not be written to the depth buffer.
105
106      This semantic can make for some unexpected semantics that are
107      described here.  Say that depth clamping is enabled and the raster
108      position is set to point behind the far clip plane such that the
109      pre-clamped zw is 2.5.  Because depth clamping is enabled the
110      raster position zw is clamped to the current near and far depth
111      range values.  Say these values are 0.1 and 0.9.  So 2.5 is clamped
112      to 0.9.
113
114      Now consider what happens if a bitmap (or image rectangle) is
115      rendered with depth testing enabled under various situations.
116      If depth clamping remains enabled and the depth range is unchanged,
117      the bitmap fragments are generated with a zw of 0.9.
118
119      However, if depth range is subsequently set to 0.2 and 0.8 and
120      depth clamping is enabled, the bitmap fragments will have their
121      zw depth component clamped to 0.8.  But if the depth range was
122      changed to 0.2 and 0.8 but depth range clamped is disabled, the
123      bitmap fragments will have a 0.9 zw depth component since then
124      the depth clamping is then not applied.
125
126    What push/pop attrib bits should affect the depth clamp enable?
127
128      RESOLUTION:  GL_ENABLE_BIT and GL_TRANSFORM_BIT.
129
130    How does depth clamping interact with depth replace operations (say
131    from NV_texture_shader)?
132
133      RESOLUTION:  The depth clamp operation occurs as part of the depth
134      test so depth clamping occurs AFTER any depth replace operation
135      in the pipeline.  A depth replace operation can reassign the
136      fragment's zw, but depth clamping if enabled will subsequently
137      clamp this new zw.
138
139    Does depth clamping affect read/draw/copy pixels operations involving
140    depth component pixels?
141
142      RESOLUTION:  No.
143
144    Does depth clamping occur after polygon offset?
145
146      RESOLUTION:  Yes.  Depth clamping occurs immediately before the
147      depth test.
148
149    Can fragments with wc<=0 be generated when this extension is supported?
150
151      RESOLUTION:  No.  The core OpenGL specification (section 2.11) is
152      worded to allow the possibility of generating fragments where wc<=0.
153      These should never be generated when this extension is supported.
154
155New Procedures and Functions
156
157    None
158
159New Tokens
160
161    Accepted by the <cap> parameter of Enable, Disable, and IsEnabled,
162    and by the <pname> parameter of GetBooleanv, GetIntegerv,
163    GetFloatv, and GetDoublev:
164
165        DEPTH_CLAMP_NV                                0x864F
166
167Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation)
168
169 --  Section 2.11 "Clipping"
170
171    Add to the end of the 3rd paragraph:
172
173    "Depth clamping is enabled with the generic Enable command and
174    disabled with the Disable command.  The value of the argument to
175    either command is DEPTH_CLAMP_NV.  If depth clamping is enabled, the
176    "-wc <= zc <= wc" plane equation are ignored by video volume clipping
177    (effectively, there is no near or far plane clipping)."
178
179    Change the 8th paragraph to indicate that only wc>0 fragments should
180    be generated rather than even allowing the posibility that wc<=0
181    fragments may be generated:
182
183    "A line segment or polygon whose vertices have wc values of differing
184    signs may generate multiple connected components after clipping.
185    GL implementations are not required to handle this situation.
186    That is, only the portion of the primitive that lies in the region
187    of wc>0 should be produced by clipping."
188
189 --  Section 2.12 "Current Raster Position"
190
191    Add to the end of the 4th paragraph:
192
193    "If depth clamping (see section 2.11) is enabled, then raster position
194    zw is first clamped as follows.  If the raster postition's wc>0,
195    then zw is clamped the range [min(n,f),max(n,f)] where n and f are
196    the current near and far depth range values (see section 2.10.1)."
197
198Additions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization)
199
200    None
201
202Additions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment Operations
203and the Framebuffer)
204
205 --  Section 4.1.5 "Depth buffer test"
206
207    Add to the end of the 2nd paragraph:
208
209    "If depth clamping (see section 2.11) is enabled, before the incoming
210    fragment's zw is compared, zw must first be clamped as follows: If the
211    fragment's wc>0, then zw is clamped to the range [min(n,f),max(n,f)]
212    where n and f are the current near and far depth range values (see
213    section 2.10.1)."
214
215Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
216
217    None
218
219Additions to Chapter 6 of the OpenGL 1.2.1 Specification (State and State Requests)
220
221    None
222
223Additions to the AGL/GLX/WGL Specifications
224
225    None
226
227GLX Protocol
228
229    None
230
231Errors
232
233    None
234
235New State
236
237(table 6.7)
238Get Value       Type  Get Command  Initial Value  Description     Sec      Attribute
239--------------  ----  -----------  -------------  --------------  ------   ----------------
240DEPTH_CLAMP_NV  B     IsEnabled    False          Depth clamping  2.10.2   transform/enable
241                                                  on/off
242
243New Implementation Dependent State
244
245    None
246
247Revision History
248
249    None
250