Question

This code will work fine in HLSL ps_2_0 but will not compile in ps_3_0. If I replace the variable with true it will compile. Does anyone know how to do this?

float4 setBoolToFloat(bool input)
{
    float4 output;
    output.xyzw = (input) ? 1.0f : 0.0f;
    return output;
}
Was it helpful?

Solution

Not sure why this worked but when I moved the three lines of code to the location where setBoolToFloat was originally called the error went away. I'm only calling this function in a couple of places so I'm not going to try and spend more time trying to make it work. I'd like to know why it didn't but I'll just live with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top