15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_shadow_ambient
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_shadow_ambient
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Brian Paul (brian_e_paul 'at' yahoo.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciNotice
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Copyright (c) 2002-2013 The Khronos Group Inc. Copyright terms at
165bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciSpecification Update Policy
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
215bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
225bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
235bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
245bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
255bd8deadSopenharmony_ci    described in more detail at
265bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ciStatus
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ci    Complete. Approved by ARB on February 14, 2002.
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ciVersion
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ci    Last Modified Date: 12 December 2001
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ciNumber
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    ARB Extension #24
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ciDependencies
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    OpenGL 1.1 is required.
435bd8deadSopenharmony_ci    ARB_shadow is required.
445bd8deadSopenharmony_ci    ARB_depth_texture is required.
455bd8deadSopenharmony_ci    This extension is written against the OpenGL 1.3 Specification.
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ciOverview
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ci    This is based on the GL_SGIX_shadow_ambient extension and is layered
505bd8deadSopenharmony_ci    upon the GL_ARB_shadow extension.
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    Basically, this extension allows the user to specify the texture
535bd8deadSopenharmony_ci    value to use when the texture compare function fails.  Normally
545bd8deadSopenharmony_ci    this value is zero.  By allowing an arbitrary value we can get
555bd8deadSopenharmony_ci    functionality which otherwise requires an advanced texture
565bd8deadSopenharmony_ci    combine extension (such as GL_NV_register_combiners) and multiple
575bd8deadSopenharmony_ci    texture units.
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ciIP Status
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    None.
625bd8deadSopenharmony_ci
635bd8deadSopenharmony_ciIssues
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ci    (1) How is this extension different from GL_SGIX_shadow_ambient?
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci      It's functionally identical.  Since the original spec isn't in
685bd8deadSopenharmony_ci      the extension registry this one was written from scratch.
695bd8deadSopenharmony_ci
705bd8deadSopenharmony_ci    (2) Is this extension really needed?
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci      RESOLUTION: Yes, if an advanced texture combine extension is not
735bd8deadSopenharmony_ci      available.  From Mark Kilgard's GDC presentation on shadow mapping:
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci      The desired color for a lit, textured, shadow fragment is:
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci      ( ambient + diffuseShade * diffuse) * decal + specular * shade
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci      where diffuseShade = dimming + ( 1.0 - dimming ) * shade, and
805bd8deadSopenharmony_ci      shade is the result of the shadow test in [0,1].  dimming
815bd8deadSopenharmony_ci      expresses the scattered light in a scene.
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci      If we limit shade to the range [<dimming>, 1] (where <dimming> is
845bd8deadSopenharmony_ci      TEXTURE_FAIL_VALUE_ARB) then we can express the diffuse term with
855bd8deadSopenharmony_ci      the standard GL_MODULATE texture env mode.
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci      Furthermore, this extension allows implementing shadow arithmetic
885bd8deadSopenharmony_ci      with a single texture stage.  Otherwise, two texture stages are
895bd8deadSopenharmony_ci      needed in order to compute diffuseShade * diffuse * decal.
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci      This extension is also useful for implementing shadowed lighting
925bd8deadSopenharmony_ci      expressions other than the one above.  In particular, a "poor-man's"
935bd8deadSopenharmony_ci      shadow mode can be implemented by setting TEXTURE_FAIL_VALUE_ARB to
945bd8deadSopenharmony_ci      the scene's ambient intensity and the texture environment mode to
955bd8deadSopenharmony_ci      GL_MODULATE.  This is the intention of the original
965bd8deadSopenharmony_ci      GL_SGIX_shadow_ambient extension.
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci    (3) What are the downsides of this extension?
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci      This extension places some arithmetic in the texture sampling logic
1015bd8deadSopenharmony_ci      which would otherwise be better implemented in the texture combine
1025bd8deadSopenharmony_ci      logic.
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci      Also, there probably aren't many (if any) other uses for this logic
1055bd8deadSopenharmony_ci      other than shadow ambient term.
1065bd8deadSopenharmony_ci
1075bd8deadSopenharmony_ci      Those who already implement advanced texture combine modes probably
1085bd8deadSopenharmony_ci      won't want to implement this extension.
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci    (4) What should the "shadow ambient" variable be named:
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci      RESOLUTION: TEXTURE_COMPARE_FAIL_VALUE_ARB since this extension
1135bd8deadSopenharmony_ci      specifies the value used when the texture comparison function fails.
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci    (5) Is GL_ARB_shadow_ambient a good name for this extension?
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci      RESOLUTION:  Probably.  Even though this extension is phrased in
1185bd8deadSopenharmony_ci      general terms, it's going to be used almost exclusively for shadow
1195bd8deadSopenharmony_ci      mapping applications.
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci    (6) Should TEXTURE_COMPARE_FAIL_VALUE_ARB be an alias for
1225bd8deadSopenharmony_ci      GL_SHADOW_AMBIENT_SGIX (from GL_SGIX_shadow_ambient)?
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci      RESOLUTION: Yes.  It serves the same purpose and avoids adding
1255bd8deadSopenharmony_ci      yet more state to texture objects.
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ciNew Procedures and Functions
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci    None
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ciNew Tokens
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ci    Accepted by the <pname> parameter of TexParameterf, TexParameteri,
1345bd8deadSopenharmony_ci    TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv:
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    TEXTURE_COMPARE_FAIL_VALUE_ARB  0x80BF  (same as SHADOW_AMBIENT_SGIX)
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ciAdditions to Chapter 2 of the 1.3 Specification (OpenGL Operation)
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci    None
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ciAdditions to Chapter 3 of the 1.3 Specification (Rasterization)
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    Section 3.8.4, Texture Parameters, p. 133, append table 3.19 with the
1455bd8deadSopenharmony_ci    following:
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci        Name                            Type   Legal Values
1485bd8deadSopenharmony_ci        ------------------------------  -----  --------------------
1495bd8deadSopenharmony_ci        TEXTURE_COMPARE_FAIL_VALUE_ARB  float   any value in [0, 1]
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci    Section 3.8.4, Texture Parameters, append last paragraph with:
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci        "The value set by TEXTURE_COMPARE_FAIL_VALUE_ARB is clamped to
1545bd8deadSopenharmony_ci        lie in [0, 1]."
1555bd8deadSopenharmony_ci
1565bd8deadSopenharmony_ci    Modify section 3.8.13.1, defined in the GL_ARB_shadow specification,
1575bd8deadSopenharmony_ci    as follows:
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci        "3.8.13.1 Depth Texture Comparison Mode
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci        [...]
1625bd8deadSopenharmony_ci        else if TEXTURE_COMPARE_MODE_ARB = COMPARE_R_TO_TEXTURE_ARB
1635bd8deadSopenharmony_ci
1645bd8deadSopenharmony_ci            if TEXTURE_COMPARE_FUNC_ARB = LEQUAL
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ci                     { 1.0,                             if R <= Dt
1675bd8deadSopenharmony_ci                 r = {
1685bd8deadSopenharmony_ci                     { TEXTURE_COMPARE_FAIL_VALUE_ARB,  if R > Dt
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci            else, if TEXTURE_COMPARE_FUNC_ARB = GEQUAL
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci                     { 1.0,                             if R >= Dt
1735bd8deadSopenharmony_ci                 r = {
1745bd8deadSopenharmony_ci                     { TEXTURE_COMPARE_FAIL_VALUE_ARB,  if R < Dt
1755bd8deadSopenharmony_ci
1765bd8deadSopenharmony_ci            endif
1775bd8deadSopenharmony_ci
1785bd8deadSopenharmony_ci        [...]
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci        If TEXTURE_MAG_FILTER is not NEAREST or TEXTURE_MIN_FILTER is
1815bd8deadSopenharmony_ci        not NEAREST or NEAREST_MIPMAP_NEAREST then r may be computed by
1825bd8deadSopenharmony_ci        comparing more than one depth texture value and texture R
1835bd8deadSopenharmony_ci        coordinate.  The details of this are implementation-dependent
1845bd8deadSopenharmony_ci        but r should be a value in the range
1855bd8deadSopenharmony_ci        [TEXTURE_COMPARE_FAIL_VALUE_ARB, 1] and proportional to the
1865bd8deadSopenharmony_ci        number of comparison passes or failures.
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci        [...]
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ciAdditions to Chapter 4 of the 1.3 Specification (Per-Fragment Operations
1915bd8deadSopenharmony_ciand the Frame Buffer)
1925bd8deadSopenharmony_ci
1935bd8deadSopenharmony_ci    None
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ciAdditions to Chapter 5 of the 1.3 Specification (Special Functions)
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    None
1985bd8deadSopenharmony_ci
1995bd8deadSopenharmony_ciAdditions to Chapter 6 of the 1.3 Specification (State and State Requests)
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    In section 6.1.3, p. 200, change the paragraph introduced by the
2025bd8deadSopenharmony_ci    ARB_shadow extension to be:
2035bd8deadSopenharmony_ci
2045bd8deadSopenharmony_ci    "The texture compare mode, function, result format and comparison
2055bd8deadSopenharmony_ci    failure value may be queried by calling GetTexParameteriv or
2065bd8deadSopenharmony_ci    GetTexParameterfv with <pname> set to TEXTURE_COMPARE_MODE_ARB,
2075bd8deadSopenharmony_ci    TEXTURE_COMPARE_FUNC_ARB, TEXTURE_COMPARE_RESULT_ARB, or
2085bd8deadSopenharmony_ci    TEXTURE_COMPARE_FAIL_VALUE_ARB, respectively."
2095bd8deadSopenharmony_ci
2105bd8deadSopenharmony_ciAdditions to the GLX Specification
2115bd8deadSopenharmony_ci
2125bd8deadSopenharmony_ci    None
2135bd8deadSopenharmony_ci
2145bd8deadSopenharmony_ciErrors
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ci    None.
2175bd8deadSopenharmony_ci
2185bd8deadSopenharmony_ciNew State
2195bd8deadSopenharmony_ci
2205bd8deadSopenharmony_ci    In table 6.16, Texture Objects, p. 224, add the following:
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci    Get Value                      Type   Get Command          Init Val Description                Sec.   Attribute
2235bd8deadSopenharmony_ci    ------------------------------ ------ -------------------- -------- -------------------------- ------ ---------
2245bd8deadSopenharmony_ci    TEXTURE_COMPARE_FAIL_VALUE_ARB R[0,1] GetTexParameter[if]v   0.0    texture compare fail value 3.8.13 texture
2255bd8deadSopenharmony_ci
2265bd8deadSopenharmony_ciNew Implementation Dependent State
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    None
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ciRevision History
2315bd8deadSopenharmony_ci
2325bd8deadSopenharmony_ci    16 April 2001
2335bd8deadSopenharmony_ci        - initial version
2345bd8deadSopenharmony_ci    22 April 2001
2355bd8deadSopenharmony_ci        - rename TEXTURE_FAIL_LUMINANCE_ARB to TEXTURE_FAIL_VALUE_ARB.
2365bd8deadSopenharmony_ci    23 April 2001
2375bd8deadSopenharmony_ci        - minor tweaks
2385bd8deadSopenharmony_ci    16 November 2001
2395bd8deadSopenharmony_ci        - rename TEXTURE_FAIL_VALUE_ARB to TEXTURE_COMPARE_FAIL_VALUE_ARB
2405bd8deadSopenharmony_ci    17 November 2001
2415bd8deadSopenharmony_ci        - adjusted 3.8.7.1 section number
2425bd8deadSopenharmony_ci    18 November 2001
2435bd8deadSopenharmony_ci        - Clarify that TEXTURE_COMPARE_FAIL_VALUE_ARB is clamped to [0,1]
2445bd8deadSopenharmony_ci        - added issue 6
2455bd8deadSopenharmony_ci        - let TEXTURE_COMPARE_FAIL_VALUE_ARB be the same as SHADOW_AMBIENT_SGIX
2465bd8deadSopenharmony_ci    12 December 2001
2475bd8deadSopenharmony_ci        - rewritten against the OpenGL 1.3 spec
2485bd8deadSopenharmony_ci        - fixed some typos
249