Search Unity

Feature Request: CustomPassInjectionPoint.BeforeForwardOpaque

Discussion in 'High Definition Render Pipeline' started by orca2, Aug 20, 2020.

  1. orca2

    orca2

    Joined:
    Sep 19, 2015
    Posts:
    6
    Hi,
    ATM there are only 5 CustomPass injection points, compared to 24 in the built-in pipeline (enum CameraEvent)
    I request to add another one - BeforeOpaque.
    This will allow my custom pass to access various data that is calculated after DepthAndNormal, specifically Lighting data.

    I can easily support this by adding a single line to function ExecuteRenderRequest() in HDRenderPipeline.cs
    RenderCustomPass(renderContext, cmd, hdCamera, customPassCullingResults, CustomPassInjectionPoint.BeforeForwardOpaque);

    just before
    RenderForwardOpaque(cullingResults, hdCamera, renderContext, cmd);


    However, editing the HDRP files myself is not a viable solution, as i'm creating a package, not a game...

    Thanks!


     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    While this doesn't seem complicated technically (and as you described, you could add injection points almost everywhere), the existing ones were chosen to allow a certain extensibility of the pipeline, while preventing to write invalid data to the buffers or break the rendering.
    If you want the devs team to add this injection point to HDRP, you should tell us your use case : Why did you need this ? Wasn't it possible to achieve the same result with the existing injections points ? How can other users benefit from it ?
     
  3. orca2

    orca2

    Joined:
    Sep 19, 2015
    Posts:
    6
    We are writing a plugin for unity that renders real-time ray-traced reflections (without DXR/RTX). It can be used as an alternative to SSR.
    The reflections must be calculated before the Opaque pass, as the opaque materials use the reflection. However, the reflection contains scene objects using the Lit material, so in order to contain correct lighting, it needs to be injected after the calculating Light/Shadow data for that frame.

    Regarding "preventing to write invalid data to the buffers or break the rendering", it's very easy to break things with any user code...
    I suspect other advanced users should benefit from additional injection points, and there is currently a large gap between AfterNormalAndDepth and BeforeRefraction.
     
  4. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,

    few comment:
    - Before opaque event is not at the location you highlight in the diagram but is before the Gbuffer pass which render deferred opaque object. The event you highlight is Before Forward Opaque. Based on your description, it looks like you want to use the calculated reflection for the lighting pass, in this case it should happen Before the lighting pass (so before Deferred lighting and before forwrad opaque which perform forward opaque lighting).
    Short: the real injection point you want for your effect is the SSR one. You would like to switch SSR by your effect (and disable the async to have shadow ready, which is what we do for raytrace reflection), have in mind that all HDRP effect work in both deferred and forward mode.

    - We have a very limited set of injection point currently to not block us for future optimization. Once we add an injection point, it is there forever preventing any kind of pass reordering or architecture optimization we would like to perform. We are aware that's is not a satisfying situation for users but adding a single injection point line in the code for a specific projects is easy. Still for your context (i.e extension package) it doesn't help. We will add more injection point in the future when the architecture will be mature enough and we know thing will not move.

    I am aware it is not the answer you expect but it is to highlight design decision behind the current rendering passes.
     
    orca2 likes this.
  5. orca2

    orca2

    Joined:
    Sep 19, 2015
    Posts:
    6
    Thanks for the response @SebLagarde :)
    I think you're right about changing the injection point (I only used forward so far).
    I understand the design consideration about limited injection points. We'll have to supply a custom version of HDRP to our users in the mean time.