Search Unity

Question Camera OnPreCull/OnPreRender not working

Discussion in 'High Definition Render Pipeline' started by Backes, Oct 4, 2019.

  1. Backes

    Backes

    Joined:
    Mar 22, 2018
    Posts:
    4
    Are these callbacks supposed to work on HDRP?
     
    Neiist and einWikinger like this.
  2. einWikinger

    einWikinger

    Joined:
    Jul 30, 2013
    Posts:
    97
    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?
     
  3. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    262
    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:
    - The render pipeline manager, it provides before and after frame / camera rendering events but is not designed to do any rendering operation (you don't have access to the camera buffers) https://docs.unity3d.com/ScriptReference/Rendering.RenderPipelineManager.html.
    - Builtin HDRP custom passes, this is the solution to write any custom effect, you can check out the doc here: https://docs.unity3d.com/Packages/c...s.high-definition@7.1/manual/Custom-Pass.html and there is also a sample project with examples of custom passes: https://github.com/alelievr/HDRP-Custom-Passes

    You can also note that there is custom post processes built-in HDRP too: https://docs.unity3d.com/Packages/c...efinition@7.1/manual/Custom-Post-Process.html
     
    andreiagmu, iamarugin and einWikinger like this.
  4. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    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:
    Code (CSharp):
    1.  
    2. // 2) cull everything outside of camera frustrum
    3. Camera.onPreCull = SetCamSizeDefault;
    4.  
    5. // 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)
    6. 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.
     
    Last edited: Dec 13, 2020
  5. Bitanian

    Bitanian

    Joined:
    Jul 24, 2020
    Posts:
    1