Hello Guest

Author Topic: Question about lighting  (Read 7780 times)

MyNameIsDonovan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Question about lighting
« on: July 01, 2013, 04:04:08 am »
So im really new to Unity and 2Dtk and I have a question about lighting.
I was hoping that I could use a point light to illuminate my sprites (in game they would be torches), but can seem to get them to do anything.
The only thing that looks like it does something is a directional light, but it only illuminates half of my sprites, and if I try make it perpendicular to my sprite, it doesn't illuminate anything :(
Can someone point me in the right direction?

profanicus

  • 2D Toolkit
  • Full Member
  • *
  • Posts: 167
    • View Profile
Re: Question about lighting
« Reply #1 on: July 01, 2013, 06:10:36 am »
You need to make sure your sprites have normals (SpriteCollection/Settings/Normal Generation), and that you use one of the lit shaders.

MyNameIsDonovan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Question about lighting
« Reply #2 on: July 01, 2013, 03:31:33 pm »
Thanks for the reply profanicus! I'll check that out when I get home from work.

MyNameIsDonovan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Question about lighting
« Reply #3 on: July 02, 2013, 02:29:39 am »
Sigh, im still having issues.
I went to sprite collection/settings/Normal Generation and have Normals Only Seleceted.
Right now I have litBlendVertexColor selected as the shader.

Ive attached a screenshot of what I am getting. Maybe that would shed some light on what im doing wrong :/

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Question about lighting
« Reply #4 on: July 02, 2013, 10:28:37 am »
Are you using the tk2dCamera?
If you are, this might be the bug in Unity where lighting is broken with custom projection matrices (i.e. like the one the tk2dCamera uses...). First thing to do is disable the tk2dCamera, create a normal perspective camera and then move it back - does it look lit in game view now?

A bug was filed with Unity back in Feb, and apparently they're fixing it. Its an issue in Unity 4.x but not in 3.x. If this issue affects you there are a few workarounds.

MyNameIsDonovan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Question about lighting
« Reply #5 on: July 02, 2013, 03:04:31 pm »
Thanks for the reply unikron :D

I am using the tk2dCamera.
You were right, I created a normal perspective camera and objects appear lit in the game view.

What kind of workarounds are there? Or would it be better to just use Unity 3.5.7 for now?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Question about lighting
« Reply #6 on: July 02, 2013, 03:36:41 pm »
You could simply not use the tk2dCamera, and use a normal ortho camera instead?

MyNameIsDonovan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Question about lighting
« Reply #7 on: July 02, 2013, 03:40:32 pm »
Aweee but I love the 2dtkcamera!
Haha, yeah thats probably what i'll do for now. Thanks unikron

MyNameIsDonovan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Question about lighting
« Reply #8 on: July 03, 2013, 02:21:34 am »
Switching to a normal ortho is working out for me.
I had a couple of questions other questions about getting rid of these thin gaps in my tilemap and getting the tilemap to light up, but found the answers :D
In case there are any other newbies like myself running into the same errors!
fix thin gaps ->http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,294.0.html
tilemap lit (thirdpost)->http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1080.msg5137.html#msg5137

The community here seems really nice and helpful!
Thanks again unikron