Is there a way to dynamically chose which vector component to use? ie. code alternative 1 vs. alternative 2.
I have a function that does swizzling on a char4 depending on a value. I calculate the different components to use (i.xyzw) and would like to write something like the //swizzling part.
uint i, j; uint2 m; //alternative 1 if (i==0) j = m.s0; else j = m.s1; //alternative 2 j = m.s[i]; or j = m[i]; uchar4 obj; uint4 i; //swizzle obj = obj.s[i.x][i.y][i.z][i.w]; or obj = (uchar4)(obj[i.x],obj[i.y],obj[i.z],obj[i.w]);