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
,w
andr
,g
,b
,a
. (Note, they can not be mixed.)So
zzzz
means make avec4
initialized with thez
component in each spot. Thexy
means make avec2
initialized with thex
andy
components.