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

Shadow map is not displayed on the frame debugger

Discussion in 'Shaders' started by valobaibai, Jun 23, 2019.

  1. valobaibai

    valobaibai

    Joined:
    Dec 14, 2018
    Posts:
    1
    When I was learning this SRP tutorial with Unity2019, the rendered shadow map was not displayed correctly on the frame debugger panel. I don't know the reason for this result, and I am not sure which step I missed.

    This is how my scene is set up:


    This is the frame debugger:


    This is the pipeline that renders the shadow map:

    Code (CSharp):
    1.     void RenderShadows(ScriptableRenderContext context,Camera camera)
    2.     {
    3.         shadowMap = RenderTexture.GetTemporary(4096,4096,16,RenderTextureFormat.Shadowmap);
    4.         shadowMap.filterMode = FilterMode.Bilinear;
    5.         shadowMap.wrapMode = TextureWrapMode.Clamp;
    6.  
    7.         shadowBuffer.SetRenderTarget(shadowMap,RenderBufferLoadAction.DontCare ,RenderBufferStoreAction.Store);
    8.         ClearFlag clearFlag = ClearFlag.Depth;
    9.         shadowBuffer.ClearRenderTarget((clearFlag & ClearFlag.Depth)!=0,(clearFlag & ClearFlag.Color)!=0,Color.clear);
    10.  
    11.         shadowBuffer.BeginSample("Render Shadow");
    12.         context.ExecuteCommandBuffer(shadowBuffer);
    13.         shadowBuffer.Clear();
    14.  
    15.         Matrix4x4 viewMatrix,projectionMatrix;
    16.         ShadowSplitData splitData;
    17.         cullingResults.ComputeSpotShadowMatricesAndCullingPrimitives(
    18.             0,out viewMatrix,out projectionMatrix,out splitData
    19.         );
    20.         shadowBuffer.SetViewProjectionMatrices(viewMatrix,projectionMatrix);
    21.         context.ExecuteCommandBuffer(shadowBuffer);
    22.         shadowBuffer.Clear();
    23.        
    24.         ShadowDrawingSettings shadowSettings = new ShadowDrawingSettings(cullingResults,0);
    25.         context.DrawShadows(ref shadowSettings);
    26.  
    27.         shadowBuffer.EndSample("Render Shadow");
    28.         context.ExecuteCommandBuffer(shadowBuffer);
    29.         shadowBuffer.Clear();
    30.     }
     
    tangwilliam likes this.
  2. bsgbryan

    bsgbryan

    Joined:
    Nov 27, 2015
    Posts:
    26
    This is happening for me as well. I cloned the repository for the tutorial and confirmed that everything is working correctly (shadows are being rendered), but the Frame Debugger just shows black for the Shadows.Draw sample; as well as every step in the sample.

    I have tested this is both Unity 2020.2.0b13 and 2021.1a7.
     
  3. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Did you try changing the 'levels' slider?
     
    stefnobel likes this.
  4. beatdesign

    beatdesign

    Joined:
    Apr 3, 2015
    Posts:
    137
    Using Unity 2020.2, Tested both in URP and Built-in
    Simple scene, plane and a cube + Directional light
    Frame Debug doesn't show Cascade Shadowmaps depth buffers. It is not a level slider problem.
    I can see Shadows.RenderJobDir task, I can see that there are 4 couples of draw-plan/draw-cube under it (because of the 4 CSM, but the game view doesn't display the depth data.
    Why?
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    I does not work in 2020.3.4.
    Did someone report this already as bug?
     
  6. tangwilliam

    tangwilliam

    Joined:
    May 4, 2016
    Posts:
    22
    I come into the samp problem with 2020.3.7f1.
    Does anyone knows how to fix this ?
     
  7. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    Sorry, I forgot to leave message here - I reported this issue and received this reply:
     
    beatdesign likes this.