vec datatypes

edited April 2014 in GLSL / Shaders
varying vec4 vertTexCoord;

vertTexCoord is of type vec4. I have seen access to it with .s, .t, .st, .r, .g, .b, .a.

Where does s and t and st stand for? And when does it have what?

Answers

  • It's a single vector with four numbers in it. It's usually used for position, .x, .y, .z, .w, or for color, .r, .g, .b, .a, or for texture coordinates, .s, .t, .p, .q. There's no difference between .x, .r, and .s - they're all fancy ways of refering to the "first" number in this vector.

    .st is itself a vector, containing the .s and .t parts. This is a fancy way of accessing values in it, which is apparently called Swizzling.

    https://www.opengl.org/wiki/Data_Type_(GLSL)

    Check section 1.2.1.

Sign In or Register to comment.