In OpenGL GLSL syntax, is there any difference between the components of a vector?
I mean, for a given vec3, the xyzw, rgba and stpq, have any real differences between them or is just a helper?
So if I set a color value into a vec3, I assume that though for making it clear to read I would use the rgba, xyzw would give the same values, right?
In OpenGL GLSL syntax, is there any difference between the components of a vector?
Share
Actually, I am not certain how it is implemented, but I think it might be some sort of a union, in which case writing to one and reading from the other is not guaranteed to work.
EDIT: The above comment holds for unions in general (C/C++), however the case in GLSL might be different. The link: http://www.opengl.org/wiki/GLSL_Types#Swizzling states that:
“You can use xyzw, rgba (for colors), or stpq (for texture coordinates). These three sets have no actual difference; they’re just syntactic sugar.”
So as @tito mentioned in the comment, it is just syntatic sugar, and can be mixed. (although not mixed in a single call, for instance xyga is not valid)