Simplest way to render image over top of another with another image used as mask in OpenGL?

Posted by Adam Naylor on Game Development See other posts from Game Development or by Adam Naylor
Published on 2013-06-12T09:17:19Z Indexed on 2013/06/24 16:39 UTC
Read the original article Hit count: 243

Filed under:
|
|

The effect I'm looking for is to have a single large background image that is always visible (at full alpha) and then show a second image (what I call a light map or specular map) that is partially shown over the top based on a third image (which is effectively a mask).

The effect is similar to this effect except instead of simply darkening or lightening the background image using the third image it needs to mask the second without effecting the first at all.

The third image is the only one that moves therefore hard baking the third images alpha into the second image isn't an option.

If my explanation isn't clear I'll provide visual examples when I have more time.

I'd prefer not to go down a shader route as I haven't taught myself this area yet so unless I have too I'd rather try to achieve this with simple alpha blending. Happy to use a shader approach.

Cheers.

Additional

These third images are obviously light sources being cast onto the first image showing the specular information from the second image to simulate the light 'shining' off the objects in the first image. The solution I implement will need to allow two light sources to potentially overlap so my current thoughts are that the alpha values of the two images will need to be combined (Added?) to produce a final image which masks the second image?

Don't worry about things like coloured lights. For this technique the lights are all considered white.

© Game Development or respective owner

Related posts about c++

Related posts about opengl