OK, so what use is SHADEBLEND?

BlitzMax Forums/BlitzMax Programming/OK, so what use is SHADEBLEND?

GfK(Posted 2013) [#1]
I've never used it.

Just now, curiosity got the better of me, and I had a play around with it. Still not much wiser. Has anybody ever actually used it to good effect?


Richard Betson(Posted 2013) [#2]
Hi,

I use it for shadows in Phoenix USC. :D I have also used it for 2D lighting FX.

- Rich -


GfK(Posted 2013) [#3]
Got any examples? Code/screens/video?


TomToad(Posted 2013) [#4]
Here is an example of lighting a portion of a cave using shadeblend
http://blitzbasic.com/Community/posts.php?topic=79703#894889


GfK(Posted 2013) [#5]
Ahhhhh!! :)

I was always under the impression that it was used in a similar way to LightBlend, and it really isn't. That explains why everything I ever tried with ShadeBlend looks like crap!

Thanks for the info.


TomToad(Posted 2013) [#6]
ShadeBlend will multiply the pixel values together. The values are in the range of 0.0 to 1.0. My example above simply uses white (1.0, 1.0, 1.0) anywhere you want pixels to show and black (0.0, 0.0, 0.0) anywhere you don't want pixels to show. You can "shade" a portion by using other values, for example 0.5, 0.5, 0.5 will result in a pixel half as bright, 0.5, 1.0, 1.0 would result in dimming red while leaving the other color channels alone.

Of course, BlitzMax expects ints of 0 to 255 instead of floats, so you would need to convert when referring to pixels directly
PixelInt:Int = PixelFloat * 255
PixelFloat:Float = PixelInt/255.0

Here is a sample program which illustrates ShadeBlend.



ImaginaryHuman(Posted 2013) [#7]
It's just a multiply. Combined with white it does nothing. Combined with a darker color it scales the colors down.