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

Question shadow glitches in my custom light

Discussion in 'Shader Graph' started by asger60, Nov 15, 2019.

  1. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    Hey, I'm experimenting with custom light in my graph, it works ok, but I get some strange glitches in the shadows when the light changes.
    Nov-15-2019 11-49-09.gif

    Heres the graph:
    Screenshot 2019-11-15 at 11.51.43.png

    And the code in the custom function goes like this:
    Code (CSharp):
    1.  
    2. void LWRPLightingFunction_float (float3 ObjPos, out float3 Direction, out float3 Color, out float ShadowAttenuation)
    3. {
    4. #ifdef LIGHTWEIGHT_LIGHTING_INCLUDED
    5.     //Actual light data from the pipeline
    6.     Light light = GetMainLight(GetShadowCoord(GetVertexPositionInputs(ObjPos)));
    7.     Direction = light.direction;
    8.     Color = light.color;
    9.     ShadowAttenuation = light.shadowAttenuation;
    10. #else
    11.     //Hardcoded data, used for the preview shader inside the graph where light functions are not available
    12.     Direction = float3(-0.5, 0.5, -0.5);
    13.     Color = float3(1, 1, 1);
    14.     ShadowAttenuation = 0.4;
    15. #endif
    16. }
    Is there something obvious I'm missing in order for this to work a little bit better?
     
  2. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    Is it maybe because i'm using the emission output from the pbr master to render the color/shadow, and somehow have shadows twice?
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    it looks like ordinary self shadowing artifacts to me. you may try to adjust the shadow bias (normal, depth) of the light.