• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1XXX incomplete (but getting close)
2
3Name
4
5    SGIX_cube_map
6
7Name Strings
8
9    GL_SGIX_cube_map
10
11Version
12
13    $Date: 1998/05/12 23:51:59 $ $Revision: 1.17 $
14
15Number
16
17    130
18
19Dependencies
20
21    OpenGL 1.1 is required.
22    EXT_light_texture affects the definition of this extension.
23
24    The enums EYE_SPACE_SGIX and OBJECT_SPACE_SGIX
25    are defined in the fragment_light_space spec and
26    used here. We aren't dependent upon the spec per-se,
27    but we do want those enums. If we had this spec without
28    fragment_light_space but with fragment_lighing, we'd
29    want to define them as part of this spec.
30
31Overview
32
33    This extension introduces a cube map method for performing
34    environment mapping and environment map term to the fragment
35    light equation.
36
37Issues
38
39    * What is the best way to enable environment mapping in the fragment
40    lighting equation?
41
42    I chose to use
43
44    ApplyTextureEXT(ENV_MAP_SGIX);
45    Enable(CUBE_MAP_SGIX);
46
47    * can cube map environment mapping be used with per-vertex lighting?
48
49    Sure, but it is simply a texture in this case, it is not multiplied
50    by the specular material.
51    If SGIX_texture_add_env is supported, the cube map environment
52    term can be added to the color computed in per-vertex lighting.
53
54    Use
55    Enable(CUBE_MAP_SGIX);
56    TexEnvi(TEXTURE_ENV,TEXTURE_ENV_MODE,ADD);
57
58    * do we want a way to transform the Reflection vectors by a matrix somehow?
59    Or perhaps we generate the R vector relative to the viewer.
60
61    The idea is if we are simulating thin film reflections or something like
62    that we want to use the environment map as a lighting map.
63
64    This is handled easily but clumsily with a call to
65    TexParameteri(CUBE_MAP_SGIX, ENV_MAP_SGIX, EYE_SPACE_SGIX) or
66    TexParameteri(CUBE_MAP_SGIX, ENV_MAP_SGIX, OBJECT_SPACE_SGIX)
67
68    the first case fixes the environment to the viewers head (needed by thin
69    film or lights fixed with the viewer), the second fixes it in the world
70    (classic environment mapping).
71
72    An alternative is to introduce a fragment_environment spec and
73    perhaps a call like
74    EnvironmentMapSpace({ EYE_SPACE_SGIX  |
75			  OBJECT_SPACE_SGIX })
76    This spec could also add the notion of multiplying the
77    reflected environment value by the specular material to the
78    equation in the fragment lighting spec.
79
80    * Do we explicitly include the environment map term in fragment lighting
81    equation or use this extension (or maybe texture or light environment) instead.
82
83    This extension adds an environment mapping term to the fragment lighting equation
84    If we made a seperate fragment_environment spec we could add the term
85    in that spec.
86
87    * We need to deal with PROXY stuff to determine if all the cube map
88    faces will fit.
89
90    * if it says somewhere in the GL specification that whenever 1D and 2D
91    textures are enabled (I know it says this in the man page, but I can't
92    find it in the spec), 2D wins, we need the same type of language here.
93    2D wins over cubemapping if both are enabled and there is only one
94    texture resource.
95
96    * If we say that reflection vectors are calculated on a per-fragment basis
97    this means that bumpy reflections should be possible since N could come
98    from a texture. If we further say that the approximation of interpolating
99    an per-vertex-calculated R vector is acceptable, this causes a conflict
100    because that effect would kill bumpy reflections.
101
102New Procedures and Functions
103
104New Tokens
105
106    Accepted by the <mode> parameter of ApplyTextureEXT, and
107    the <pname> parameter of
108    TexParameterf, TexParameterfv, Texparameteri, and TexParameteriv,
109    GetTexParameterfv, GetTexParameteriv:
110
111	ENV_MAP_SGIX		0x8340
112
113    Accepted by the <cap> parameter of Enable, Disable and IsEnabled,
114    the <target> parameter of
115    TexParameterf, TexParameterfv, Texparameteri, and TexParameteriv,
116    GetTexParameterfv, GetTexParameteriv,
117    BindTextureEXT,
118    accepted by the <pname> parameters of GetBooleanv, GetIntegerv:
119
120	CUBE_MAP_SGIX		0x8341
121
122    Accepted by the <target> parameters of GetTexImage,
123    GetTexLevelParameterfv, GetTexLevelParameteriv,
124    TexImage2D, TexSubImage2D, CopyTexImage2D, and CopyTexSubImage2D:
125
126	CUBE_MAP_ZP_SGIX	0x8342
127	CUBE_MAP_ZN_SGIX	0x8343
128	CUBE_MAP_XN_SGIX	0x8344
129	CUBE_MAP_XP_SGIX	0x8345
130	CUBE_MAP_YN_SGIX	0x8346
131	CUBE_MAP_YP_SGIX	0x8347
132
133    Accepted by the <pname> parameters of GetBooleanv, GetIntegerv,
134    GetFloatv, and GetDoublev:
135
136	CUBE_MAP_BINDING_SGIX	0x8348
137
138Additions to Chapter 2 of the 1.1 Specification (OpenGL Operation)
139
140
141Additions to Chapter 3 of the 1.1 Specification (Rasterization)
142
143    In section 3.8 we should add text that specifies that each of
144    the 6 faces of the cube map should be legal textures
145    based on the filtering mode before cube mapping can be enabled
146    If they are not it is as if texturing is disabled.
147
148    Before Section 3.8.1 Texture Minification insert a new section 3.8.1
149    Environment Map Address Calculation.
150
151    Environment map address calculation may be used to compute texture coordinates
152    in an environment map texture.
153
154    The Reflection vector 'r' is computed on
155    a per-fragment basis from interpolated view vector(VPe) and
156    interpolated normal 'n' vectors as
157
158    r = (X,Y,Z) = 2*n*dot(n,VPe) - VPe
159
160    If TexParameter is called with <pname> ENV_MAP_SGIX and
161    <param> OBJECT_SPACE_SGIX, the view vector 'VPe' is transformed
162    by the inverse of the modelview matrix before 'r' is calculated.
163    This is the default behavior. If TexParameter is called with
164    <pname> ENV_MAP_SGIX and <param> EYE_SPACE_SGIX, the view vector is
165    unchanged before the calculation of the reflection vector.
166
167    The calculation of 'r' may be approximated by computing it on a
168    per-vertex basis, transforming by the inverse of the modelview matrix
169    if necessary, optionally normalizing it for numerical purposes
170    and then interpolating it on a per-pixel basis.
171    This will lead to unacceptable distortion effects if r varies greatly on a
172    per-vertex basis and will also prevent the use of reflection vector generation
173    from a texture derived normal since the calculation of R occurs before
174    the texture stage.
175
176    Cube Map Face Selection
177
178    If the environment map is implemented with a cube map, one of the six faces of
179    the cube is selected by the major axis of the reflection vector on a per-pixel
180    basis.
181
182    major axis   X                Y                Z
183    -----------------------------------------------------------
184    <= 0      CUBE_MAP_XN_SGIX CUBE_MAP_YN_SGIX CUBE_MAP_ZN_SGIX
185    > 0       CUBE_MAP_XP_SGIX CUBE_MAP_YP_SGIX CUBE_MAP_ZN_SGIX
186
187    Once the face is selected, the s,t texture coordinates are computed
188    from the (X,Y,Z) coordinates of the reflection vector and replace
189    any texture coordinates specified with TexCoord or generated by TexGen as:
190
191    map                 s		t		r	q
192    -------------------------------------------------------------
193    CUBE_MAP_ZN_SGIX    .5 - .5*X/Z     .5 - .5*Y/Z	0.	1.
194    CUBE_MAP_ZP_SGIX    .5 - .5*X/Z     .5 + .5*Y/Z	0.	1.
195
196    CUBE_MAP_XN_SGIX    .5 + .5*Z/X     .5 - .5*Y/X	0.	1.
197    CUBE_MAP_XP_SGIX    .5 + .5*Z/X     .5 + .5*Y/X	0.	1.
198
199    CUBE_MAP_YN_SGIX    .5 - .5*X/Y     .5 + .5*Z/Y	0.	1.
200    CUBE_MAP_YP_SGIX    .5 + .5*X/Y     .5 + .5*Z/Y	0.	1.
201
202    note to spec editor: (see the figure in file cubemap.sho to visualize the mappings.)
203
204    Level of detail should be computed in a manner that corresponds to
205    the specification of level of detail for two-dimensional texturing.
206
207    Note that the chain rule can be applied using the above formulas and
208    slope information for X,Y,Z (dX/dx, dY/dx, dZ/dx, dX/dy, dY/dy, dZ/dy)
209    to obtain ds/dx, ds/dy, dt/dx, dt/dy.
210
211    e.g.  ds/dx = dX/dx*ds/dX + dY/dx*ds/dY + dZ/dx*ds/dZ
212
213    We add an enviroment map term to the equation in section 3.9.2 from the
214    fragment_lighting spec:
215
216    The desired general equation for the fragment illumination model is:
217
218    Cl =  Em 			emissive
219       + Am*As			ambient material*scene ambient color
220       SUM{_i = 0 through Nf-1} {
221       + Atten_i*SpotL_i*{	distance/spot light attenuation
222	    + Am*Al_i		ambient material*ambient light
223	    + Dm*Dl_i*(N.L_i)	diffuse material*diffuse light
224	    + Sm*Sl_i*(N.H_i)^n	specular material*specular light
225	  }
226	}
227	+Sm*Ev
228
229	Nf is the number of fragment light sources
230	N is the fragment normal vector
231	L_i is the direction vector from the fragment position to the light source
232	H_i is the half angle vector
233	n is the specular exponent (shininess)
234	Ev is the environment map value.
235
236    Ev is defined to be 0 unless
237    ApplyTextureEXT(ENV_MAP_SGIX) has been called in conjunction
238    with an enabled texture in which case the value is
239    the value determined from the cube map access as specified above.
240
241Additions to Chapter 4 of the 1.1 Specification (Per-Fragment Operations
242and the Framebuffer)
243
244    None
245
246Additions to Chapter 5 of the 1.1 Specification (Special Functions)
247
248    None
249
250Additions to Chapter 6 of the 1.1 Specification (State and State Requests)
251
252    Although many of the parameter values of a set of cube map textures have no
253    effect on texture operation, they are maintained and may be queried.
254    There is no value associated with the binding points
255    CUBE_MAP_ZP_2D_SGIX,
256    CUBE_MAP_ZN_2D_SGIX,
257    CUBE_MAP_XN_2D_SGIX,
258    CUBE_MAP_XP_2D_SGIX,
259    CUBE_MAP_YN_2D_SGIX,
260    CUBE_MAP_YP_2D_SGIX,
261    so they are not accepted as the <pname> parameter
262    of GetBooleanv, GetIntegerv, GetFloatv, or GetDoublev.  The name of
263    the set of cube map textures that are bound to the above binding posts are queried
264    by calling GetBooleanv, GetIntegerv, GetFloatv, or GetDoublev with
265    <pname> set to CUBE_MAP_BINDING_SGIX.
266    Zero is returned if no texture has been bound.
267
268Additions to the GLX Specification
269
270    None
271
272Dependencies on EXT_light_texture
273
274    If EXT_light_texture is not supported, then references to
275    ApplyTextureEXT() are to be ignored.
276
277Errors
278
279    INVALID_VALUE is generated if BindTextureEXT parameter <target> is
280    one of CUBE_MAP_SGIX
281    and parameter <texture> is not the name of a
282    cube map texture, the name of an as yet unbound texture, or zero.
283
284    * more of these *
285
286New State
287
288    Get Value			Get Command		Type	Initial Value		Attribute
289    ---------			-----------		----	-------------		---------
290    CUBE_MAP_BINDING_SGIX	GetIntegerv		Z+	0			texture
291    ENV_MAP_SGIX		GetTexParameteriv	Z2	OBJECT_SPACE_SGIX	texture
292    CUBE_MAP                    IsEnabled               XXX?
293
294
295    CUBE_MAP_ZP_2D_SGIX etc XXX (how do we specify this?)
296
297New Implementation Dependent State
298
299    None
300