Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Custom Culling using the Scriptable Render Pipeline

Discussion in 'Graphics Experimental Previews' started by ToddRivers, Oct 3, 2018.

  1. ToddRivers

    ToddRivers

    Joined:
    Mar 15, 2013
    Posts:
    17
    Hey! I'm working on a project that needs some unique culling that's hard to do simply with layers.
    Especially useful would be the ability to only render objects from one scene at a time.

    I'm excited by the new Scriptable Render Pipeline stuff and am looking into how I could customize what gets rendered using it.
    I've had a look through the docs and this post:
    https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/SRP-Culling

    And as I understand the ScriptableRenderContext uses a FilterResults struct representing what's going to be rendered.
    This is generated by CullResults.Cull() which takes a ScriptableCullingParameters.
    However I'm not sure how I can customize this to cull specific game objects or all objects from a scene.

    It is or will it be possible to modify FilterResults yourself? Like add / remove Renderers from it?
    Or is there any documentation or advice on how ScriptableCullingParameters class works, particularly with its sceneMask?
     
    tspk91, mitaywalle and JesOb like this.
  2. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    262
  3. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    75
    I would also like more access to the Culling methods for custom culling. My use case would be to *not* perform culling as I already know all the objects are in the camera field of view. I would like to reclaim those precious milliseconds lost to the culling step.
     
  4. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    133
    I have a similar issue as the original poster. We have separate hierarchies of gameplay areas and need a way to hide them from the camera and listener. Basically we need independent worlds/scenes but we're still connecting them with OffMesh links. The objects in the separate areas still need updating, so we can't simply deactivate the root node.

    Something similar to the sceneMask sounded promising but there hasn't been any update on it.
     
  5. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    133
    I'm curious if anyone has come up with a solution to this problem? We still haven't found a decent way to cull out visible or audible objects. Is there some way to set the camera and listener to only cull objects in the scene that it is in?
     
  6. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    131
    Bump?
     
  7. TheDelhiDuck

    TheDelhiDuck

    Joined:
    Aug 29, 2014
    Posts:
    35
    I'd find this useful too.
     
  8. Manamongods

    Manamongods

    Joined:
    Nov 19, 2017
    Posts:
    40
    It would be good if I could cull within another CullingResults, because I'm rendering multiple slices of a frustum and every slice is contained within the full frustum, which I already have CullingResults for.

    Also, being able to prevent culling from updating CullingGroups would be very useful, because currently I create a dummy camera that I get the ScriptableCullingParameters from to use when culling the slices, because my CullingGroups should only update based on the full frustum.
     
    Last edited: Jul 17, 2021
  9. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,098
    And I would like to remove lights from culling since it is buggy in unity.
    Any idea how could I do this ?
     
  10. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Hey All,
    I'm looking into doing some custom culling in URP as well. Nothing crazy but I would like to be able to manually specify a subset of the total scene before the filtering and culling (locked areas of the scene don't need to be in the calculation etc.) Umbra culling is already working decently well but sometimes locked meshes still render incorrectly.
    Any ideas how to achieve this?

    EDIT: It looks like the Rendering Layer Mask in the additional settings of renderers looks promising
     
    Last edited: Sep 27, 2021
  11. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,279
    It would be extremely powerful to be able to override or "stack on top of" the core culling. This would make custom occlusion culling solutions MUCH easier to implement, and other features as well. Being able to inject before the c++ culler, after the c++ culler, or replace the c++ culler entirely (which yes, would be slower in C# if copied exactly, but it allows us to in theory make it still faster if we have our own use cases!)
     
  12. Rob-Fireproof

    Rob-Fireproof

    Joined:
    Dec 18, 2012
    Posts:
    57
    Does anyone know if anything ever happened to allow custom culling? It would still be incredibly useful!
     
    tspk91 likes this.
  13. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,279
    I believe nothing has changed on that front
     
  14. Twoseven

    Twoseven

    Joined:
    Jul 13, 2016
    Posts:
    3
    If anyone is curious, you can somewhat work around this by temporarily setting the renderingLayerMask on objects you wish to exclude from a render and use filteringSettings.renderingLayerMask

    It would be nice to not have to do this, though.
     
    tspk91 likes this.
  15. Bovine

    Bovine

    Joined:
    Oct 13, 2010
    Posts:
    195
    Guessing this is still not possible, eh? :/