Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

ScriptableCullingParameters SetCullingPlane inconsistencies?

Discussion in 'Graphics Experimental Previews' started by XRA, Nov 7, 2017.

  1. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    I'm noticing that SetCullingPlane seems finicky about the planes provided, where it will cull mostly correctly but then also will cull out all the geometry or have things drop in and out when the camera is at certain orientations.

    At first I thought maybe my planes are not correct, but I'm also using CullingGroups which I query after calling CullResults.Cull() (using the culling planes), and the CullingGroups are culling absolutely perfectly with the planes, and not exhibiting the renderer culling issues.
    (I am also able to make both not work by putting in obviously wrong planes)

    Is there a slight difference with how renderContext.DrawRenderers() uses the culling planes set, VS how CullingGroups use them?

    Can anyone provide any examples or clues to making sure my culling planes are setup correctly for using with CullResults.Cull() ?

    I imagine that all the plane's normals are supposed to point "into" the frustum volume, but maybe that isn't correct? Also seems like they are in world space with the normal also being world space?
     
  2. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    heres a gfy example, https://gfycat.com/ifr/TinyRevolvingAmericancicada

    The red wireframe cubes are being culled via CullingGroups, the result of using the clipped frustum planes with SetCullingPlane(), they cull reliably.

    The geometry through the portal culls reliably in one direction, but the other direction only appears at certain camera angles, while the CullingGroups still cull reliably.

    (Both culling groups and geometry are using the same CullResults.Cull() to initiate the cull)

    I'm still leaning toward user-error with my culling planes, but I don't get why the Culling Groups would cull correctly if the planes are wrong.
     
    Last edited: Nov 8, 2017
  3. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Hi XRA,

    No. They both use same planes to test against AABB/Spheres. If you have occlusion baked then occlusion buffer is used to test both renderers and group's spheres.

    That's correct.

    Do you have the same issue with occlusion culling disabled? Can you share a repro scene so we can take a look at it?
     
  4. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    hey thanks for the reply, I'm not using occlusion culling in terms of baked occlusion, as a test I made sure to turn off anything related to the occlusion system on the MeshRenderers and Camera, though with that stuff enabled by default it didn't seem to change anything.

    So the main plan is to use frustum culling, except with the clipped down / shrunken frustum when viewing through portals. Prior to 2017.3 I was in 4.7, so the portal culling would test the planes and toggle renderers on and off from within OnPreCull.

    I could try going back to that approach using the culling groups, but not sure if toggling renderers within Render() is going to cause issues, haven't tried yet :) I know I could issue cmd.DrawMesh() for visibile culling groups but then it seems like I'm repeating work in C# that Unity would do via frustum culling.

    I should be able to make a repro scene, it's a huge project so I will separate it out into a simple test script, will probably help over here too for debugging.

     
  5. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    I got it working, after rewriting a simple version in a separate project, everything was working alright with the modified culling planes.
    I think it was a matrix multiplication order thing, related to how I transform the planes from viewing into the portal, to the rendering view looking out the destination portal.

    I should have just started on a separate test project sooner, would have saved me some time :)

    The SRP is really good, and I'm looking forward to continue porting the rest of my effects over!
     
  6. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Awesome. Let us know if you have feedback/issues with SRP.