Camera OnPreCull/OnPreRender not working

Are these callbacks supposed to work on HDRP?

2 Likes

I’d like to know that as well, as I just ran into the same issue - the OnPreCull delegate isn’t called (at all?) on our HDRP-based project (Unity 2019.2.17f1 + HDRP 6.9.2). Are there any replacements?

Hi,

All the camera events have been deprecated in SRP so if you’re using Universal / HDRP your code won’t be called if you try to use them.
Two system are replacing these events:

You can also note that there is custom post processes built-in HDRP too: Redirecting to latest version of com.unity.render-pipelines.high-definition

3 Likes

Hi,

I think this is related so i’ll ask here:

In built-in pipeline (old), i used to visualize unity’s built-in frustrum culling this way:

// 2) cull everything outside of camera frustrum
Camera.onPreCull = SetCamSizeDefault;

// 2) render everything inside the camera, and some distance outside of camera (which has been culled in (1), so it will show mostly as empty space)
Camera.onPreRender = SetCamSizeLarger;

This worked fine, following the old event exec order.

How do i do this visualization within URP? The URP loop only allows me to access BeginFrameRendering and BeginCameraRendering with delegates, but the ‘culling’/‘build rend data’ + ‘execute renderer’ happens deeper inside (to which i have no exposed delegates via which i could inject my c# code).

I’m aware the process in implementing said visualization for URP would be different from the built-in pipeline, but would welcome some additional resources - any (more detailed than the official docs) example code or links would be appreciated. I’m struggling to find them myself.

3 Likes

Bump

I found this Solution working for me. You can use this :

protected void OnEnable()
{
    RenderPipelineManager.beginCameraRendering += CustomOnPostRender;
}


    protected void CustomOnPostRender(ScriptableRenderContext context, Camera camera)
    {
        //Write your Code Here
    }

    private void OnDisable()
    {
        RenderPipelineManager.beginCameraRendering -= CustomOnPostRender;
    }
2 Likes