PDA

View Full Version : texture coordinates generation



Sagrailo
04-01-2008, 03:36 AM
I need to have texture coordination generated for each vertex of given object, so that vector of texture coordinates is equal to the vector of vertex coordinates themselves, only normalized (ie. texture coordinates are calculated through projecting vertex to sphere with unit radius). Any suggestion on how best to accomplish this: is any of glTexGen() variations usable here, or the only alternative is to calculate texture coordinates manually, from corresponding vertex coordinates?

Thanks.

k_szczech
04-01-2008, 06:15 AM
glTexGen won't help with this. You must either use vertex shader or precompute texture coordinates at application startup.

-NiCo-
04-01-2008, 07:56 AM
You can use texgen in an object linear setup with
s_plane -> 1 0 0 0
t_plane -> 0 1 0 0
r_plane -> 0 0 1 0
q_plane -> 0 0 0 1

and then use these coordinates to sample a cube texture. This way the normalization is implied in the texture lookup.

Otherwise I would suggest using shaders, which makes it a whole lot easier.