2D Toolkit Forum

2D Toolkit => Support => Topic started by: deathbypixel on November 26, 2012, 10:04:50 pm

Title: Tilemap affected by light
Post by: deathbypixel 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!

Title: Re: Tilemap affected by light
Post by: unikronsoftware 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
Title: Re: Tilemap affected by light
Post by: deathbypixel on November 27, 2012, 08:20:33 pm
Thanks, worked perfectly! Note that this was in k2dTileMapMeshBuilder.cs

How will this affect performance?
Title: Re: Tilemap affected by light
Post by: unikronsoftware 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.