15bd8deadSopenharmony_ciXXX incomplete (but getting close) 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ciName 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ci SGIX_cube_map 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ciName Strings 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ci GL_SGIX_cube_map 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ciVersion 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ci $Date: 1998/05/12 23:51:59 $ $Revision: 1.17 $ 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ciNumber 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ci 130 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciDependencies 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci OpenGL 1.1 is required. 225bd8deadSopenharmony_ci EXT_light_texture affects the definition of this extension. 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci The enums EYE_SPACE_SGIX and OBJECT_SPACE_SGIX 255bd8deadSopenharmony_ci are defined in the fragment_light_space spec and 265bd8deadSopenharmony_ci used here. We aren't dependent upon the spec per-se, 275bd8deadSopenharmony_ci but we do want those enums. If we had this spec without 285bd8deadSopenharmony_ci fragment_light_space but with fragment_lighing, we'd 295bd8deadSopenharmony_ci want to define them as part of this spec. 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciOverview 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci This extension introduces a cube map method for performing 345bd8deadSopenharmony_ci environment mapping and environment map term to the fragment 355bd8deadSopenharmony_ci light equation. 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ciIssues 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci * What is the best way to enable environment mapping in the fragment 405bd8deadSopenharmony_ci lighting equation? 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci I chose to use 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci ApplyTextureEXT(ENV_MAP_SGIX); 455bd8deadSopenharmony_ci Enable(CUBE_MAP_SGIX); 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci * can cube map environment mapping be used with per-vertex lighting? 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci Sure, but it is simply a texture in this case, it is not multiplied 505bd8deadSopenharmony_ci by the specular material. 515bd8deadSopenharmony_ci If SGIX_texture_add_env is supported, the cube map environment 525bd8deadSopenharmony_ci term can be added to the color computed in per-vertex lighting. 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci Use 555bd8deadSopenharmony_ci Enable(CUBE_MAP_SGIX); 565bd8deadSopenharmony_ci TexEnvi(TEXTURE_ENV,TEXTURE_ENV_MODE,ADD); 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci * do we want a way to transform the Reflection vectors by a matrix somehow? 595bd8deadSopenharmony_ci Or perhaps we generate the R vector relative to the viewer. 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci The idea is if we are simulating thin film reflections or something like 625bd8deadSopenharmony_ci that we want to use the environment map as a lighting map. 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci This is handled easily but clumsily with a call to 655bd8deadSopenharmony_ci TexParameteri(CUBE_MAP_SGIX, ENV_MAP_SGIX, EYE_SPACE_SGIX) or 665bd8deadSopenharmony_ci TexParameteri(CUBE_MAP_SGIX, ENV_MAP_SGIX, OBJECT_SPACE_SGIX) 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ci the first case fixes the environment to the viewers head (needed by thin 695bd8deadSopenharmony_ci film or lights fixed with the viewer), the second fixes it in the world 705bd8deadSopenharmony_ci (classic environment mapping). 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci An alternative is to introduce a fragment_environment spec and 735bd8deadSopenharmony_ci perhaps a call like 745bd8deadSopenharmony_ci EnvironmentMapSpace({ EYE_SPACE_SGIX | 755bd8deadSopenharmony_ci OBJECT_SPACE_SGIX }) 765bd8deadSopenharmony_ci This spec could also add the notion of multiplying the 775bd8deadSopenharmony_ci reflected environment value by the specular material to the 785bd8deadSopenharmony_ci equation in the fragment lighting spec. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci * Do we explicitly include the environment map term in fragment lighting 815bd8deadSopenharmony_ci equation or use this extension (or maybe texture or light environment) instead. 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci This extension adds an environment mapping term to the fragment lighting equation 845bd8deadSopenharmony_ci If we made a seperate fragment_environment spec we could add the term 855bd8deadSopenharmony_ci in that spec. 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci * We need to deal with PROXY stuff to determine if all the cube map 885bd8deadSopenharmony_ci faces will fit. 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci * if it says somewhere in the GL specification that whenever 1D and 2D 915bd8deadSopenharmony_ci textures are enabled (I know it says this in the man page, but I can't 925bd8deadSopenharmony_ci find it in the spec), 2D wins, we need the same type of language here. 935bd8deadSopenharmony_ci 2D wins over cubemapping if both are enabled and there is only one 945bd8deadSopenharmony_ci texture resource. 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ci * If we say that reflection vectors are calculated on a per-fragment basis 975bd8deadSopenharmony_ci this means that bumpy reflections should be possible since N could come 985bd8deadSopenharmony_ci from a texture. If we further say that the approximation of interpolating 995bd8deadSopenharmony_ci an per-vertex-calculated R vector is acceptable, this causes a conflict 1005bd8deadSopenharmony_ci because that effect would kill bumpy reflections. 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ciNew Procedures and Functions 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ciNew Tokens 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci Accepted by the <mode> parameter of ApplyTextureEXT, and 1075bd8deadSopenharmony_ci the <pname> parameter of 1085bd8deadSopenharmony_ci TexParameterf, TexParameterfv, Texparameteri, and TexParameteriv, 1095bd8deadSopenharmony_ci GetTexParameterfv, GetTexParameteriv: 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci ENV_MAP_SGIX 0x8340 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci Accepted by the <cap> parameter of Enable, Disable and IsEnabled, 1145bd8deadSopenharmony_ci the <target> parameter of 1155bd8deadSopenharmony_ci TexParameterf, TexParameterfv, Texparameteri, and TexParameteriv, 1165bd8deadSopenharmony_ci GetTexParameterfv, GetTexParameteriv, 1175bd8deadSopenharmony_ci BindTextureEXT, 1185bd8deadSopenharmony_ci accepted by the <pname> parameters of GetBooleanv, GetIntegerv: 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci CUBE_MAP_SGIX 0x8341 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci Accepted by the <target> parameters of GetTexImage, 1235bd8deadSopenharmony_ci GetTexLevelParameterfv, GetTexLevelParameteriv, 1245bd8deadSopenharmony_ci TexImage2D, TexSubImage2D, CopyTexImage2D, and CopyTexSubImage2D: 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci CUBE_MAP_ZP_SGIX 0x8342 1275bd8deadSopenharmony_ci CUBE_MAP_ZN_SGIX 0x8343 1285bd8deadSopenharmony_ci CUBE_MAP_XN_SGIX 0x8344 1295bd8deadSopenharmony_ci CUBE_MAP_XP_SGIX 0x8345 1305bd8deadSopenharmony_ci CUBE_MAP_YN_SGIX 0x8346 1315bd8deadSopenharmony_ci CUBE_MAP_YP_SGIX 0x8347 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci Accepted by the <pname> parameters of GetBooleanv, GetIntegerv, 1345bd8deadSopenharmony_ci GetFloatv, and GetDoublev: 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci CUBE_MAP_BINDING_SGIX 0x8348 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ciAdditions to Chapter 2 of the 1.1 Specification (OpenGL Operation) 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ciAdditions to Chapter 3 of the 1.1 Specification (Rasterization) 1425bd8deadSopenharmony_ci 1435bd8deadSopenharmony_ci In section 3.8 we should add text that specifies that each of 1445bd8deadSopenharmony_ci the 6 faces of the cube map should be legal textures 1455bd8deadSopenharmony_ci based on the filtering mode before cube mapping can be enabled 1465bd8deadSopenharmony_ci If they are not it is as if texturing is disabled. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci Before Section 3.8.1 Texture Minification insert a new section 3.8.1 1495bd8deadSopenharmony_ci Environment Map Address Calculation. 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci Environment map address calculation may be used to compute texture coordinates 1525bd8deadSopenharmony_ci in an environment map texture. 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci The Reflection vector 'r' is computed on 1555bd8deadSopenharmony_ci a per-fragment basis from interpolated view vector(VPe) and 1565bd8deadSopenharmony_ci interpolated normal 'n' vectors as 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci r = (X,Y,Z) = 2*n*dot(n,VPe) - VPe 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ci If TexParameter is called with <pname> ENV_MAP_SGIX and 1615bd8deadSopenharmony_ci <param> OBJECT_SPACE_SGIX, the view vector 'VPe' is transformed 1625bd8deadSopenharmony_ci by the inverse of the modelview matrix before 'r' is calculated. 1635bd8deadSopenharmony_ci This is the default behavior. If TexParameter is called with 1645bd8deadSopenharmony_ci <pname> ENV_MAP_SGIX and <param> EYE_SPACE_SGIX, the view vector is 1655bd8deadSopenharmony_ci unchanged before the calculation of the reflection vector. 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci The calculation of 'r' may be approximated by computing it on a 1685bd8deadSopenharmony_ci per-vertex basis, transforming by the inverse of the modelview matrix 1695bd8deadSopenharmony_ci if necessary, optionally normalizing it for numerical purposes 1705bd8deadSopenharmony_ci and then interpolating it on a per-pixel basis. 1715bd8deadSopenharmony_ci This will lead to unacceptable distortion effects if r varies greatly on a 1725bd8deadSopenharmony_ci per-vertex basis and will also prevent the use of reflection vector generation 1735bd8deadSopenharmony_ci from a texture derived normal since the calculation of R occurs before 1745bd8deadSopenharmony_ci the texture stage. 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci Cube Map Face Selection 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci If the environment map is implemented with a cube map, one of the six faces of 1795bd8deadSopenharmony_ci the cube is selected by the major axis of the reflection vector on a per-pixel 1805bd8deadSopenharmony_ci basis. 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci major axis X Y Z 1835bd8deadSopenharmony_ci ----------------------------------------------------------- 1845bd8deadSopenharmony_ci <= 0 CUBE_MAP_XN_SGIX CUBE_MAP_YN_SGIX CUBE_MAP_ZN_SGIX 1855bd8deadSopenharmony_ci > 0 CUBE_MAP_XP_SGIX CUBE_MAP_YP_SGIX CUBE_MAP_ZN_SGIX 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci Once the face is selected, the s,t texture coordinates are computed 1885bd8deadSopenharmony_ci from the (X,Y,Z) coordinates of the reflection vector and replace 1895bd8deadSopenharmony_ci any texture coordinates specified with TexCoord or generated by TexGen as: 1905bd8deadSopenharmony_ci 1915bd8deadSopenharmony_ci map s t r q 1925bd8deadSopenharmony_ci ------------------------------------------------------------- 1935bd8deadSopenharmony_ci CUBE_MAP_ZN_SGIX .5 - .5*X/Z .5 - .5*Y/Z 0. 1. 1945bd8deadSopenharmony_ci CUBE_MAP_ZP_SGIX .5 - .5*X/Z .5 + .5*Y/Z 0. 1. 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci CUBE_MAP_XN_SGIX .5 + .5*Z/X .5 - .5*Y/X 0. 1. 1975bd8deadSopenharmony_ci CUBE_MAP_XP_SGIX .5 + .5*Z/X .5 + .5*Y/X 0. 1. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci CUBE_MAP_YN_SGIX .5 - .5*X/Y .5 + .5*Z/Y 0. 1. 2005bd8deadSopenharmony_ci CUBE_MAP_YP_SGIX .5 + .5*X/Y .5 + .5*Z/Y 0. 1. 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci note to spec editor: (see the figure in file cubemap.sho to visualize the mappings.) 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci Level of detail should be computed in a manner that corresponds to 2055bd8deadSopenharmony_ci the specification of level of detail for two-dimensional texturing. 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ci Note that the chain rule can be applied using the above formulas and 2085bd8deadSopenharmony_ci slope information for X,Y,Z (dX/dx, dY/dx, dZ/dx, dX/dy, dY/dy, dZ/dy) 2095bd8deadSopenharmony_ci to obtain ds/dx, ds/dy, dt/dx, dt/dy. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci e.g. ds/dx = dX/dx*ds/dX + dY/dx*ds/dY + dZ/dx*ds/dZ 2125bd8deadSopenharmony_ci 2135bd8deadSopenharmony_ci We add an enviroment map term to the equation in section 3.9.2 from the 2145bd8deadSopenharmony_ci fragment_lighting spec: 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci The desired general equation for the fragment illumination model is: 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ci Cl = Em emissive 2195bd8deadSopenharmony_ci + Am*As ambient material*scene ambient color 2205bd8deadSopenharmony_ci SUM{_i = 0 through Nf-1} { 2215bd8deadSopenharmony_ci + Atten_i*SpotL_i*{ distance/spot light attenuation 2225bd8deadSopenharmony_ci + Am*Al_i ambient material*ambient light 2235bd8deadSopenharmony_ci + Dm*Dl_i*(N.L_i) diffuse material*diffuse light 2245bd8deadSopenharmony_ci + Sm*Sl_i*(N.H_i)^n specular material*specular light 2255bd8deadSopenharmony_ci } 2265bd8deadSopenharmony_ci } 2275bd8deadSopenharmony_ci +Sm*Ev 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci Nf is the number of fragment light sources 2305bd8deadSopenharmony_ci N is the fragment normal vector 2315bd8deadSopenharmony_ci L_i is the direction vector from the fragment position to the light source 2325bd8deadSopenharmony_ci H_i is the half angle vector 2335bd8deadSopenharmony_ci n is the specular exponent (shininess) 2345bd8deadSopenharmony_ci Ev is the environment map value. 2355bd8deadSopenharmony_ci 2365bd8deadSopenharmony_ci Ev is defined to be 0 unless 2375bd8deadSopenharmony_ci ApplyTextureEXT(ENV_MAP_SGIX) has been called in conjunction 2385bd8deadSopenharmony_ci with an enabled texture in which case the value is 2395bd8deadSopenharmony_ci the value determined from the cube map access as specified above. 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ciAdditions to Chapter 4 of the 1.1 Specification (Per-Fragment Operations 2425bd8deadSopenharmony_ciand the Framebuffer) 2435bd8deadSopenharmony_ci 2445bd8deadSopenharmony_ci None 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ciAdditions to Chapter 5 of the 1.1 Specification (Special Functions) 2475bd8deadSopenharmony_ci 2485bd8deadSopenharmony_ci None 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ciAdditions to Chapter 6 of the 1.1 Specification (State and State Requests) 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci Although many of the parameter values of a set of cube map textures have no 2535bd8deadSopenharmony_ci effect on texture operation, they are maintained and may be queried. 2545bd8deadSopenharmony_ci There is no value associated with the binding points 2555bd8deadSopenharmony_ci CUBE_MAP_ZP_2D_SGIX, 2565bd8deadSopenharmony_ci CUBE_MAP_ZN_2D_SGIX, 2575bd8deadSopenharmony_ci CUBE_MAP_XN_2D_SGIX, 2585bd8deadSopenharmony_ci CUBE_MAP_XP_2D_SGIX, 2595bd8deadSopenharmony_ci CUBE_MAP_YN_2D_SGIX, 2605bd8deadSopenharmony_ci CUBE_MAP_YP_2D_SGIX, 2615bd8deadSopenharmony_ci so they are not accepted as the <pname> parameter 2625bd8deadSopenharmony_ci of GetBooleanv, GetIntegerv, GetFloatv, or GetDoublev. The name of 2635bd8deadSopenharmony_ci the set of cube map textures that are bound to the above binding posts are queried 2645bd8deadSopenharmony_ci by calling GetBooleanv, GetIntegerv, GetFloatv, or GetDoublev with 2655bd8deadSopenharmony_ci <pname> set to CUBE_MAP_BINDING_SGIX. 2665bd8deadSopenharmony_ci Zero is returned if no texture has been bound. 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ciAdditions to the GLX Specification 2695bd8deadSopenharmony_ci 2705bd8deadSopenharmony_ci None 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ciDependencies on EXT_light_texture 2735bd8deadSopenharmony_ci 2745bd8deadSopenharmony_ci If EXT_light_texture is not supported, then references to 2755bd8deadSopenharmony_ci ApplyTextureEXT() are to be ignored. 2765bd8deadSopenharmony_ci 2775bd8deadSopenharmony_ciErrors 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci INVALID_VALUE is generated if BindTextureEXT parameter <target> is 2805bd8deadSopenharmony_ci one of CUBE_MAP_SGIX 2815bd8deadSopenharmony_ci and parameter <texture> is not the name of a 2825bd8deadSopenharmony_ci cube map texture, the name of an as yet unbound texture, or zero. 2835bd8deadSopenharmony_ci 2845bd8deadSopenharmony_ci * more of these * 2855bd8deadSopenharmony_ci 2865bd8deadSopenharmony_ciNew State 2875bd8deadSopenharmony_ci 2885bd8deadSopenharmony_ci Get Value Get Command Type Initial Value Attribute 2895bd8deadSopenharmony_ci --------- ----------- ---- ------------- --------- 2905bd8deadSopenharmony_ci CUBE_MAP_BINDING_SGIX GetIntegerv Z+ 0 texture 2915bd8deadSopenharmony_ci ENV_MAP_SGIX GetTexParameteriv Z2 OBJECT_SPACE_SGIX texture 2925bd8deadSopenharmony_ci CUBE_MAP IsEnabled XXX? 2935bd8deadSopenharmony_ci 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci CUBE_MAP_ZP_2D_SGIX etc XXX (how do we specify this?) 2965bd8deadSopenharmony_ci 2975bd8deadSopenharmony_ciNew Implementation Dependent State 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ci None 300