What's the correct way to downcast a float4 into a float3 discarding the .w component, pls?

float4 b;

1. float3 a = as_float3(b); //this should be ok

2. float3 a = (float3)b; //I'm not sure about this

3. float3 a = (float3)(b.x,b.y,b.z); //obviously ok, but I want it simpler.

Thanks.

Btw, it's the #2 option legal? Just by curiosity.

Option #2 is not legal as per the spec.

Ok, thanks, all is clear now.

you can also do:

float 3 a = b.xyz;

float 3 a = b.s012; // 1st, 2nd + 3nd terms (can use hex digit 0..F)

float 3 a = c.s7f3; // 8th, 16th, 4rd term

or swizzle/duplicate the terms:

a = b.yzx;

a = b.xxz;

There's lots of examples of valid/invalid cases in the 1.1 spec in section 6.1.7