Hello Guest

Author Topic: How do i lit my sprite? lit...shader doesn't work with my sprite...  (Read 21191 times)

akdhane

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
hi, I was trying to use point light to lit some stuff and scene, but some how all those lit... shaders don't work for me.

Is there specific steps I need  to follow?

I thought it is supposed to be simple changing shader on material...

Using window and regular_Unity (not pro).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How do i lit my sprite? lit...shader doesn't work with my sprite...
« Reply #1 on: October 01, 2012, 11:37:50 pm »
You will need to switch shader to LitBlend/PremulVertexColor depending on if "Premultiplied Alpha" is set in the sprite collection, and then make sure you set "Normal Generation" to "Normals Only" - without normals, lighting won't work properly.

akdhane

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How do i lit my sprite? lit...shader doesn't work with my sprite...
« Reply #2 on: October 02, 2012, 09:06:53 am »
You will need to switch shader to LitBlend/PremulVertexColor depending on if "Premultiplied Alpha" is set in the sprite collection, and then make sure you set "Normal Generation" to "Normals Only" - without normals, lighting won't work properly.
Thank you very much for replay.

and it works perfectly :)

Thank you :)

cworboys

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How do i lit my sprite? lit...shader doesn't work with my sprite...
« Reply #3 on: April 23, 2013, 11:43:34 pm »
Hi there.

I am relatively new to all of this and am trying to set up  the sprites in our game to use Unity's lighting.

The buildings in the background, sidewalk, and street are set up correctly and are using the lighting.  However the other objects in the foreground (fire hydrant and garbage can) are not.  I have checked the settings and they are identical.

I have done the following:

- Set up a directional light and coloured it red (to be able to clearly see which objects are using the lighting)
- Set the shaders for everything to tk2d/LitBlendVertexColor
- Set the settings in the Sprite Collections to:
     - PreMultiplied Alpha: Unchecked
     - Normal Generation: Normals Only
     - Made sure I committed the changes to the Sprite Collection

As far as I can tell, all of the objects are set up identically, yet only some of them are lit by the red light.  Any suggestions?

Also, what is the difference between the LitBlendVertexColor and the LitPremulVertexColor?  As far as I understand you should use LitBlendVertexColor if your sprites have the PreMultiplied Alpha setting unchecked, and use LitPremulVertexColor if you do have it checked.  Is this correct?

I am using 2D2K version 1.9.  Thank you for your time.



Link to image of problem: http://imgur.com/Gkm6Ei7

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How do i lit my sprite? lit...shader doesn't work with my sprite...
« Reply #4 on: April 24, 2013, 10:30:59 am »
1. Those sprites aren't on different layers are they? If the lights were set up to not affect all layers, then it could potentially cause issues.

2. Are you using tk2dCamera? There was a bug in Unitys lighting system which affected tk2dCamera. Bug report filed, and I believe it was fixed in 4.1.2, but I haven't verified it.

3. The shader is set up correctly.

4. Can you switch to a Unity lit shader (eg. Diffuse) to see if it makes any difference?