glDetailTexFuncSGIS(3G) OpenGL Reference glDetailTexFuncSGIS(3G)
NAME
glDetailTexFuncSGIS - specify detail texture scaling function
C SPECIFICATION
void glDetailTexFuncSGIS( GLenum target,
GLsizei n,
const GLfloat *points )
PARAMETERS
target The target to which the scaling function will be applied. Must be
GLTEXTURE2D.
n The number of scaling function samples in points.
points An array of scaling function samples, each of which is an (LOD,
function-value) pair.
DESCRIPTION
The detail texture extension defines three additional texture
magnification filters. These filters are selected by choosing one of the
values GLLINEARDETAILSGIS, GLLINEARDETAILALPHASGIS, or
GLLINEARDETAILCOLORSGIS for the current 2D texture's
GLTEXTUREMAGFILTER.
All three filters sample the level zero texture array exactly as it would
be sampled with filter mode GLLINEAR. All three also sample the level
zero texture array of a second texture, known as the detail texture, when
two conditions are met. The detail texture corresponding to texture
GLTEXTURE2D is GLDETAILTEXTURE2DSGIS. The conditions are:
1. The active texture must be GLTEXTURE2D.
2. The internal formats of GLTEXTURE2D and
GLDETAILTEXTURE2DSGIS must have been specified identically.
3 The level 0 image of GLDETAILTEXTURE2DSGIS must have nonzero
width and height.
4 If the internal formats of GLTEXTURE2D and
GLDETAILTEXTURE2DSGIS are one of the dual or quad texture
storage formats as defined by SGIStextureselect, then the
corresponding texture group selection must be specified
identically.
If these conditions are not met, it is as though the magnification
texture filter was GLLINEAR. (Although querying the magnification
filter value will return the value as specified.) If they are met, the
level zero array of the detail texture is also linearly sampled, using
the following arithmetic:
Page 1
glDetailTexFuncSGIS(3G) OpenGL Reference glDetailTexFuncSGIS(3G)
n = log base 2 of the width of the level zero array of GLTEXTURE2D
m = log base 2 of the height of the level zero array of GLTEXTURE2D
N = log base 2 of the width of GLDETAILTEXTURE2DSGIS
M = log base 2 of the height of GLDETAILTEXTURE2DSGIS
L = GLDETAILTEXTURELEVELSGIS value of GLTEXTURE2D
u = s * 2**(n-L)
v = t * 2**(m-L)
i0 = floor(u - 1/2) mod 2**N
j0 = floor(v - 1/2) mod 2**M
i1 = (i0 + 1) mod 2**N
j1 = (j0 + 1) mod 2**M
A = frac(u - 1/2)
B = frac(v - 1/2)
Tdetail = (1-A) * (1-B) * detail[i0,j0] +
A * (1-B) * detail[i1,j0] +
(1-A) * B * detail[i0,j1] +
A * B * detail[i1,j1]
Note that magnification corresponds to negative values of level-of-detail
and minification corresponds to positive values. Hence L, the value of
the GLDETAILTEXTURELEVELSGIS parameter of GLTEXTURE2D, must be
negative. The absolute value of L can be thought of as the number of
levels that separate the layer zero image of GLTEXTURE2D and the image
of GLDETAILTEXTURE2DSGIS, which is replicated as necessary to fill
the appropriate number of texels. For example, if L is -2, the detail
texture image is replicated as necessary in x and y to form a single
image whose dimensions are four times larger than the level zero array of
GLTEXTURE2D.
The texture value computed from the primary texture (Ttexture) and the
value computed from the detail texture (Tdetail) are combined in one of
two ways to compute the final texture value (T). The values of Ttexture,
Tdetail, and T are treated as though they range from 0.0 through 1.0 in
these equations.
If GLDETAILTEXTUREMODESGIS of GLTEXTURE2D is GLADD, then
T' = Ttexture + F(LOD) * (2*Tdetail-1)
T = 0 if T' < 0;
T' if 0 <= T' <= 1;
1 if T' > 1.
Page 2
glDetailTexFuncSGIS(3G) OpenGL Reference glDetailTexFuncSGIS(3G)
where F is a function of the level-of-detail parameter LOD. In effect,
the detail texture is scaled and biased so that its range is [-1,1]. The
resulting signed value is scaled by a function of LOD, added to the base
texture, and clamped to [0,1].
If GLDETAILTEXTUREMODESGIS of GLTEXTURE2D is GLMODULATE, then
T' = Ttexture * (1 + F(LOD) * (2*Tdetail-1))
T = 0 if T' < 0;
T' if 0 <= T' <= 1;
1 if T' > 1.
Here again the detail texture is scaled and biased so that its range is
[-1,1]. The resulting signed value is scaled by a function of LOD and
biased by 1. This result scales the base texture, which is then clamped
to [0,1].
glDetailTexFuncSGIS is used to specify the scaling function F. target
must be GLTEXTURE2D. n specifies the number of pairs of values in
points. points points to an array of pairs of floating point values.
The first value of each pair specifies a value of LOD, and the second
value of each pair specifies the corresponding function value. The order
in which the points are specified is not significant. The n value pairs
in points completely specify the function, replacing any previous
specification that may have existed.
The function F is evaluated by fitting a curve through the sample points
specified in points. This curve may be linear between adjacent points,
or it may be smoothed, but it will pass exactly through the points,
limited only by the resolution of the implementation. The value pair
with the lowest LOD value specifies the function value F for all values
of LOD less than or equal to that pair's LOD. Likewise, the value pair
with the greatest LOD value specifies the function value F for all values
of LOD greater than or equal to that pair's LOD.
Since negative values of LOD correspond to magnification and positive
values correspond to minification, the points should have negative LOD
values (although specifying a positive value does not generate an error).
For example, an LOD of -4 corresponds to a magnification by a factor of
2**4, or 16. The default function points are (0,0) and (-4,1).
If the texture magnification filter is GLLINEARDETAILSGIS, then both
the color and the alpha components of T are computed as described in the
equations above. If the filter is GLLINEARDETAILCOLORSGIS, then all
components of T other than alpha are computed as described above, and the
alpha component of T is computed as if the texture magnification filter
were GLLINEAR. Finally, if the filter is GLLINEARDETAILALPHASGIS,
the alpha component of T is computed as described in the equations above,
and all other components of T are computed as if the texture
magnification filter were GLLINEAR.
Page 3
glDetailTexFuncSGIS(3G) OpenGL Reference glDetailTexFuncSGIS(3G)
NOTES
The detail texture itself is specified by calling glTexImage2D with
target set to GLDETAILTEXTURE2DSGIS, level set to 0, border set to 0,
and the other parameters specified to generate the desired image.
As a general rule, avoid using detail texturing if the base texture is
not significantly larger than the detail texture; filtering artifacts can
occur under conditions of high magnification. (For example, it's not a
good idea to use a 256x256 detail texture with a 128x128 base texture.)
Instead, make the base texture larger and incorporate more high-frequency
information in the larger mipmap levels. This is more efficient than
using detail texturing and eliminates some rendering artifacts.
ERRORS
GLINVALIDENUM is generated if target is not GLTEXTURE2D.
GLINVALIDVALUE is generated if n is negative.
GLINVALIDOPERATION is generated if glDetailTexFuncSGIS is executed
between the execution of glBegin and the corresponding execution of
glEnd.
ASSOCIATED GETS
glGetTexParameter, glGetDetailTexFuncSGIS.
MACHINE DEPENDENCIES
On RealityEngine, RealityEngine2, and VTX systems detail texturing may
not be used when rendering to pixmaps.
Detail texturing acts as if the mipmap stack were extended by a number of
levels equal to the absolute value of the GLDETAILTEXTURELEVELSGIS
parameter. The number of normal mipmap levels plus the number of detail
levels must not exceed the maximum number of levels that can be supported
on the hardware. For example, on InfiniteReality systems the maximum
number of levels is 15. A detail texture at level -4 could be supported
on a base texture of size 2K (that is, a base texture with 11 levels) but
not on a base texture that is larger than 2K (one with 12 or more
levels). Failure to observe this constraint causes detail textures to
swim or jitter.
SEE ALSO
glTexImage2D, glTexParameter, glTexSubImage2DEXT.
Page 4