Search Unity

Question custom render pass, don't render anything

Discussion in 'High Definition Render Pipeline' started by chena_cpp, Jan 31, 2024.

  1. chena_cpp

    chena_cpp

    Joined:
    Oct 27, 2014
    Posts:
    24
    I test custom render use the sample, https://github.com/alelievr/HDRP-Cu...s/Scenes/CameraDepthBaking/CameraDepthBake.cs.
    sample work correct, but because i want use my custom shader, so i can't use the RenderDepthFromCamera api, then i change the src code from
    Code (CSharp):
    1. // Depth
    2.         if (depthTexture != null)
    3.             CustomPassUtils.RenderDepthFromCamera(ctx, bakingCamera, depthTexture, ClearFlag.Depth, bakingCamera.cullingMask, overrideRenderState: overrideDepthTest);
    4.  
    to

    Code (CSharp):
    1.         // Depth
    2.         if (depthTexture != null)
    3.         {
    4.             //CustomPassUtils.RenderDepthFromCamera(ctx, bakingCamera, depthTexture, ClearFlag.Depth, bakingCamera.cullingMask, overrideRenderState: overrideDepthTest);
    5.  
    6.             var filterSettings = new FilteringSettings(RenderQueueRange.opaque);
    7.  
    8.             // Create the draw render settings
    9.             // note that it takes a shader pass name
    10.             var drawingSettings = new DrawingSettings();
    11.             drawingSettings.SetShaderPassName(0, new ShaderTagId("DepthOnly"));
    12.  
    13.             // enable instancing for the draw call
    14.             drawingSettings.enableInstancing = true;
    15.  
    16.             // pass light probe and lightmap data to each renderer
    17.             drawingSettings.perObjectData = PerObjectData.None;
    18.  
    19.  
    20.  
    21.             ctx.renderContext.DrawRenderers(ctx.cullingResults, ref drawingSettings, ref filterSettings);
    22.  
    23.         }
    it don't render anything now, why?
    how could i debug it, know the reason, thanks.
     
    Last edited: Jan 31, 2024
  2. chena_cpp

    chena_cpp

    Joined:
    Oct 27, 2014
    Posts:
    24
    I upload the code and test scene, create a hdrp project, copy CameraDepthBaking folder to assets folder, open the CameraDepthBaking/test scene, unity version 2021.3.15f1c1.
     

    Attached Files: