Hello Guest

Author Topic: Tilemap affected by light  (Read 5336 times)

deathbypixel

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Tilemap affected by light
« on: November 26, 2012, 10:04:50 pm »
Hello and thanks for a fantastic product!

I have created a tile map in a scene (I'm using a perspective camera) and I'm wondering what approach I should use to get my tiles affected by light, e.g. with a spotlight.

Cheers!


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Tilemap affected by light
« Reply #1 on: November 26, 2012, 11:29:26 pm »
You will need normals for this to work...
in tk2dTileMap.cs, line 132, comment this out so it reads:

Code: [Select]
// if (tileMap.serializeRenderData)
chunk.mesh.RecalculateNormals();

Now you should be able to just switch to a lit shader and lights should work

deathbypixel

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Tilemap affected by light
« Reply #2 on: November 27, 2012, 08:20:33 pm »
Thanks, worked perfectly! Note that this was in k2dTileMapMeshBuilder.cs

How will this affect performance?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Tilemap affected by light
« Reply #3 on: November 27, 2012, 10:41:04 pm »
Shouldn't be any worse. It takes longer to actually build the tilemap, but if you're not modifying it at runtime, you shouldn't need to care.