about env-mapping and spherical one


when i coded usign my software renderer i use to have a trick for env-mapping that was taking the normal x/y componets (in eye space) and transform them from the [-1 1] range to [0 1] (val*0.5 + 0.5).

i’m tring to do the same under opengl, but with texGen-SPHERICAL_MAP i don’t get the desired results and i’d like to use my old algorithm. is there a way to specify in TexGen( EYE_SPACE ), that i want to use the NORMAL instead of the VERTEX? then i could adjust the TEXTURE_MATRIX to transform the range

i want to do something like this (in eye_space):
tex.s = (normal*{1 0 0})0.5 + 0.5;
tex.t = (normal
{0 1 0})*0.5 + 0.5;

and i like sth like this with opengl:
(ok, this is pseudo-GL, a bit faster to write)


glLoadMatrixfv( TEXTURE_MATRIX
[0.5 0 0 0 .5]
[0 0.5 0 0.5]
[0 0 0 0]
[0 0 0 0]


If you have a up-to-date Nvidia graphics card.You can just use their extension NV_texgen_reflection

The following is the overview part copied
from http://oss.sgi.com/projects/ogl-sample/registry/NV/texgen_reflection.txt
This extension provides two new texture coordinate generation modes
that are useful texture-based lighting and environment mapping.
The reflection map mode generates texture coordinates (s,t,r)
matching the vertex’s eye-space reflection vector. The reflection
map mode is useful for environment mapping without the singularity
inherent in sphere mapping. The normal map mode generates texture
coordinates (s,t,r) matching the vertex’s transformed eye-space
normal. The normal map mode is useful for sophisticated cube map
texturing-based diffuse lighting models.