2
\$\begingroup\$

I have a simple question. what are the meaning of :

half4 myHalf;
myHalf.yyyy;
myHalf.xxzz;
// or
myHalf.yw

Thanks a lot !

\$\endgroup\$
4
\$\begingroup\$

It's a simple answer! half4 is a four component vector, using half precision floating point coordinates. The extensions you've shown are quick ways to create new vectors using the values from myHalf.

myHalf.yyyy is a four component vector with the values: (myhalf.y, myhalf.y, myhalf.y, myhalf.y)

myHalf.xxzz is a four component vector with the values: (myhalf.x, myhalf.x, myhalf.z, myhalf.z)

myHalf.yw is a two component vector with the values: (myhalf.y, myhalf.w).

\$\endgroup\$
  • 1
    \$\begingroup\$ This is also referring to as "swizzling". \$\endgroup\$ – Josh Jul 2 '13 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.