Fragment shader tint and fade

Started by
-1 comments, last by noodleBowl 9 years, 2 months ago

I'm in the middle of working on some fragment shaders of mine.

And I wanted to add an effect where my sprites would fade out over time. Currently, I do this by normalizing the max lifespan of the fade with the current amount left in the fades lifespan. It works, but I was wondering how could I have a 'fade factor'?

Basically something that says if the value is 1 the sprite fades at a normal rate. If its 2, double the speed of the fade for sprite. If its lower then 1, then make the fade slower than normal

Current fragment Shader:


//fadeout over time effect for sprites
out vec4 color;
uniform vec2 lifespan;
 
void main()
{
     color = vec4(1, 0, 0, (lifespan.x, lifespan.y));
}

My second question is that how could I do tinting for images?
I am wondering about tinting for the entire image where the alpha channel is excluded.
Also tinting where only certain areas of the image are considered. Much like how terraria had the different colors of hair and they where all the same style and just different shades of color

This topic is closed to new replies.

Advertisement