How can I make a glow stay the same color against the background, even though I am using additive blending?
I am using openGL and programming on an iPhone.
I am rendering a glowing 'beam' on top of my game scene. I am using a few textures with additive blending to make the glow effect. If the beam is rendered on a pure black background, the beam will look exactly how I want it, however, when the beam is rendered on my ever chang开发者_如何学JAVAing game, it blends with the colors behind it.
Currently, this is my only idea:
1) Render the beam to a texture and draw the texture on the background using normal blending.
Problems - The texture will always be opaque (black is my glClear color). I do not yet know how to remove all of the black from the texture I rendered to.
Any suggestions?
You could render to an texture with alpha channel and blend that. But this will again change your beam's appearance. Blending will always introduce some change in appearance, you can't get around this.
The blending formula is
Destination = Incoming * Incoming_Blend_Factor + Original * Original_Blend_Factor
If you want your colour to be the same this equates to
Destination = Incoming
which, by comparision of coefficients is
Destination = Incoming * 1 + Original * 0
I.e. by not blending at all.
As an exercise I give you the following: In Photoshop or GIMP but some background image into the background layer and your beam into a layer on top of it. Then try to get the result you desire by tinkering with the available blend modes.
精彩评论