Search Unity

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,550
    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