Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Lighting skipped on scaled sprites within range

Discussion in '2D' started by IndreamsStudios, Feb 9, 2014.

  1. IndreamsStudios

    IndreamsStudios

    Joined:
    Jun 4, 2013
    Posts:
    9
    Hi, I've been looking into lighting of sprites, and I noticed today that sprites don't always get lit when they are in range if the sprite is scaled.

    I've made a test scene that looks like this: http://i.imgur.com/DRQYv15.png

    The point light in the center has a range of 10, and is located at the origin. On the left are two front-facing quads with scale (4,4,1) at Z=3 using the Default-Diffuse material. The inner one is at X=-2.4, and the outer one is at X=3.

    Mirrored on the right side are two sprites, using a material with Sprites/Diffuse. The outer one should be lit identically to the outer quad, but instead it only receives ambient light.

    Changing the pixel light count in QualitySettings to zero does not cause the outer sprite to be vertex-lit (though the other 3 objects switch to per-vertex lighting). Changing the sprite scale to (1,1,1) fixes the issue, so it's just a problem with scaled sprites.

    Is this a known bug that will be fixed soon?
     
  2. nunesbarbosa

    nunesbarbosa

    Joined:
    Jul 17, 2012
    Posts:
    103
    Hi mate.. I'm having the same problem here.. It only happens when you scale the object from script. On editor this doesn't happen. Maybe it's a bug.

    $unityTrouble.png
     
  3. IndreamsStudios

    IndreamsStudios

    Joined:
    Jun 4, 2013
    Posts:
    9
    I'm seeing this happen in the editor too. I noticed that if you change the sprite's PixelsToUnits, then you can make it larger and still get lighting to work. But that doesn't solve non-uniform scaling or variable scaling for spritesheets.
     
  4. Likvidniy

    Likvidniy

    Joined:
    Dec 24, 2012
    Posts:
    4
    you can use [spot lights ] they seems to work appropriate with scaled sprites !
     
  5. KorsAir

    KorsAir

    Joined:
    Nov 16, 2013
    Posts:
    3
    Any news regarding this problem? Every time I change the scale of a game object it stops receiving light from the light sources, regardless of its type, spotlight or point.
     
  6. nunesbarbosa

    nunesbarbosa

    Joined:
    Jul 17, 2012
    Posts:
    103
  7. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    Hi all,

    Lighting issues with scaled sprites is a known bug. We've fixed it in 4.5!
     
    Last edited: May 15, 2014
  8. tensaix2j

    tensaix2j

    Joined:
    Aug 6, 2013
    Posts:
    1
    The bug seems to remain in version 4.5.4f1.
     
  9. evuslu

    evuslu

    Joined:
    Feb 26, 2013
    Posts:
    9
    Have you tried to change fog density to 0, maybe this might be the problem
     
  10. KTurbo

    KTurbo

    Joined:
    Aug 28, 2013
    Posts:
    1
    I've been struggling with this problem for a bit. Luckily I found the problem rather quickly. Make sure to scale the sprite with Vector3 and set the z-value to 1. My problem was that I was scaling with Vector2 and that sets the z-value to 0.