Search Unity

Rendering into shadow maps with procedural geometry

Discussion in 'Universal Render Pipeline' started by Fewes, Mar 8, 2020.

  1. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    259
    I have a system for drawing millions of tree instances which works by drawing procedural billboards using a geometry shader, which I am trying to port to URP. I have the basic rendering working already by submitting DrawProcedural via the ScriptableRenderContext in the Execute function of a custom ScriptableRendererFeature.
    I'm a little lost on how I would go about submitting shadow map draw calls however, since there is no RenderPassEvent.BeforeRenderingShadowMap.
    Previously, I used Graphics.DrawProcedural with the castShadows parameter set to true. What would be the equivalent in URP?
     
  2. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    Hey,
    Currently there is no easy way to do this without heavily editing the URP source, we are lacking the ability for a render pass to inherit the target from a previous pass. So in this case you would want to draw your objects into the shadow map after the default one has run, and we need to be able to say 'I'll draw into the same target that is already bound'.
    This work is scheduled very soon as it unblocks us internally form also adding features that can draw into an existing target easily.
     
    cecarlsen and Fewes like this.
  3. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    259
    Thank you for the reply, and great to hear it is a planned feature, as it was very useful in the built-in pipeline.
    If you are looking to improve on the old ways, having access to the actual internal render target itself would be great. This would for example allow the use of the depth buffer from the cascaded shadows render pass for custom effects such as a transparent/particle shadow buffer. Being able to customize the internal render target before it renders would also be nice, but I understand this makes it easy for the user to break things.
     
    DebugLogWarning likes this.
  4. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    259
    Hi again, any updates on this?

    Edit: So actually, it seems Graphics.DrawProcedural still works in URP (for some reason I was under the impression it didn't) and procedural geometry rendered that way will cast shadows if you pass the correct arguments (and call it from Update, not BeginCameraRendering or something). Still, it'd be nice to be able to do custom rendering to the shadow/depth map just like in the standard rendering pipeline.
     
    Last edited: Oct 1, 2020