Search Unity

Partial Shadows

Discussion in 'Shaders' started by DARKHAWX, Apr 15, 2017.

  1. DARKHAWX

    DARKHAWX

    Joined:
    Apr 15, 2017
    Posts:
    15
    Hi there,

    I currently had a shader that will reveal an object as the player gets within a certain distance of it (i.e. display pixel normally if its within x distance of player otherwise discard). However currently with my shader shadows are always displayed, even if the object is hidden/partially hidden.
    How can I prevent this from happening? How can I disable shadows for the object if the pixel isn't within range? I can't just turn shadows on and off, I need to be able to partially show shadows for objects.

    If this isn't possible just with shaders what is some way I can get around this?
     
  2. DARKHAWX

    DARKHAWX

    Joined:
    Apr 15, 2017
    Posts:
    15
    Fixed it!

    If you're making changes to the vertexs of an object in a shader, simply add "addshadow" to your "#pragma surface" directive.