Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 16874

Component-wise function/if-statement

$
0
0

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 …


Viewing all articles
Browse latest Browse all 16874

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>