Hi this is a simple question.
I'm trying to read and understand a shader function which makes use of vec3<f32> variable types.
I don't understand what is that .zzzz key for:
var myvar: vec3<f32> = vec3<f32>(1.3, 3.3, 3.3);
myvar.zzzz; // ??
myvar.xy; // ??
I can only understand myvar.x, myvar.y, myvar.z, but what happens when you combine or repeat those keys?
I can't yet find it in the official documentation unfortunately.
Thanks
This is a swizzle, also called convenience letterings in the spec. The spec section 7.7.1 says:
There are letterings for
x,y,z,wandr,g,b,a. (Note, they can not be mixed.)So
zzzzmeans make avec4initialized with thezcomponent in each spot. Thexymeans make avec2initialized with thexandycomponents.