aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/ogl-sample/main/doc/man/mangl/standard/texgen.gl
blob: 66e29f1be1eb5877adfca3ca3bd13660e0cbbb74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
_C_ License Applicability. Except to the extent portions of this file are
_C_ made subject to an alternative license as permitted in the SGI Free
_C_ Software License B, Version 1.1 (the "License"), the contents of this
_C_ file are subject only to the provisions of the License. You may not use
_C_ this file except in compliance with the License. You may obtain a copy
_C_ of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
_C_ Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
_C_ 
_C_ http://oss.sgi.com/projects/FreeB
_C_ 
_C_ Note that, as provided in the License, the Software is distributed on an
_C_ "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
_C_ DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
_C_ CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
_C_ PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
_C_ 
_C_ Original Code. The Original Code is: OpenGL Sample Implementation,
_C_ Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
_C_ Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
_C_ Copyright in any portions created by third parties is as indicated
_C_ elsewhere herein. All Rights Reserved.
_C_ 
_C_ Additional Notice Provisions: The application programming interfaces
_C_ established by SGI in conjunction with the Original Code are The
_C_ OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
_C_ April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
_C_ 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
_C_ Window System(R) (Version 1.3), released October 19, 1998. This software
_C_ was created using the OpenGL(R) version 1.2.1 Sample Implementation
_C_ published by SGI, but has not been independently verified as being
_C_ compliant with the OpenGL(R) version 1.2.1 Specification.
_C_
_C_ The first character in this file must be an '_'!
_C_ Anything on a line after _C_ is ignored
_define(_filters,eqn)_C_
_C_      eqn is automatically replaced with neqn for nroff
_header(TexGen,control the generation of texture coordinates)
_names(TexGen,[ifd])
.EQ
delim $$
.EN
.SH PARAMETERS
_phead(_param1)
Specifies a texture coordinate.
Must be one of _const(S), _const(T), _const(R), or _const(Q).
_phead(_param2)
Specifies the symbolic name of the texture-coordinate generation function.
Must be _const(TEXTURE_GEN_MODE). 
_phead(_param3)
Specifies a single-valued texture generation parameter,
one of _const(OBJECT_LINEAR), _const(EYE_LINEAR), or _const(SPHERE_MAP). 
_names(TexGen,[ifd]v)
.SH PARAMETERS
_phead(_param1)
Specifies a texture coordinate.
Must be one of _const(S), _const(T), _const(R), or _const(Q).
_phead(_param2)
Specifies the symbolic name of the texture-coordinate generation function
or function parameters.
Must be
_const(TEXTURE_GEN_MODE),
_const(OBJECT_PLANE), or
_const(EYE_PLANE). 
_phead(_param3)
Specifies a pointer to an array of texture generation parameters.
If _param2 is _const(TEXTURE_GEN_MODE),
then the array must contain a single symbolic constant,
one of
_const(OBJECT_LINEAR),
_const(EYE_LINEAR), or
_const(SPHERE_MAP). 
Otherwise,
_param3 holds the coefficients for the texture-coordinate generation function
specified by _param2.
.SH DESCRIPTION
_cmnd selects a texture-coordinate generation function
or supplies coefficients for one of the functions.
_param1 names one of the (\f2s\fP, \f2t\fP, \f2r\fP, \f2q\fP) texture
coordinates; it must be one of the symbols
_const(S),
_const(T),
_const(R), or
_const(Q).
_param2 must be one of three symbolic constants:
_const(TEXTURE_GEN_MODE),
_const(OBJECT_PLANE), or
_const(EYE_PLANE). 
If _param2 is _const(TEXTURE_GEN_MODE),
then _param3 chooses a mode,
one of
_const(OBJECT_LINEAR),
_const(EYE_LINEAR), or
_const(SPHERE_MAP). 
If _param2 is either _const(OBJECT_PLANE) or _const(EYE_PLANE),
_param3 contains coefficients for the corresponding
texture generation function.
.P 
If the texture generation function is _const(OBJECT_LINEAR),
the function
.P
.ce
$g ~=~ p sub 1^x sub o ~+~ p sub 2^y sub o ~+~ p sub 3^z sub o ~+~ p sub 4^w sub o$
.P
.br
is used, where $g$ is the value computed for the coordinate named in _param1,
$p sub 1$,
$p sub 2$,
$p sub 3$,
and
$p sub 4$ are the four values supplied in _param3, and
$x sub o$,
$y sub o$,
$z sub o$, and
$w sub o$ are the object coordinates of the vertex.
This function can be used, for example, to texture-map terrain using sea level
as a reference plane
(defined by $p sub 1$, $p sub 2$, $p sub 3$, and $p sub 4$). 
The altitude of a terrain vertex is computed by the _const(OBJECT_LINEAR)
coordinate generation function as its distance from sea level; 
that altitude can then be used to index the texture image to map white snow
onto peaks and green grass onto foothills.
.P
If the texture generation function is _const(EYE_LINEAR), the function
.P
.ce
$g ~=~ p sub 1 sup prime ^x sub e ~+~ p sub 2 sup prime ^y sub e ~+~ p sub 3 sup prime ^z sub e ~+~ p sub 4 sup prime ^w sub e$
.P
.br
is used, where 
.P
.ce
$( p sub 1 sup prime
~~p sub 2 sup prime~~p sub 3 sup prime~~
{ p sub 4 sup prime}) ~=~ ( p sub 1~~ p sub 2~~ p sub 3~~ p sub 4 ) ~M sup -1$
.P
.br
and
$x sub e$,
$y sub e$,
$z sub e$, and
$w sub e$ are the eye coordinates of the vertex,
$p sub 1$,
$p sub 2$,
$p sub 3$,
and
$p sub 4$ are the values supplied in _param3, and
$M$ is the modelview matrix when _cmnd is invoked.
If $M$ is poorly conditioned or singular,
texture coordinates generated by the resulting function may be inaccurate
or undefined.
.P
Note that the values in _param3 define a reference plane in eye coordinates. 
The modelview matrix that is applied to them may not be the same one
in effect when the polygon vertices are transformed. 
This function establishes a field of texture coordinates
that can produce dynamic contour lines on moving objects.
.P
If _param2 is _const(SPHERE_MAP) and _param1 is either
_const(S) or
_const(T),
$s$ and $t$ texture coordinates are generated as follows. 
Let \f2u\fP be the unit vector pointing from the origin to the polygon vertex
(in eye coordinates). 
Let \f2n\fP sup prime be the current normal,
after transformation to eye coordinates. 
Let 
.P
.ce
$f ~=~ ( f sub x~~f sub y~~f sub z ) sup T$
be the reflection vector such that
.P
.ce
$f ~=~  u ~-~ 2 n sup prime n sup prime sup T u$
.br
.P
Finally, let $ m ~=~ 2 sqrt { f sub x sup {~2} ~+~ f sub y sup {~2} ~+~ (f sub z ~+~ 1 ) sup 2}$. 
Then the values assigned to the $s$ and $t$ texture coordinates are
.P
.ce 1
$s ~=~ f sub x over m ~+~ 1 over 2$
.sp
.ce 1
$t ~=~ f sub y over m ~+~ 1 over 2$
.P
To enable or disable a texture-coordinate generation function, call
_cmnd(Enable) or _cmnd(Disable)
with one of the symbolic texture-coordinate names
(_const(TEXTURE_GEN_S),
_const(TEXTURE_GEN_T),
_const(TEXTURE_GEN_R), or
_const(TEXTURE_GEN_Q)) as the argument. 
When enabled,
the specified texture coordinate is computed
according to the generating function associated with that coordinate. 
When disabled,
subsequent vertices take the specified texture coordinate
from the current set of texture coordinates. Initially, all texture
generation functions are set to _const(EYE_LINEAR) and are disabled.
Both $s$ plane equations are (1, 0, 0, 0),
both $t$ plane equations are (0, 1, 0, 0),
and all $r$ and $q$ plane equations are (0, 0, 0, 0).
.P
When the _arbstring(multitexture) extension is supported, _cmnd set the
texture generation parameters for the currently active texture unit,
selected with _cmnd(ActiveTextureARB).
.SH ERRORS
_const(INVALID_ENUM) is generated when _param1 or _param2 is not an
accepted defined value,
or when _param2 is _const(TEXTURE_GEN_MODE) and _param3 is not an
accepted defined value.
.P
_const(INVALID_ENUM) is generated when _param2 is _const(TEXTURE_GEN_MODE),
_param3 is _const(SPHERE_MAP),
and _param1 is either _const(R) or _const(Q).
.P
_const(INVALID_OPERATION) is generated if _cmnd
is executed between the execution of _cmnd(Begin)
and the corresponding execution of _cmnd(End).
.SH ASSOCIATED GETS
_cmnd(GetTexGen)
.br
_cmnd(IsEnabled) with argument _const(TEXTURE_GEN_S)
.br
_cmnd(IsEnabled) with argument _const(TEXTURE_GEN_T)
.br
_cmnd(IsEnabled) with argument _const(TEXTURE_GEN_R)
.br
_cmnd(IsEnabled) with argument _const(TEXTURE_GEN_Q)
.SH SEE ALSO
_cmnd(ActiveTextureARB),
_cmnd(CopyPixels),
_cmnd(CopyTexImage2D),
_cmnd(CopyTexSubImage1D),
_cmnd(CopyTexSubImage2D),
_cmnd(CopyTexSubImage3D),
_cmnd(TexEnv),
_cmnd(TexImage1D),
_cmnd(TexImage2D),
_cmnd(TexImage3D),
_cmnd(TexParameter),
_cmnd(TexSubImage1D),
_cmnd(TexSubImage2D),
_cmnd(TexSubImage3D)