float4 color = tex2D(inputSampler, TexCoord);
//compute distance from center
float distance = color.a>0.3f?length(TexCoord - 0.5f):1.0f;
What is color.a> and why is there a ; in the middle of that second line?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Response to the original question: “Can someone tell me what this snippet of HLSL code means?
what is color.a> and why is there a ; in the middle of that second line?”
Its a html escape sequence screwup.
>should be>(“greater than” symbol).So it should be:
Likewise if you encounter
<it is probably<(“less than” symbol). Other common ones ones are:"-> ‘"‘&-> ‘&‘ -> ‘ ‘ (space)What the pixel shader is actually doing is if the alpha of the sampled texture at this point is greater than
0.3,distanceis the length from the sampled texcoord (U,V) location to (0.5, 0.5) i.e. the center of the texture sampled from. If the alpha is0.3or less, thendistanceis set to1.0f.The distance value is obviously used later in the shader to apply some pixel effect.