Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

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:
    198
    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:
    225
    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:
    198
    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.
unityunity