15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_polygon_offset_clamp 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_polygon_offset_clamp 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Piers Daniell (pdaniell 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Eric Lengyel, Terathon Software 165bd8deadSopenharmony_ci Tobias Hector, Imagination Technologies 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciNotice 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Copyright (c) 2017 The Khronos Group Inc. Copyright terms at 215bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciSpecification Update Policy 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 265bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 275bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 285bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 295bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 305bd8deadSopenharmony_ci described in more detail at 315bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciStatus 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci Draft 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ciVersion 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci Last Modified Date: April 3, 2017 405bd8deadSopenharmony_ci Revision: 1 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ciNumber 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci ARB Extension #193 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ciDependencies 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci OpenGL 3.3 (either core or compatibility profiles). 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci This extension is written against the OpenGL 4.5 (Compatibility Profile) 515bd8deadSopenharmony_ci Specification (October 24, 2016). 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ciOverview 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci This extension adds a new parameter to the polygon offset function 565bd8deadSopenharmony_ci that clamps the calculated offset to a minimum or maximum value. 575bd8deadSopenharmony_ci The clamping functionality is useful when polygons are nearly 585bd8deadSopenharmony_ci parallel to the view direction because their high slopes can result 595bd8deadSopenharmony_ci in arbitrarily large polygon offsets. In the particular case of 605bd8deadSopenharmony_ci shadow mapping, the lack of clamping can produce the appearance of 615bd8deadSopenharmony_ci unwanted holes when the shadow casting polygons are offset beyond 625bd8deadSopenharmony_ci the shadow receiving polygons, and this problem can be alleviated by 635bd8deadSopenharmony_ci enforcing a maximum offset value. 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ciIP Status 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci No known IP claims. 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ciNew Procedures and Functions 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci void PolygonOffsetClamp(float factor, float units, float clamp); 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ciNew Tokens 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci Accepted by the <pname> parameters of GetBooleanv, GetIntegerv, 765bd8deadSopenharmony_ci GetInteger64v, GetFloatv, and GetDoublev: 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci POLYGON_OFFSET_CLAMP 0x8E1B 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciAdditions to Chapter 14 of the OpenGL 4.5 (Compatibility Profile) Specification 815bd8deadSopenharmony_ci(Fixed-Function Primitive Assembly and Rasterization) 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci -- Modify Open GL section 14.6.5 "Depth Offset" 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci Replace the 1st paragraph... 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci "The depth values of all fragments generated by the rasterization of 885bd8deadSopenharmony_ci a polygon may be offset by a single value that is computed for that 895bd8deadSopenharmony_ci polygon. The function that determines this value is specified with 905bd8deadSopenharmony_ci the commands 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci void PolygonOffsetClamp(float factor, float units, float clamp); 935bd8deadSopenharmony_ci void PolygonOffset(float factor, float units); 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci <factor> scales the maximum depth slope of the polygon, and <units> 965bd8deadSopenharmony_ci scales an implementation-dependent constant that relates to the 975bd8deadSopenharmony_ci usable resolution of the depth buffer. The resulting values are 985bd8deadSopenharmony_ci summed to produce the polygon offset value, which may then be 995bd8deadSopenharmony_ci clamped to a minimum or maximum value specified by <clamp>. The 1005bd8deadSopenharmony_ci values <factor>, <units>, and <clamp> may each be positive, 1015bd8deadSopenharmony_ci negative, or zero. Calling the command PolygonOffset is equivalent 1025bd8deadSopenharmony_ci to calling the command PolygonOffsetClamp with <clamp> equal to 1035bd8deadSopenharmony_ci zero." 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci Replace the 6th paragraph... 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ci "The offset value o for a polygon is 1085bd8deadSopenharmony_ci _ 1095bd8deadSopenharmony_ci | m x <factor> + r x <units>, if <clamp> = 0 or NaN; 1105bd8deadSopenharmony_ci | 1115bd8deadSopenharmony_ci o = < min(m x <factor> + r x <units>, <clamp>), if <clamp> > 0; 1125bd8deadSopenharmony_ci | 1135bd8deadSopenharmony_ci |_ max(m x <factor> + r x <units>, <clamp>), if <clamp> < 0. 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ci m is computed as described above. If the depth buffer uses a fixed- 1165bd8deadSopenharmony_ci point representation, m is a function of depth values in the range 1175bd8deadSopenharmony_ci [0, 1], and o is applied to depth values in the same range." 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ciAdditions to the AGL/EGL/GLX/WGL Specifications 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci None 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ciGLX Protocol 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci A new GL rendering command is added. The following command is sent 1265bd8deadSopenharmony_ci to the server as part of a glXRender request: 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci PolygonOffsetClamp 1295bd8deadSopenharmony_ci 2 16 rendering command length 1305bd8deadSopenharmony_ci 2 4225 rendering command opcode 1315bd8deadSopenharmony_ci 4 FLOAT32 factor 1325bd8deadSopenharmony_ci 4 FLOAT32 units 1335bd8deadSopenharmony_ci 4 FLOAT32 clamp 1345bd8deadSopenharmony_ci 1355bd8deadSopenharmony_ciErrors 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci None 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ciNew State (OpenGL) 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ci Get Value Type Get Command Initial Value Description Sec Attrib 1425bd8deadSopenharmony_ci ------------------------ ---- ----------- ------------- -------------------- ----- ------- 1435bd8deadSopenharmony_ci POLYGON_OFFSET_CLAMP R GetFloatv 0 Polygon offset clamp 14.6.5 polygon 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ciNew Implementation Dependent State 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ci None 1485bd8deadSopenharmony_ci 1495bd8deadSopenharmony_ciIssues 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci 1) Should the PolygonOffsetClamp command specify only the <clamp> 1525bd8deadSopenharmony_ci parameter, or should it specify all three of the parameters 1535bd8deadSopenharmony_ci <factor>, <units>, and <clamp>? 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci Defining a new command that specifies new state in addition to 1565bd8deadSopenharmony_ci state that can be specified with an existing command has a 1575bd8deadSopenharmony_ci precedent in the BlendFuncSeparate command. The argument can be 1585bd8deadSopenharmony_ci made that an application would usually want to set the <factor> 1595bd8deadSopenharmony_ci and <units> values at the same time it sets the <clamp> value, 1605bd8deadSopenharmony_ci and making one GL call is better than making two GL calls. 1615bd8deadSopenharmony_ci Furthermore, requiring that a call to PolygonOffset sets 1625bd8deadSopenharmony_ci POLYGON_OFFSET_CLAMP to zero insulates applications unaware 1635bd8deadSopenharmony_ci of the new state from failures to restore it to its initial 1645bd8deadSopenharmony_ci value in separate libraries, and this cannot be done if an 1655bd8deadSopenharmony_ci orthogonal command specifying only the <clamp> value were to be 1665bd8deadSopenharmony_ci defined. 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci RESOLVED: This extension defines a new command that specifies 1695bd8deadSopenharmony_ci the <factor>, <units>, and <clamp> parameters. 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci 2) What happens if <clamp> is infinity or NaN? 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci As per Section 2.1, the result of providing an infinity or NaN 1745bd8deadSopenharmony_ci is unspecified. However, if <clamp> is positive or negative 1755bd8deadSopenharmony_ci infinity, then Equation (3.13), in the literal mathematical 1765bd8deadSopenharmony_ci sense, is effectively reduced to the case in which no clamping 1775bd8deadSopenharmony_ci occurs, and this should be the defined behavior. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci If <clamp> is a floating-point NaN, then we could leave the 1805bd8deadSopenharmony_ci result undefined, but that could lead to application code 1815bd8deadSopenharmony_ci working correctly with one implementation and then inexplicably 1825bd8deadSopenharmony_ci failing with another. It would be better to define the behavior 1835bd8deadSopenharmony_ci such that no clamping occurs. If this is not the behavior 1845bd8deadSopenharmony_ci exhibited by the hardware, then the implementation can turn all 1855bd8deadSopenharmony_ci infinites and NaNs into zero using the following code: 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci int32_t clampBits = *(int32_t *) &clamp; 1885bd8deadSopenharmony_ci clampBits &= (((clampBits >> 23) & 0xFF) - 0xFF) >> 31; 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci This ANDs with all one bits if and only if the floating-point 1915bd8deadSopenharmony_ci exponent is less than 255. Otherwise, it ANDs with all zero 1925bd8deadSopenharmony_ci bits. (This assumes a well-defined right shift of negative 1935bd8deadSopenharmony_ci integers.) 1945bd8deadSopenharmony_ci 1955bd8deadSopenharmony_ci RESOLVED: If <clamp> is infinity or NaN, then no clamping is 1965bd8deadSopenharmony_ci applied to the polygon offset. 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci 3) What happens if <clamp> is a denormalized floating-point value? 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci As per Section 2.1, the result of providing a denormalized value 2015bd8deadSopenharmony_ci must yield predictable results. However, some implementations 2025bd8deadSopenharmony_ci may treat denormalized values as equal to zero, and other 2035bd8deadSopenharmony_ci implementations may treat them as greater than or less than 2045bd8deadSopenharmony_ci zero. To ensure uniform behavior across all implementations, we 2055bd8deadSopenharmony_ci can require that denormalized values not be equal to zero. This 2065bd8deadSopenharmony_ci may necessitate that implementations convert denormalized values 2075bd8deadSopenharmony_ci to the smallest representable normalized value with the same 2085bd8deadSopenharmony_ci sign. 2095bd8deadSopenharmony_ci 2105bd8deadSopenharmony_ci RESOLVED: Denormalized values are not considered equal to zero 2115bd8deadSopenharmony_ci in Equation (3.13). 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ciRevision History 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci Rev. Date Author Changes 2165bd8deadSopenharmony_ci ---- ---------- --------- ----------------------------------------------- 2175bd8deadSopenharmony_ci 1 2017-04-03 pdaniell Initial draft for OpenGL 4.6 forked from 2185bd8deadSopenharmony_ci GL_EXT_polygon_offset_clamp rev. 4 219