Steps to draw 2D point lit scene with shadows

Started by
0 comments, last by bigbarry 4 years ago

I'm thinking about how I would go about creating a 2D scene that allows for multiple point lights that each cast shadows over a scene that contains objects, exclusively broken down into line segments.

I've found quite a few tutorials online for 2D light and shadows, although there doesn't seem to be a clear consensus with regards to technique. For example, some tutorials suggest using a simplified method of shadow mapping techniques used in 3D shadow drawing, while others use more home baked methods. Some methods also use additive lighting and others use subtractive lighting.

For context I'm using WebGL, but I'm hoping to get a more generalised understanding of how this technique should work.

I have a few questions with regard to the implementation:

  • Should each light have it's own shadow texture, or should every light combine (i.e. blend) together their shadows into one single texture?
  • When generating the geometry that's rendered to the shadow texture(s), would every line segment in the scene (regardless of whether it's completely occluded by a nearer segment) need to be used to compute (on the CPU) the triangle fan that makes up it's shadow?
  • In the final drawing stage, for the main scene (i.e. when drawing the scene with the shadow and light textures) is the idea that the light texture should be dictating the colour and visibility of the underlying sprite texture coordinate, and the corresponding point in the shadow texture just subtracts from that value?

If I'm heading down the wrong path and these questions highlight my lack of understanding I'd appreciate if someone could talk me through the general steps of how I could go about this (in OpenGL/WebGL terms preferably, but any advice would be welcome.)

Thanks

This topic is closed to new replies.

Advertisement