Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Cull Off Shader with Transparent Cutout

Discussion in 'Shaders' started by witherhunterboy, Apr 15, 2022.

  1. witherhunterboy

    witherhunterboy

    Joined:
    Sep 18, 2021
    Posts:
    2
    Hello, I was wondering if anyone would be able to help me with this. I am working on a 3d game that uses quads with 2d sprites in them as the primary visual element. The quads rotate to follow the camera, and I have found that, when directional lighting is introduced, they look really good if the light is facing the side you are seeing but absolutely terrible if the light is hitting the other side and you only see the darkened part. Because of this, I have tried to make a shader that turns Cull to Off, as according to my current understanding that would allow the quad to be lit from behind. however, since the vast majority of the sprites I am using are partly transparent, I need to be able to make them have no Cull and have the transparent cutout feature that exists with the basic shader, and with my extremely limited knowledge on shaders I have only been able to flipflop between no Cull and having transparency. If any of you would be able to write a very simple shader that does this or set me on the right path towards making one myself, I would appreciate it very much.


    upload_2022-4-15_16-20-36.png
    how the sprites look when facing the sun (and how I would like them to look whenever light is present from any side)



    upload_2022-4-15_16-22-10.png
    how the sprites look when facing away from the sun
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,557
    A good tip for making foliage like this look nice is to instead make the normals of your vertices point upwards, instead of in the direction of the face. That way when the sun is directly above, they look their brightest, and as it sets they get darker and darker. It will also mean the lighting stays consistent no matter the side the light is on.

    Here's an example:

     
    Last edited: Apr 16, 2022