Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

ComputeDirectionalShadowMatricesAndCullingPrimitives fails

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

  1. Hyp-X


    Jun 24, 2015

    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


    Jan 16, 2020
    Hi, dealing with the same thing!

    Did you ever find the calculation for split spheres?

  3. echu33


    Oct 30, 2020
    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.