Reputation: 21
I pass a 1D array as sampler1D and a 2D array (basically a matrix) as sampler2D to my vertex shader. Everything works fine - i checked the values, every value is where it should be. BUT - I can't seem to multiply two values of those samplers with each other.
float pos=0.0;
vec4 f = texture1D(xk,ki);
vec4 H = texture2D(er,vec2(0,i));
pos=f[0]*H[0];
colorcheck=pos;
I pass colorcheck to my fragment shader, but it won't render my object, instead everything is just black (passing colorcheck=1.0 works fine). I checked both vectors after the lookup - both have valid values in all fields.
I've tried f.x*H.x, and all combinations I can think of.. I even tried multiplying in the fragment shader - won't work either..
EDIT simplified vertex shader (doesnt work either/works when I pass colorcheck=1.0/f.x/H.x.. anything)
uniform sampler1D xk;
uniform sampler2D eigenraum;
varying float colorcheck;
void main(){
vec4 f = texture1D(xk,0);
vec4 H = texture2D(eigenraum,vec2(0,0));
colorcheck=f[0]*H[0];
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
and fragment shader:
varying float colorcheck;
void main()
{
gl_FragColor=vec4(colorcheck,1,1,1.0);
}
Thanks for your help!
EDIT2 - turns out I can't substract/add them either..
Upvotes: 2
Views: 352
Reputation: 35933
I found the solution - it's not in the shader code. I forgot the glActiveTexture call when binding the arrays to the textures!
Upvotes: 2