Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

ComputeDirectionalShadowMatricesAndCullingPrimitives fails

Discussion in 'Graphics Experimental Previews' started by Hyp-X, Mar 10, 2020.

  1. Hyp-X

    Hyp-X

    Joined:
    Jun 24, 2015
    Posts:
    438
    Hi,

    I've been writing my own SRP and run into an issue.

    CullingResults.ComputeDirectionalShadowMatricesAndCullingPrimitives returns false and does not compute the shadow matrices and culling primitives if there's no MeshRenderers visible in the camera frustum.

    Most geometry I have is procedurally drawn through DrawMeshInstanced and DrawMeshInstancedIndirect so I need this to function with no MeshRenderers in camera view.

    I checked the URP & HDRP and they have the following note:
    Code (CSharp):
    1.             // TODO: At some point this logic should be moved to C#, then the parameters cullResults and lightIndex can be removed as well
    2.             //       For directional lights shadow data is extracted from the cullResults, so that needs to be somehow provided here.
    3.             //       Check ScriptableShadowsUtility.cpp ComputeDirectionalShadowMatricesAndCullingPrimitives(...) for details.
    Now I'd like to check ScriptableShadowsUtility.cpp but I don't know where I can find it.

    I think I reasonable reimplemented this functions functionality, but the result differs in ways I can't explain.
    I went through my calculation several times, but it is possible that I missed something.
    It would be really good if Unity released the source of this function...

    Right now I'm using Unity 2019.3.4f1, but I checked the 2020.1/HDRP 8 source and it still has this note and code like this.
     
  2. SimonFearn

    SimonFearn

    Joined:
    Jan 16, 2020
    Posts:
    4
    Hi, dealing with the same thing!

    Did you ever find the calculation for split spheres?

    Thanks
     
  3. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    My workaround for this is write a shader surve as a "Dummy shadow caster" that did not write anything into the shadowmap (clipped in the fragment shader of the shadow caster pass), And always put a cast shadow only renderer in front of the camera using the dummy shader caster material.