2D Toolkit Forum

2D Toolkit => Support => Topic started by: Neeko on April 12, 2015, 11:20:03 pm

Title: Some sprites not being lit by directional light
Post by: Neeko on April 12, 2015, 11:20:03 pm
I'm having an odd issue with some sprites in a scene not reacting to a directional light (they appear as if there's no light in the scene), yet a duplicate of the same sprite will be lit just fine.

(http://chattypics.com/files/CapturePNG_p2c1mc5xc5.png)

As you can see, the tombstone and background silhouette sprites on the left are being lit, but the same (duplicate) sprites on the right are not. Their settings are exactly the same, minus transform position.

Any ideas on why this would be occurring? I can confirm that the sprite is setup properly, generating normals, and with the proper shader. I'm using latest version of both Unity and tk2d (2.5.1).
Title: Re: Some sprites not being lit by directional light
Post by: unikronsoftware on April 12, 2015, 11:29:03 pm
No idea, but try switching to a default Unity shader & remove the texture to try and make out whats going on there. It almost looks like its missing normals but can't say for certain.
Title: Re: Some sprites not being lit by directional light
Post by: Neeko on April 13, 2015, 12:01:03 am
So the sprite the looks like it's missing normals was rotated 180 degrees along the y-axis (to mirror its neighboring sprite). I reset the rotation of the sprite to 0, and it was being lit again.

So I'm guessing normals are generated for just the one side? Is there a way to generate normals for both sides of a sprite or am I going to have to explicitly provide a separate sprite now for sprites I want to rotate?
Title: Re: Some sprites not being lit by directional light
Post by: Neeko on April 13, 2015, 12:13:49 am
Never mind, just realized I can flip the sprites scale on the x axis through the tk2dSprite script to achieve the same thing.

I do have some sprites that I rotate through Transform.Rotate, which will have the same issue of not having normals generated on one side though, but I have a feeling that there's not much I can do about that.
Title: Re: Some sprites not being lit by directional light
Post by: unikronsoftware on April 13, 2015, 12:18:16 am
You could create a shader that lights the front and the back differently. The problem is the tk2d shader is 2 sided, but there are only one set of normals (for the front). So its effectively being lit on the back.