Search Unity

No additional light shadows in custom shader

Discussion in 'Universal Render Pipeline' started by kulesz, Aug 12, 2021.

  1. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    140
    Hi,

    I was trying to use this sample shader as a base for my own lit URP material:
    https://gist.github.com/phi-lira/225cd7c5e8545be602dca4eb5ed111ba

    Unfortunately - I cannot get shadows from point lights to work. Shadow from directional light work fine, but there's no additional ones (neither from spot or point lights).
    I've checked "Receive Shadows" in material properties and I've enabled shadows in pipeline settings - there's still no shadows on this custom shader.
    However - on standard Lit material everything works fine - all lights cast shadows. So the renderer settings should be fine and the problem lies within the shader alone.

    Is there something else I should do? Or is the shader above deprecated?
    Even simple copy-paste from source above does not produce point light shadows.
     
  2. undecyce

    undecyce

    Joined:
    Oct 17, 2019
    Posts:
    8
    Sample shadowmap again for additional lights works for me.
    Code (CSharp):
    1. float4 shadowMask = SAMPLE_SHADOWMASK(dynamicLightmapUV);
    and in light loops, add it as a additional parameter:
    Code (CSharp):
    1. Light light = GetAdditionalLight(lightIndex, IN.positionWS, shadowMask);
     
  3. slushieboy99

    slushieboy99

    Joined:
    Aug 29, 2014
    Posts:
    88
    What is dynamicLightmapUV in this context?