2D lighting not working on tilemap

I got 2D lighting working on my sprites using the tutorial below

But the lights seem to have no effect on tilemaps (walls and floors in my case), even though it’s targeting all sorting layers

How can I get 2D lights to affect tilemaps?

I haven’t watched the video. Do the sprites you use on your tilemaps and your tilemaps renderers have a material with normal maps?

1 Like

Here are screenshots of both in the inspector

Your tilemaps has the “sprite-default” material. Being 2D it cannot react to light.

Are you sure they don’t mention that in the tutorial you are following?

https://www.youtube.com/watch?v=kzJ5QIy-klM

2 Likes

That’s definitely the issue as all other objects are using Sprite-Lit-Default. However, tilemaps do not allow me to select Sprite-Lit-Default as the material, only Sprites-Default?

The video I just posted is about adding custom materials to sprites; it’s the same process for tilemaps.

Excellent, thanks! I have one more issue if you don’t mind.

The point light appears in the Scene view, but doesn’t appear in the Game

Why could this be?

1 Like

I had the same issue, setting the light to 0 on the Z (same as the sprites) made it work in game. Weird that it would display at any Z in the scene view but not in game.

in my case, I set the Z position of its transform really high (500+) and works.

That was it!

Here are the precise steps I went through to set up my TileMap with lighting. I had to fumble a bit, and thought to post in case it helps someone else.

  1. Find Sprite-Lit-Default Material in your Packages folder (you must have installed the 2D lighting package). Packages > Lightweight RP > Runtime > Materials > Sprite-Lit-Default. You can create a custom material and add the Lightweight RP shader if you prefer. Packages > Lightweight RP > Runtime > Shaders > 2D > Sprite-Lit-Default, and then you would drag this shader onto your custom shader. If these paths change in the future you can navigate there by selecting something with the Sprite-Lit-Default material on it (if none in the scene drag a new sprite in and it will auto have it) and click on the material in the Renderer.
  2. Click on your TileMap and replace the Default Sprite material with Sprite-Lit-Default Material.
  3. If everything works your TileMap will turn black.
5 Likes