Hello,
does anyone know of a method for applying a function or if-statement component-wise in HLSL (prefered; bonus points if it also/or works in GLSL)?
My example is a function that should allow me to modulate the color of game-sprites, by making them completely white (1.0f), completely black (-1.0f) and lerping everything in between.
float targetValue;
float alpha;
if (target > 0.0f)
{
targetValue = 1.0f;
alpha = target;
}
else
{
targetValue = 0.0f;
alpha = -target;
}
return lerp(value, targetValue, alpha);
That is the base function for a single value, and now I want to have …