I have encountered a weird x.wwww
component of the float4 x
vector in a HLSL code. I haven't seen such a member or member function of float4 structures in HLSL, so please tell me what is the meaning of that. It is in the code of this pixel shader:
float4 PSConstantColor( PS_PARTICLE_INPUT input ) : SV_TARGET
{
// Sample particle texture
float4 vColor = g_baseTexture.Sample( g_samLinear, input.Tex ).wwww;
// Clip fully transparent pixels
clip( vColor.a - 1.0/255.0 );
// Return color
return vColor;
}
At first I thought it should be the w
component replicated to all the members of the float4 vColor
vector, but it does not make sense for the color value, does it?
wwww
swizzle operator, as you said, it does not show it as a part of float4 structure. Other operators you mentioned (xyz
,zxy
etc.) are clearly explained but non ofwwww
is present. I searched here: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509634(v=vs.85).aspx but found nothing about it. – Pekov Jun 24 '15 at 12:24colour = sample.aaaa
(or equivalently,sample.wwww
) to "broadcast" the luma component (stored in the alpha channel) to all colour channels as a first step, and then add the Co & Cg chroma offsets to each of r, g, and b in subsequent steps, to tint the initial grey to the desired output colour. – DMGregory Jun 24 '15 at 16:33