Code: Select all
fixed4 c;
if (IN.worldPos.y < _Y2)
c = _Color2;
else if (IN.worldPos.y > _Y1)
c = _Color1;
else
{
c = lerp(_Color1, _Color2, (IN.worldPos.y - _Y1) / (_Y2 - _Y1));
}Is this really the case or am I wrong?
Code: Select all
fixed4 c;
if (IN.worldPos.y < _Y2)
c = _Color2;
else if (IN.worldPos.y > _Y1)
c = _Color1;
else
{
c = lerp(_Color1, _Color2, (IN.worldPos.y - _Y1) / (_Y2 - _Y1));
}Lol, programmer! Hey!wazzcob wrote: ↑Thu Jun 03, 2021 11:29 am Help with writing shader code like this:
And yes, by the way, I've come across rumors that if-else constructs in shaders are not correct.Code: Select all
fixed4 c; if (IN.worldPos.y < _Y2) c = _Color2; else if (IN.worldPos.y > _Y1) c = _Color1; else { c = lerp(_Color1, _Color2, (IN.worldPos.y - _Y1) / (_Y2 - _Y1)); }
Is this really the case or am I wrong?