Compositing Fun with Additive Blends!
I’m happy to announce that we’ve added additive blend support to Corona. It’s available starting in Corona daily build #497.
What’s additive blends? It’s a cool way to get glow effects. It’s also known as “Linear Dodge” for the Photoshop buffs among you.
In the rest of this post, I’ll break it down into its gory details with code, math, and pictures.
Whenever you’re doing alpha blends between two different objects, you’re doing compositing. By default, Corona does the standard “normal” blend which is what most of us think intuitively think of when we say blend two objects together, i.e. the painter’s algorithm.
So if you use the following code, which places a transparent PNG on top of a background…
local laser = display.newImage( "blendmode_laser2.png" )
…You’d get:
For the math buffs among you, the equation for normal blends looks like this:
colorFinal = (colorTop)*(alphaTop) + (colorBottom)*(1 – alphaTop)
Now, there are a ton of possible blend modes. Photoshop has around 2 dozen. It turns out that there’s another way to do blends which is incredibly useful. That’s the additive blend mode (a.k.a. linear dodge for you Photoshop types). This blend mode merely adds the pixel values of two overlapping objects on a per-channel basis (up until saturation):
The blending equation here looks (if the sum exceeds saturation, then the channel just takes on the max value):
colorFinal = (colorTop)*(alphaTop) + (colorBottom)
To do this, you just need to set a new “blendMode” property of the display object:
local laser = display.newImage( "blendmode_laser2.png" )
laser.blendMode = "add"
The other value for blendMode is “normal” which is the default.
There are a couple of limitations. This only works on vector and image objects. This does not work on groups. And we’re not supporting fancy things like using masks simultaneously (that will have to wait until we introduce shaders), so your mileage may vary.
Special thanks to Joe Kauffman for sharing some image files for me to use. You can also thank him for guilting me into adding this feature. I know he and several others have been waiting awhile, so I finally found some free time to implement it.


Great news! This is a feature I think everyone’s been waiting for. Can’t wait to try it out.
Yeah! I was waiting for this for quite a while. Can’t wait to check it out.
@Walter
Great work!
Now, that you are warm on graphics, plz also bring the tinting feature to the SDK
This is pretty cool news, been waiting a while for something like this to come along
Are there any performance impacts to changing blending modes? (I assume not but wanted to make sure..)
Fantastic! Any chance of adding a subtractive blend mode with the same restrictions? Seems it should just be a duplication of the additive code, with one slight change:
colorFinal = colorBottom – (colorTop)*(alphaTop)
This could be useful in certain situations where using a black image with normal blend mode is too limiting.
YES!!! The next feature I´d like to see on Corona SDK is 3D rotation for 2D objects, like in After Effects.
This is a very welcome addition for doing effects like explosions.
Where the hell’s X-Pressive?!? Particle Candy needs this update to achieve super awesomeness!!!
Very glad to see this addition!!
Shoop da woop.
Don’t worry -we are back at our office now, so you can expect a blend mode update within the next couple of days.
This is indeed a great feature and a huge step forward -thumbs up! We will also provide samples with the next Particle Candy update to show what cool things you can do using additive blend mode.
Great, this is excellent, but what about ‘SCREEN’ blend modes? I would like to make anaglyphing of images, which requires ‘SCREEN’ mode. I currently use it in Flash for my stereoscopic 3D panorama engine at http://www.3d-360.com and would like to port this to Iphone using Corona (as no Flash…)
You should have sent this out on email. Not to late. Do it, all those that have signed up for Corona info and are designers are gonna want to know about this. Me especially. I only found it today, by accident.