• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ARB_polygon_offset_clamp
4
5Name Strings
6
7    GL_ARB_polygon_offset_clamp
8
9Contact
10
11    Piers Daniell (pdaniell 'at' nvidia.com)
12
13Contributors
14
15    Eric Lengyel, Terathon Software
16    Tobias Hector, Imagination Technologies
17
18Notice
19
20    Copyright (c) 2017 The Khronos Group Inc. Copyright terms at
21        http://www.khronos.org/registry/speccopyright.html
22
23Specification Update Policy
24
25    Khronos-approved extension specifications are updated in response to
26    issues and bugs prioritized by the Khronos OpenGL Working Group. For
27    extensions which have been promoted to a core Specification, fixes will
28    first appear in the latest version of that core Specification, and will
29    eventually be backported to the extension document. This policy is
30    described in more detail at
31        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
32
33Status
34
35    Draft
36
37Version
38
39    Last Modified Date: April 3, 2017
40    Revision: 1
41
42Number
43
44    ARB Extension #193
45
46Dependencies
47
48    OpenGL 3.3 (either core or compatibility profiles).
49
50    This extension is written against the OpenGL 4.5 (Compatibility Profile)
51    Specification (October 24, 2016).
52
53Overview
54
55    This extension adds a new parameter to the polygon offset function
56    that clamps the calculated offset to a minimum or maximum value.
57    The clamping functionality is useful when polygons are nearly
58    parallel to the view direction because their high slopes can result
59    in arbitrarily large polygon offsets. In the particular case of
60    shadow mapping, the lack of clamping can produce the appearance of
61    unwanted holes when the shadow casting polygons are offset beyond
62    the shadow receiving polygons, and this problem can be alleviated by
63    enforcing a maximum offset value.
64
65IP Status
66
67    No known IP claims.
68
69New Procedures and Functions
70
71    void PolygonOffsetClamp(float factor, float units, float clamp);
72
73New Tokens
74
75    Accepted by the <pname> parameters of GetBooleanv, GetIntegerv,
76    GetInteger64v, GetFloatv, and GetDoublev:
77
78        POLYGON_OFFSET_CLAMP                    0x8E1B
79
80Additions to Chapter 14 of the OpenGL 4.5 (Compatibility Profile) Specification
81(Fixed-Function Primitive Assembly and Rasterization)
82
83 -- Modify Open GL section 14.6.5 "Depth Offset"
84
85    Replace the 1st paragraph...
86
87    "The depth values of all fragments generated by the rasterization of
88    a polygon may be offset by a single value that is computed for that
89    polygon. The function that determines this value is specified with
90    the commands
91
92     void PolygonOffsetClamp(float factor, float units, float clamp);
93     void PolygonOffset(float factor, float units);
94
95    <factor> scales the maximum depth slope of the polygon, and <units>
96    scales an implementation-dependent constant that relates to the
97    usable resolution of the depth buffer. The resulting values are
98    summed to produce the polygon offset value, which may then be
99    clamped to a minimum or maximum value specified by <clamp>. The
100    values <factor>, <units>, and <clamp> may each be positive,
101    negative, or zero. Calling the command PolygonOffset is equivalent
102    to calling the command PolygonOffsetClamp with <clamp> equal to
103    zero."
104
105    Replace the 6th paragraph...
106
107    "The offset value o for a polygon is
108          _
109         |   m x <factor> + r x <units>,          if <clamp> = 0 or NaN;
110         |
111    o = <    min(m x <factor> + r x <units>, <clamp>),   if <clamp> > 0;
112         |
113         |_  max(m x <factor> + r x <units>, <clamp>),   if <clamp> < 0.
114
115    m is computed as described above. If the depth buffer uses a fixed-
116    point representation, m is a function of depth values in the range
117    [0, 1], and o is applied to depth values in the same range."
118
119Additions to the AGL/EGL/GLX/WGL Specifications
120
121    None
122
123GLX Protocol
124
125    A new GL rendering command is added. The following command is sent
126    to the server as part of a glXRender request:
127
128        PolygonOffsetClamp
129            2           16              rendering command length
130            2           4225            rendering command opcode
131            4           FLOAT32         factor
132            4           FLOAT32         units
133            4           FLOAT32         clamp
134
135Errors
136
137    None
138
139New State (OpenGL)
140
141    Get Value                Type  Get Command  Initial Value  Description           Sec     Attrib
142    ------------------------ ----  -----------  -------------  --------------------  -----   -------
143    POLYGON_OFFSET_CLAMP      R    GetFloatv          0        Polygon offset clamp  14.6.5  polygon
144
145New Implementation Dependent State
146
147    None
148
149Issues
150
151    1)  Should the PolygonOffsetClamp command specify only the <clamp>
152        parameter, or should it specify all three of the parameters
153        <factor>, <units>, and <clamp>?
154
155        Defining a new command that specifies new state in addition to
156        state that can be specified with an existing command has a
157        precedent in the BlendFuncSeparate command. The argument can be
158        made that an application would usually want to set the <factor>
159        and <units> values at the same time it sets the <clamp> value,
160        and making one GL call is better than making two GL calls.
161        Furthermore, requiring that a call to PolygonOffset sets
162        POLYGON_OFFSET_CLAMP to zero insulates applications unaware
163        of the new state from failures to restore it to its initial
164        value in separate libraries, and this cannot be done if an
165        orthogonal command specifying only the <clamp> value were to be
166        defined.
167
168        RESOLVED: This extension defines a new command that specifies
169        the <factor>, <units>, and <clamp> parameters.
170
171    2)  What happens if <clamp> is infinity or NaN?
172
173        As per Section 2.1, the result of providing an infinity or NaN
174        is unspecified. However, if <clamp> is positive or negative
175        infinity, then Equation (3.13), in the literal mathematical
176        sense, is effectively reduced to the case in which no clamping
177        occurs, and this should be the defined behavior.
178
179        If <clamp> is a floating-point NaN, then we could leave the
180        result undefined, but that could lead to application code
181        working correctly with one implementation and then inexplicably
182        failing with another. It would be better to define the behavior
183        such that no clamping occurs. If this is not the behavior
184        exhibited by the hardware, then the implementation can turn all
185        infinites and NaNs into zero using the following code:
186
187            int32_t clampBits = *(int32_t *) &clamp;
188            clampBits &= (((clampBits >> 23) & 0xFF) - 0xFF) >> 31;
189
190        This ANDs with all one bits if and only if the floating-point
191        exponent is less than 255. Otherwise, it ANDs with all zero
192        bits. (This assumes a well-defined right shift of negative
193        integers.)
194
195        RESOLVED: If <clamp> is infinity or NaN, then no clamping is
196        applied to the polygon offset.
197
198    3)  What happens if <clamp> is a denormalized floating-point value?
199
200        As per Section 2.1, the result of providing a denormalized value
201        must yield predictable results. However, some implementations
202        may treat denormalized values as equal to zero, and other
203        implementations may treat them as greater than or less than
204        zero. To ensure uniform behavior across all implementations, we
205        can require that denormalized values not be equal to zero. This
206        may necessitate that implementations convert denormalized values
207        to the smallest representable normalized value with the same
208        sign.
209
210        RESOLVED: Denormalized values are not considered equal to zero
211        in Equation (3.13).
212
213Revision History
214
215    Rev.    Date      Author     Changes
216    ----  ---------- ---------  -----------------------------------------------
217    1     2017-04-03 pdaniell   Initial draft for OpenGL 4.6 forked from
218                                GL_EXT_polygon_offset_clamp rev. 4
219