Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Normal mapped sprites: How to disable culling?

Discussion in '2D' started by Andreas Loew, May 21, 2015.

  1. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    We currently have a setup for normal mapped sprites - which allows using light effects in 2d. ( See youtube )

    To accomplish this we set up a material using the shader "Standard" with rendering mode "fade", a normal map and the sprite's texture as albedo.
    When creating a sprite or animation we simply assign the material instead of the standard sprite material.
    Add some lights and your are done.

    Everything works fine - scaling - rotating - except when trying to flip the sprite. When flipping twice (e.g. in x and y direction) the sprite comes back...

    I guess that the problem is located in the culling that is applied due to the switched orientation of the sprite's vertexes.

    I tried to set different values in "Animator" -> "Culling Mode" but that did not change anything.

    So my question is: Is there a way to disable culling? Or am I totally wrong and there is there some other reason why the sprites disappear?
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,999

    Attached Files:

    Andreas Loew likes this.
  3. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    Thanks - ok - that's now 50% ;-)
    The sprite appears again - but the light's direction is now inverted...

    Guess inverting the vectors from the normal map would be required now. However unity's shader sources are quite extensive...

    In case you have some time it would be great if you could help me out with this... does not have to be for free btw. ;)
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,999
  5. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    I've tried several - but none of them seems to work as expected... they either did not care about culling - or deliver bad quality - or both...
     
  6. Malkyne

    Malkyne

    Joined:
    Nov 18, 2009
    Posts:
    39
    Oh, shoot, I wish I had seen this post sooner! I know it's old, but since Andreas makes nice software that I like, I figured I should send this his way, if it will help. I made this shader a few months ago. It's not my greatest shader in history, but it seems to do the job:

    https://bitbucket.org/snippets/HiddenAchievement/rjkkR

    Unfortunately, after I came up with that, my artist told me he needed a working emissive layer. Some days, you just can't catch a break!