15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_shader_texture_lod
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_shader_texture_lod
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Benj Lipchak
125bd8deadSopenharmony_ci    Ben Bowman
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ci    and contributors to the ARB_shader_texture_lod spec, 
155bd8deadSopenharmony_ci    which provided the basis for this spec.
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ciContact
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    Benj Lipchak, Apple (lipchak 'at' apple.com)
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciIP Status
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    No known IP issues.
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciStatus
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    Draft
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciVersion
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    Last Modified Date: February 24, 2011
325bd8deadSopenharmony_ci    Revision: 3
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ciNumber
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    OpenGL ES Extension #77
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ciDependencies
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 2.0 Specification.
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    This extension is written against The OpenGL ES Shading Language,
435bd8deadSopenharmony_ci    Language Version 1.00, Document Revision 17.
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ci    This extension interacts with EXT_texture_filter_anisotropic.
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ciOverview
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ci    This extension adds additional texture functions to the
505bd8deadSopenharmony_ci    OpenGL ES Shading Language which provide the shader writer
515bd8deadSopenharmony_ci    with explicit control of LOD.
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    Mipmap texture fetches and anisotropic texture fetches
545bd8deadSopenharmony_ci    require implicit derivatives to calculate rho, lambda
555bd8deadSopenharmony_ci    and/or the line of anisotropy.  These implicit derivatives
565bd8deadSopenharmony_ci    will be undefined for texture fetches occurring inside
575bd8deadSopenharmony_ci    non-uniform control flow or for vertex shader texture
585bd8deadSopenharmony_ci    fetches, resulting in undefined texels.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ci    The additional texture functions introduced with
615bd8deadSopenharmony_ci    this extension provide explicit control of LOD
625bd8deadSopenharmony_ci    (isotropic texture functions) or provide explicit
635bd8deadSopenharmony_ci    derivatives (anisotropic texture functions).
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ci    Anisotropic texture functions return defined texels
665bd8deadSopenharmony_ci    for mipmap texture fetches or anisotropic texture fetches,
675bd8deadSopenharmony_ci    even inside non-uniform control flow.  Isotropic texture
685bd8deadSopenharmony_ci    functions return defined texels for mipmap texture fetches,
695bd8deadSopenharmony_ci    even inside non-uniform control flow.  However, isotropic
705bd8deadSopenharmony_ci    texture functions return undefined texels for anisotropic
715bd8deadSopenharmony_ci    texture fetches.
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    The existing isotropic vertex texture functions:
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci        vec4 texture2DLodEXT(sampler2D sampler,
765bd8deadSopenharmony_ci                             vec2 coord, 
775bd8deadSopenharmony_ci                             float lod);
785bd8deadSopenharmony_ci        vec4 texture2DProjLodEXT(sampler2D sampler,
795bd8deadSopenharmony_ci                                 vec3 coord, 
805bd8deadSopenharmony_ci                                 float lod);
815bd8deadSopenharmony_ci        vec4 texture2DProjLodEXT(sampler2D sampler,
825bd8deadSopenharmony_ci                                 vec4 coord, 
835bd8deadSopenharmony_ci                                 float lod);
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci        vec4 textureCubeLodEXT(samplerCube sampler,
865bd8deadSopenharmony_ci                               vec3 coord,
875bd8deadSopenharmony_ci                               float lod);
885bd8deadSopenharmony_ci
895bd8deadSopenharmony_ci    are added to the built-in functions for fragment shaders
905bd8deadSopenharmony_ci    with "EXT" suffix appended.
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    New anisotropic texture functions, providing explicit
935bd8deadSopenharmony_ci    derivatives:
945bd8deadSopenharmony_ci
955bd8deadSopenharmony_ci        vec4 texture2DGradEXT(sampler2D sampler,
965bd8deadSopenharmony_ci                              vec2 P, 
975bd8deadSopenharmony_ci                              vec2 dPdx, 
985bd8deadSopenharmony_ci                              vec2  dPdy);
995bd8deadSopenharmony_ci        vec4 texture2DProjGradEXT(sampler2D sampler,
1005bd8deadSopenharmony_ci                                  vec3 P, 
1015bd8deadSopenharmony_ci                                  vec2 dPdx, 
1025bd8deadSopenharmony_ci                                  vec2 dPdy);
1035bd8deadSopenharmony_ci        vec4 texture2DProjGradEXT(sampler2D sampler,
1045bd8deadSopenharmony_ci                                  vec4 P,
1055bd8deadSopenharmony_ci                                  vec2 dPdx, 
1065bd8deadSopenharmony_ci                                  vec2 dPdy);
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci        vec4 textureCubeGradEXT(samplerCube sampler,
1095bd8deadSopenharmony_ci                                vec3 P,
1105bd8deadSopenharmony_ci                                vec3 dPdx, 
1115bd8deadSopenharmony_ci                                vec3 dPdy);
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci     are added to the built-in functions for vertex shaders
1145bd8deadSopenharmony_ci     and fragment shaders.
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ciNew Procedures and Functions
1175bd8deadSopenharmony_ci
1185bd8deadSopenharmony_ci    None
1195bd8deadSopenharmony_ci
1205bd8deadSopenharmony_ciNew Tokens
1215bd8deadSopenharmony_ci
1225bd8deadSopenharmony_ci    None
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL Operation)
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    None
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci    In Section 3.7.7, replace the final paragraph on p. 76 with:
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci    "Let s(x, y) be the function that associates an s texture coordinate
1335bd8deadSopenharmony_ci    with each set of window coordinates (x, y) that lie within a
1345bd8deadSopenharmony_ci    primitive;  define t(x, y) analogously.  Let u(x, y) = wt * s(x, y) and 
1355bd8deadSopenharmony_ci    v(x, y) = ht * t(x, y), where wt and ht are equal to the width and height 
1365bd8deadSopenharmony_ci    of the level zero array.
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    Let
1395bd8deadSopenharmony_ci        dUdx = wt*dSdx; dUdy = wt*dSdy;
1405bd8deadSopenharmony_ci        dVdx = ht*dTdx; dVdy = ht*dTdy;                       (3.12a)
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci    where dSdx indicates the derivative of s with respect to window x,
1435bd8deadSopenharmony_ci    and similarly for dTdx.
1445bd8deadSopenharmony_ci
1455bd8deadSopenharmony_ci    For a polygon, rho is given at a fragment with window coordinates
1465bd8deadSopenharmony_ci    (x, y) by
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci        rho = max (
1495bd8deadSopenharmony_ci              sqrt(dUdx*dUdx + dVdx*dVdx),
1505bd8deadSopenharmony_ci              sqrt(dUdy*dUdy + dVdy*dVdy)
1515bd8deadSopenharmony_ci              );                                              (3.12b)"
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment Operations and the Frame Buffer)
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci    None
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL ES 2.0 Specification (Special Functions)
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci    None
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 2.0 Specification (State and State
1625bd8deadSopenharmony_ciRequests)
1635bd8deadSopenharmony_ci
1645bd8deadSopenharmony_ci    None
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL ES 2.0 Specification (Invariance)
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci    None
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ciAdditions to version 1.00.17 of the OpenGL ES Shading Language Specification
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci    "A new preprocessor #define is added to the OpenGL Shading Language:
1735bd8deadSopenharmony_ci
1745bd8deadSopenharmony_ci        #define GL_EXT_shader_texture_lod 1
1755bd8deadSopenharmony_ci
1765bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
1775bd8deadSopenharmony_ci    language features described in this extension:
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci        #extension GL_EXT_shader_texture_lod : <behavior>
1805bd8deadSopenharmony_ci
1815bd8deadSopenharmony_ci    Where <behavior> is as specified in section 3.3."
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ci
1845bd8deadSopenharmony_ciAdditions to Chapter 8 of version 1.00.17 of the OpenGL ES Shading Language
1855bd8deadSopenharmony_ciSpecification
1865bd8deadSopenharmony_ci
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci    8.7  Texture Lookup Functions
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci    Delete the last paragraph, and replace with:
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    "For the "Lod" functions, lod specifies lambda_base (see equation 3.11 in
1935bd8deadSopenharmony_ci    The OpenGL ES 2.0 Specification) and specifies dSdx, dTdx = 0 and
1945bd8deadSopenharmony_ci    dSdy, dTdy = 0 (see equation 3.12a in The OpenGL ES 2.0 Specification).
1955bd8deadSopenharmony_ci    The "Lod" functions are allowed in a vertex shader.  If enabled by the 
1965bd8deadSopenharmony_ci    preprocessor directive #extension, the "Lod" functions are also allowed in 
1975bd8deadSopenharmony_ci    a fragment shader.
1985bd8deadSopenharmony_ci
1995bd8deadSopenharmony_ci    For the "Grad" functions, dPdx is the explicit derivative of P with respect
2005bd8deadSopenharmony_ci    to window x, and similarly dPdy with respect to window y. For the "ProjGrad"
2015bd8deadSopenharmony_ci    functions, dPdx is the explicit derivative of the projected P with respect
2025bd8deadSopenharmony_ci    to window x, and similarly for dPdy with respect to window y.  For a two-
2035bd8deadSopenharmony_ci    dimensional texture, dPdx and dPdy are vec2.  For a cube map texture, 
2045bd8deadSopenharmony_ci    dPdx and dPdy are vec3.
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci    Let
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ci        dSdx = dPdx.s;
2095bd8deadSopenharmony_ci        dSdy = dPdy.s;
2105bd8deadSopenharmony_ci        dTdx = dPdx.t;
2115bd8deadSopenharmony_ci        dTdy = dPdy.t;
2125bd8deadSopenharmony_ci
2135bd8deadSopenharmony_ci    and
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci                / 0.0;    for two-dimensional texture
2165bd8deadSopenharmony_ci        dRdx = (
2175bd8deadSopenharmony_ci                \ dPdx.p; for cube map texture
2185bd8deadSopenharmony_ci
2195bd8deadSopenharmony_ci                / 0.0;    for two-dimensional texture
2205bd8deadSopenharmony_ci        dRdy = (
2215bd8deadSopenharmony_ci                \ dPdy.p; for cube map texture
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ci    (See equation 3.12a in The OpenGL ES 2.0 Specification.)
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    If enabled by the preprocessor directive #extension, the "Grad" functions
2265bd8deadSopenharmony_ci    are allowed in vertex and fragment shaders.
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    All other texture functions may require implicit derivatives.  Implicit
2295bd8deadSopenharmony_ci    derivatives are undefined within non-uniform control flow or for vertex
2305bd8deadSopenharmony_ci    shader texture fetches."
2315bd8deadSopenharmony_ci
2325bd8deadSopenharmony_ci    Add the following entries to the texture function table:
2335bd8deadSopenharmony_ci
2345bd8deadSopenharmony_ci        vec4 texture2DGradEXT(sampler2D sampler,
2355bd8deadSopenharmony_ci                              vec2 P, 
2365bd8deadSopenharmony_ci                              vec2 dPdx, 
2375bd8deadSopenharmony_ci                              vec2  dPdy);
2385bd8deadSopenharmony_ci        vec4 texture2DProjGradEXT(sampler2D sampler,
2395bd8deadSopenharmony_ci                                  vec3 P, 
2405bd8deadSopenharmony_ci                                  vec2 dPdx, 
2415bd8deadSopenharmony_ci                                  vec2 dPdy);
2425bd8deadSopenharmony_ci        vec4 texture2DProjGradEXT(sampler2D sampler,
2435bd8deadSopenharmony_ci                                  vec4 P,
2445bd8deadSopenharmony_ci                                  vec2 dPdx, 
2455bd8deadSopenharmony_ci                                  vec2 dPdy);
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci        vec4 textureCubeGradEXT(samplerCube sampler,
2485bd8deadSopenharmony_ci                                vec3 P,
2495bd8deadSopenharmony_ci                                vec3 dPdx, 
2505bd8deadSopenharmony_ci                                vec3 dPdy);
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ciInteractions with EXT_texture_anisotropic
2535bd8deadSopenharmony_ci
2545bd8deadSopenharmony_ci    The Lod functions set the derivatives ds/dx, dt/dx, dr/dx,
2555bd8deadSopenharmony_ci    dx/dy, dt/dy, and dr/dy = 0.  Therefore Rhox and Rhoy = 0
2565bd8deadSopenharmony_ci    0, Rhomax and Rhomin = 0.
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ciRevision History:
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci3 - 2011-02-24
2615bd8deadSopenharmony_ci    * Assign extension number
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ci2 - 2010-01-20
2645bd8deadSopenharmony_ci    * Naming updates
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci1 - 2010-01-19
2675bd8deadSopenharmony_ci    * Initial ES version
268