PDA

View Full Version : Fixed function equivalent of simple shader



Stuart McDonald
11-21-2010, 01:50 PM
Hi,
I'm using a 3D seamless texture with a really simple shader that uses a scaled gl_Position to access the texture
varying vec3 position3v;
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
position3v = gl_Vertex.xyz * 0.5;
}

uniform sampler3D TEX3D;
varying vec3 position3v;
void main(void)
{
gl_FragColor = texture(TEX3D, position3v);
}
Is there anyway I can get something similar using fixed function? Basically I want to use the 3D texture to texture my object without having to give texture coords to vertices. I assume I need the glTexGeni routines, but I really can't get my head around them.

Thanks.

mhagain
11-21-2010, 04:11 PM
You don't need texgen for this, just set your texcoord pointer to the same data as your vertex pointer (assuming you're using vertex arrays/VBOs/etc) and do a glScalef (or equivalent) on the texture matrix.

Stuart McDonald
11-23-2010, 01:30 AM
That worked a treat thanks! So obvious, but I would never have thought of it.