how to use cg with textures in vertex and fragment shader?

hello,

im using cg v1.41 with geforce7800gtx graphics card.

i need to do texture lookups in the vertex and the fragment shader to different textures.

i use 1 vertex texture and 2 fragment textures.

as im doing now, it seems, that the fragment texture is overwriting the vertex texture!!??

here is the cg-compiler output for the vertex texture:
#var sampler2D vertexTexture : : texunit 0 : 12 : 1

and the output for the fragment textures:
#var sampler2D fragmentTexture0 : : texunit 0 : 11 : 1
#var sampler2D fragmentTexture1 : : texunit 1 : 12 : 1

can someone explain to me, what im doing wrong?

should i somehow compile the programs together or say, that texunit 0 is already in use?

thanks a lot,
chris

You can use semantics to specify which texture unit a particular uniform sampler is bound to. Like so:

float4 frag( uniform sampler2D texture  : TEXUNIT0,
             uniform sampler2D texture2 : TEXUNIT1,
             etc... )

BTW, you can not compile multiple programs together so you will need to be sure the uniforms are allocated to the correct texture units yourself (as shown above) since the compiler has no way of knowing anything about your other programs.

-SirKnight

thanks SirKnight!

i forgot to specify the binding semantics, so the fragment program compiler cannot know, that the vertex program was compiled with accessing the texture in texunit0. now it works!

chris