Simple 2D Lighting

I have something fairly similar in a WIP project (nevermind the black pillars, they are just 3D meshes and have nothing to do with the lights).

Here is how I handled it:

  • Make two render targets
  • Render your normal scene to the first one
  • Render your lights to the second one
    • Clear it with black (or your ambient light color)
  • Make a material for your render target quad that uses both render target textures
  • In that material’s fragment shader, blend the two textures however you wish
    • Just multiplying them together is easiest

You can read through this thread and this thread for info on how to set up and use render targets. See here for a simplified step-by-step list of what you need to do in your render script update function to use a render target.

Note: This is basically just a mask, there will be no cast shadows or anything like that

17 Likes