Malii
Malii

Reputation: 448

OpenGL Similar to multiply effect for lighting

So I'm working on a game and I'm wondering how I would achieve a similar effect to multiply in photoshop but in OpenGL. Too explain it better I have attached some images showing the steps that it would go through.

So to start with I have my image, which I render normally.

enter image description here

I then draw a black screen over it all.

Then I have my lights image, these are just white gradients.

enter image description here

After that I apply my multiply effect in photoshop:

enter image description here

How would I go about achieving the same effect but in opengl?

The lights would also have to blend together.

It doesn't matter how the effect was created in photoshop however, as long as I can create the same ending result.

I'm using LWJGL.

Upvotes: 0

Views: 555

Answers (1)

Tim
Tim

Reputation: 35943

  1. Draw the light image to the screen.
  2. Enable blending with function glBlendFunc(GL_DST_COLOR, GL_ZERO)
  3. Draw your other objects to the screen.

The resulting fragments drawn will be the multiplied value of the background (light) and incoming objects (quads).

Upvotes: 1

Related Questions