dependant texture problems ARB_fragment_program

Hi, im pretty new to GL, and im having trouble using dependant texture reads in a ARB_fragment_shader. i would imagine that my code should produce something, but currently it dosent produce any artifacts on the screen.

I have simplified my program to try and texture one polygon that is passed into the card with tex coords to carry out a lookup on a 3d texture, the result of this 3d texture read i want to use in another lookup for colouring.

The data i’m intrested in is encoded in the 3d textures red channel, from this i want the red channels value to be used in a 1D texture lookup to get a RGBA quadruple for the final fragment colour.

Im unsure if my shader code is incorrect, or the way i manipulate the ogl state?

Im using a GeForceFX card
SHADER CODE

!!ARBfp1.0
TEMP R0;
TEX R0, fragment.texcoord[0], texture[0], 3D;
TEX result.color, R0.x, texture[1], 1D;
END

DRAW CODE

glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_VERTEX_PROGRAM_ARB);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, vrVertexShader);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, vrFragmentShader);
glEnable(GL_TEXTURE_3D);
glBindTexture(GL_TEXTURE_3D, texName[0]);
glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, texName[1]);
glCallList(vrSliceGeometryList);
glDisable(GL_VERTEX_PROGRAM_ARB);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
glFlush ();

could it be the way i specify the texture, or have i done something wrong in the draw proc, or maybe the shader, or maybe my state is setup wrong ??

any help would be greatly appreciated!!

You have to select the active texture stage before binding a (multi)texture:

glActiveTextureARB(GL_TEXTURE0_ARB);glBindTexture(GL_TEXTURE_3D, texName[0]);
glActiveTextureARB(GL_TEXTURE1_ARB);glBindTexture(GL_TEXTURE_1D, texName[1]);

You do not need the “glEnable(GL_TEXTURE_nD)” calls when using ARB or NV fragment programs.

The rest of your code looks fine …

Klaus

Thanks Klaus, that worked a treat, I thought it would be something simple like that, but being new to GL, i didint know where i could get the documentation for such things !!

Thanks again

No problem. IMHO the newest OpenGL Redbook covering OpenGL 1.4 is all you need: http://www.opengl.org/documentation/red_book_1.0/

And, of course, the OpenGL Extension Registry (although sometimes hard to read): http://oss.sgi.com/projects/ogl-sample/registry/

Have fun with OpenGL,
Klaus