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

Pixel Perfect Shader not interacting with lights

Discussion in 'Shaders' started by Solivagant, Sep 19, 2014.

  1. Solivagant

    Solivagant

    Joined:
    Jan 25, 2014
    Posts:
    8
    Hi guys,

    I'm working on a pixel art game. Recently I realized I had all my sprites imported with Bilinear filtering, once I changed everything to uncompressed and Point filtering, the game looks pixel perfect. Well, almost.

    The remaining issue was that some of the pixels looked squished. After some digging I realized this is Unity squishing some of the pixels to a half-pixel size.

    I found a solution, the shader linked in this Unity Answers question: http://answers.unity3d.com/questions/652149/spritemanager-odd-uv-vectors.html

    So I changed all my sprites' Material to use this Pixel Snap Alpha Blended shader that was included in Unity 4.2.

    Now I can't get any lighting to affect the sprites, because it seems the pixel snap shader isn't considering any light.

    I've attached this shader and the regular sprite diffuse shader. I have tried to mix them together but my shader knowledge is very limited still. You can also find them both here http://unity3d.com/unity/download/archive/ There are links to the built in shaders in each version, 4.2 has the pixel snap attached here and the sprite difuse I included from latest version.

    I had a chance to show this problem to some Unity engineers and because the setup wasn't ideal (we didn't have tables or chairs), their 5-minute check of the issue didn't come to a solution. So I'm turning to the forums!

    Appreciate any help on this matter.
     

    Attached Files:

    Last edited: Sep 19, 2014
  2. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Your diffuse shader is in surface shader, all lighting calculation is done automatically, however your other shader is in CG, the lighting isn't done automatically with this shader, you have do code it.