1

I am making a 2d game in the perspective of Terraria/Starbound. I want the lighting to look similar to this: enter image description here

Ive tried to get lighting like this by adding a material on all the sprites in my game and then giving them a sprite diffuse shader. Then I made a point light wherever I needed light. There where two problems with this though: 1) Where the light was most intense, it was draining the color of a sprite and made it lighter. 2) I noticed a big FPS drop (And I only had 1 point light!).

Is there any way of achieving lighting like this without having to write my own lighting engine? Ive search the asset store and Ive searched to see if unity has any way of handing 2D lighting from this angle but I have found nothing.

If I do have to write my own lighting engine, would that be to complex for someone who is relatively new to unity and has only had ~ 8 months experience?

Umair M
  • 10,298
  • 6
  • 42
  • 74
user3738071
  • 199
  • 5
  • 15

2 Answers2

1

Assume you are using tile map.

You need to have a field of view map, which can be achieved by reading this: http://www.redblobgames.com/articles/visibility/

Using such map, you know exactly the color tinting for each tile. Now, just blend the color to the SpriteRenderer of every tile on the map.

Somebody already created a line of sight plugin: http://forum.unity3d.com/threads/light-of-sight-2d-dynamic-lighting-open-source.295968/

0

Here's my hacky solution on GitHub

  1. There's 2 cameras.
  2. Empty tiles on the tilemap are filled in with white blocks (only one camera renders this)
  3. A gaussian blur is applied to the camera rendering the white blocks
  4. Then, blend the two cameras, darkening everything not covered by the white blur.
  5. You can adjust the "light" penetration by changing the white tile's sprite's Pixels Per Unit.