I created a simple graphics program using DirectX 12 for learning purpose. I heard that using If statements in the shader code is not good for performance. However i couldn't wrap my head around how to achieve the effect on the attached image without using if statements.
Here is my code:
float4 WaterPixelShader(PixelInput _in) : SV_Target
{
float heigth = _in.worldPosition.y / 10;
float white;
if (heigth > 0.7)
{
white = 1;
}
else
{
white = 0;
}
return float4(white, white, heigth, 1);
}
This is the effect I am trying to achieve: