hi, I’ve got a problem when runnging a Cg (v1.4) vertex shader doing a texture lookup (32f, GL_NEAREST - runs HW-accelerated) and a fragment shader which is doing a lookup into another texture. It seems that the fragment shader does a lookup into the texture which was bound to the vertex shader.
So my question:
is it possible to do texture lookups into different textures in a vertex and fragment shader in one render pass?
In my Cg code I didn’t set the TEXUNITS for both textures (Cg doesn’t require this) - I just bound the one textureid to the vertex, the other to the fragment shader. Does anyone know if it might work if I set the TEXUNITS? Or maybe with GLSL
ok, I can give you more details:
(my HW is a GF 6800 Ultra AGP, driver: 81.98)
I need to do a 2D displacement for every pixel. therefore I render a GL_POINT at every pixel location with approprialte texture coordinates. then the vertex shader does a lookup into a texture GL_TEXTURE_2D NPOT with display res. this texture stores a new location for that point…the shader looks like this:
but that didn’t work - the result was an image textured with the looup texture from the vertex shader. I did a workaround and used the fragment shader to encode the displaced texcoords into the RG channels and rendered this into and 32f FBO - doing the image lookup in another render pass…but well…this doesn’t seem to be the most efficent way to me…
my pick would be to do: “uniform sampler2D image : TEXUNIT1” and the other TEXUNIT0 for the vertexshader…
you should add those : TEXUNITx things,else Cg doesnt know which texture you want to use… unless you use the cgruntime to the binding, which I never used so far, always bind with gl…
maybe that does the trick, however I havent used any vertex texture fetches yet, so pure guessing here
If you don’t specify which texture unit a sampler is bound to (either in the shader or through the runtime), then the compiler will choose resources for you. Since you have a vertex and fragment shader (note they are separate shaders) the compiler is auto assigning TEXUNIT0 to the sampler in each shader.