View Full Version : vector multiplication

07-02-2010, 12:12 PM

I saw in some places the following code snippet in the Fragment shader.
"uniform sampler2D s_tex0;
varying vec2 v_texCoord;
varying vec4 v_primaryColor;
void main()
gl_FragColor = texture2D(s_tex0, v_texCoord) * v_primaryColor;

In the main() function, since the build-in function texture2D returns a vec4, is that legal for two vec4s to do a multiplication like that? What's the result of vec4_foo * vec4_bar? A cross multiplication?

Thanks a lot.


07-02-2010, 03:16 PM
I think I found the answer. In the spec 5.9, it is said " Multiply (*) applied to two vectors yields a component-wise multiply". Thanks for reading.