Skip to main content
gamedev.net
🔒 Locked

Crossfading

Started by Xtremehobo 1 reply 300+ views
Original Post
Xtremehobo
Xtremehobo
Heya, I must be having a brainfart or something because I''ve spent all day coding this little lighting control program with 40 or so different sliders (20 for each "scene" mode) and one big one to crossfade between each "scene". Basically heres what I want to know how to do (a simple algorighm would be nice ) I have two values, Value1, and Value2. Both can be between 0-255. I then have a CrossfadeValue, which also is between 0 and 255. How can I combine Value1 and Value2, using CrossfadeValue to modulate them, to create a FinalValue? It should work somewhat like this: If: value1=255 value2=0 crossfadevalue=128, FinalValue should = 128. If: Value1=100 value2=0 crossfadevalue=255, FinalValue should = 100. Get the drift? Any help would be greatly appricated with this! Thanks and Best Regards, Matt Carpenter
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
Xtremehobo
Xtremehobo
quote:
Original post by VertexNormal
Can you do linear interpolation?

t=Crossfade / 255.0
FinalValue = Value1*t + Value2*(1-t)



That seems to do the trick!

Thanks
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.