Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tell me about Additive Blending

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st Jan 2015 15:25
What does additive blending do exactly?

SetSpriteTransparency( iSpriteIndex, mode )

mode - The transparency mode for this sprite, 0=off, 1=alpha transparency, 2=additive blending


I put additive blending on a solid blue square.
On a black background it looked identical.
On another colour it created brighter colours (e.g Blue + Amber = brighter yellow)
I sort of understand this bit.

If I remove the solid blue square, it returns to black, the underlying colour.

But if I remove a semi-transparent square, the background is "tattooed" with the sprite that was there previously.

What is happening, I want to work out how to take advantage of this property?

Quidquid latine dictum sit, altum sonatur
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Jan 2015 15:51
Quote: "But if I remove a semi-transparent square, the background is "tattooed" with the sprite that was there previously."

Not quite sure what you mean but that sounds like a bug to me. The additive sprite should not permanently change the appearance of other sprites. Are you perhaps not clearing the backbuffer?

Additive blend is where the colour of the sprite is added to the sprite/s below when it is drawn, basically it's a sprite shader. You should use black for transparent rather than using an alpha value of less than 255. For example if you want to use an existing transparent sprite with additive blend just paste it onto a black background in a new image.

Maybe some example code of this tattooing effect?


Using AppGameKit V2 Tier 1
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Feb 2015 10:05
Thanks baxslash. It took me a while to extract the example with the error, but I got there in the end. The key was fading out the sprite.

I think I understand it now. As I fade out the sprite, it is adding the previous frame, therefore it is counteracting itself. As a result, even a 100% transparent sprite is 100% opaque as it keeps adding the previous incarnation.

Here's the example code, I appreciate you confirming whether or not my interpretation of what is happening is correct. The left sprite is "normal", the right sprite uses additive blending. They are being faded out with a tween.



Quidquid latine dictum sit, altum sonatur

Login to post a reply

Server time is: 2024-05-26 03:49:33
Your offset time is: 2024-05-26 03:49:33