Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Graphics [RELEASED] Perfect Culling - Pixel Perfect Occlusion Culling

Discussion in 'Tools In Progress' started by PatrickKa, Apr 18, 2021.

  1. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Nice! This should be clearly stated in the description then.

    Another question. I can just assume that technique requires a separate render pass? (it is important because if it is true I don't know if it would be beneficial on tiled rendering platforms - mobiles including oculus quests, and it would require extensive testing)
     
  2. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    All occlusion calculations are done in the Unity Editor in a baking step that stores the results in a lookup table. This makes it very straight-forward and efficient at run-time though comes at a memory cost but there is features in the asset to tune that as well to meet your memory budget.

    Concluding that it should be pretty good for mobile platforms especially considering that some of the expensive steps such as tree traversals (what Umbra is doing) are completely avoided.

    However your level should ideally be pretty static and have good culling opportunities to really make Perfect Culling shine because fully dynamic objects are not supported.
     
    shamsfk likes this.
  3. FuhaoXie

    FuhaoXie

    Joined:
    Nov 18, 2016
    Posts:
    26
    Yes, like unity reflection probes has a toggle "occlusion culling". Does perfect culling has the same feature?
     
  4. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Currently there is no such feature but I'm working on an update that should allow to cull Reflection Probes and other Unity objects (Lights, Scripts, Terrains, etc.) but it would not be an automatic process.
     
    PutridEx likes this.
  5. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    Hi, your plugin is great! Well done!
    I'm working on a point & click exploration game. It's based on Cinemachine camera system so I'm pretty sure there is a way to know every possible camera point of view. Is it possible for you to expand the Perfect Culling Camera size utility to accept a range of Cinemachine Virtual Camera and then compute the bounds of the volume? Bonus point if it is able to detect all the cells that needs to be baked :)
     
  6. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Thanks!

    If you cameras are all static you might want to use a PerfectCullingVolume for each of them and just set the cell size and volume size to 1x1x1 to effectively only bake a single view point or make it slightly larger to account for some movement, etc.

    I have never used nor researched Cinemachine so I'm not exactly knowledgeable about how it works and what it can do. I'm sure you could also add some temporary meshes to calculate the bounds. Unfortunately I cannot add code specific to Cinemachine because that would require that everybody that wants to use Perfect Culling needs to install it as well.
     
  7. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello PatrickKA,

    I have some skinned mesh renderers that get occluded when behind walls(which is great) but they never render again when they are not occluded anymore by another object. They skinned mesh renderers don't move from their position they just play some iddle animations. Any idea why would this happen?

    Regards,
    Carlos
     
  8. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Did you already try some of the things mentioned in the Troubleshooting documentation? Furthermore if you could replicate the issue in a simplified project I'd be more than happy to look in-depth into your problem.

    I guess what happened is that the mesh was never considered visible in the first place and is always culled. I'm going to double check now whether Skinned Mesh Renderers are picked up at all. I will report back in a moment.
     
  9. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Okay I looked into it and it seems to be a problem in the Native Renderer. You can just disable it and rebake:
    1) Select the menu Perfect Culling/Settings
    2) Check "Use Unity For Rendering"
    3) Rebake

    That should solve your issue!
     

    Attached Files:

  10. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    Hey, this is great news! Just to be sure—does this mean that Perfect Culling will work with terrains without having to convert those terrains to meshes?
     
  11. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Thank you! That did it, now the skinned meshes are rendered back when they are not occlude anymore.

    Regards,
    Carlos
     
    PatrickKa likes this.
  12. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Yes. That was the main motivation here and it will introduce PerfectCullingTerrain, a script you can attach to your terrain to make it cullable. However it is important to note that under the hood it still needs to generate a temporary mesh for the baking process but that is just an implementation detail and nothing you need to do manually. It is also important to know that Perfect Culling cannot cull the terrain partially but only cull it as a whole (if it was not visible at all).

    Overall still a massive improvement and if you want to give this feature a try ahead of time just provide me with your invoice details via PM and I will send a link to the updated package!
     
    Lars-Steenhoff likes this.
  13. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    Hi, thanks for your answer, I've been working on my Cinemachine Sampler Provider. This script gives every possible camera position to the plugin.
    I've noticed something: when in play mode, if my cam is on a grid cell that has not been baked, the plugin culls 100% of the renderers. I think that it would be better to have an option to choose wether the plugin culls everything or nothing when no data is available.
     
  14. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    That is great feedback and I agree that your suggestions to just render everything in this case is a lot more graceful and a better way to go about it. I will add that as an option but got no ETA yet because I'm still testing the other upcoming update (I might be able to sneak it into that one if everything goes well though). If you want to hack it in yourself you can take a look at PerfectCullingCamera.cs. Basically you just need to check if PerfectCullingTemp.ListUshort is empty and manually push the indices 0 to number of bake groups for the current volume into it.

    EDIT: I just tried to add it and added a constant to PerfectCullingConstants.cs (I guess most people would want it to be enabled). Seems to work nicely. I can send you the upcoming version that now also includes this feature if you are interested. Alternatively I can also send you the diff and you can quickly add it yourself to your current version.
     
    Last edited: Nov 3, 2021
    heartingNinja likes this.
  15. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    I'll be glad to get the upcoming version!
    I have some objects popping up, so I switched to your materials and I wasn't able to see a lot because of all the hdrp post-processing. So I wonder if the same can happen during the baking process. I'll try modifying the PerfectCullingBakerUnity (SpawnCamera function) but I suspect there's also a DLL for the baking functions so I'm not sure if it will change anything.
     
  16. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    I sent you a PM.

    If you are on Windows it would by default use the native renderer (that is inside the DLL). There should be no way how any Unity functionality can interfere with the baking process in this case. You could also try to go into the Perfect Culling Settings and enable "Use Unity for Rendering". This will use Unity for rendering and maybe that works better for you, too. Generally it already should be setup in such a way that nothing can interfere with the baking process. Any kind of interference would most likely cause the GPU to read something invalid and you'd see an error immediately.
     
  17. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    Hi, I've found why I had some renderers popping: some "god rays" that are semi-transparent super large 3D objects where in the way. If I disable them before the bake, everything is ok. Now I'm looking for a way to exclude them from the baking process. I had no luck with "PerfectCullingRendererTag".
     
  18. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    The steps to make this work are:
    1) Add PerfectCullingRenderTag and check "Exclude From Bake"
    2) Clear Bake Groups on your PerfectCullingVolume
    3) Add all renderers back in (should now be excluded)

    I probably should change it to automatically reflect this change without the need to re-add the renderers though.
     
  19. ClementSchepens

    ClementSchepens

    Joined:
    May 27, 2020
    Posts:
    25
    Are all renderer excluded form the bake disabled when the baking happens?

    Edit: To set the bool ExcludeRendererFromBake by script I'm forced to modify PerfectCullingRendererTag.cs

    Code (CSharp):
    1. public bool ExcludeRendererFromBake { get => excludeRendererFromBake; set => excludeRendererFromBake = value; }
     
  20. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Yes. Initially all renderers get disabled and only the ones that are part of the bake are turned back on.
     
  21. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,010
    How is "not rendering" actually happening ? Is it disabling renderer on objects ?

    Do we get a notification like with unity occlusion culling (OnBecameVisible etc)

    Can It make transparent material behave like occluder (in unity It cannot be done)

    Can It disable lights from occlusion culling.
     
  22. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Essentially, yes. However starting in Unity 2019 it uses this more efficient approach: https://docs.unity3d.com/ScriptReference/Renderer-forceRenderingOff.html

    The next update will allow to toggle behaviours thus allowing you to execute custom logic.

    You can force a material to render opaque by putting pc_opaque into the material name. You can also do the opposite by putting pc_trans into the material name. Since the C# source code is available you can obviously customize this for your need as well, etc..

    Not at the moment but this will also be in the next update where you can toggle behaviours and that also includes lights. Basically you would just couple the Light with a Renderer and when the Renderer is culled so will be the Light.

    I already can hand out a preview version of the upcoming update so you would not need to wait for the "official" release.
     
  23. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,866
  24. Warmacha

    Warmacha

    Joined:
    Dec 13, 2015
    Posts:
    27
    Heyo! so been learning about the asset for the past couple of days, big improvements in batching from Unity's default occlusion.

    We're running a Multi Scene setup and building to Android, I was running the profiler and noticed spikes coming from perfect culling while looking around during playmode and even in builds.

    upload_2022-1-30_18-14-12.png

    is this the expected amount of cpu usage for perfect culling?

    If not, I wonder if this has to do with the amount of volume boxes we are having to use? I couldn't find any docs on how to do multi scene setups so I just copied how it seemed to work in your demo scenes. I put a volume box in every scene that was to be loaded in (there's about 4 scenes that have it at a time), added in the renderers in the scene to each respective volume box, and hit bake all. Each one of the volume boxes has about 9k cells merged down from 77k and the volume boxes overlap each other.
     
  25. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Hey,

    What Unity and Perfect Culling version are you using?

    You might be able to open PerfectCullingConstants.cs and adjust the ToggleRenderMode because chances are that it is set to PerfectCullingRenderToggleMode.ToggleShadowcastMode. In that case you can just try to replace it with PerfectCullingRenderToggleMode.ToggleForceRenderingOff.
    Notice that this only works in Unity 2019+ or higher and would fallback to a less efficient variant in older Unity versions.

    Generally the ToggleAllRenderers() functionality is only triggered when you move into a different cell. This can happen more frequently than it should for two reasons:
    • The cells are very very small and the camera ends up in a different cell even though it barely moved. In this case you might want to apply some additional merge-downsample steps to increase the final size of the cells and reduce the frequency of cell transitions.
    • You got multiple volumes but they use very different cell resolutions and/or are positioned in a way that the underlying math combined with floating point precision causes the calculated cell to jump around a lot.

      For instance the volume is at (23.12312312, 14.38493123123, 123.9090990976).
      In this case try to position the volume in such a way that it ends up at a more nice position such as (20, 15, 120). For best results you can also try to make the position divisible by the cell size. For a cell size of (0.5, 0.5, 0.5) a position such as (23.0, 14.5, 124.0) should be fine. This is especially important for overlapping volumes. Here you most likely want to make sure that the cell resolution matches so you essentially end up with the grid overlapping perfectly.

    I will also send you a download link to a preview of an upcoming update that improves the toggle behaviour specifically but it is a preview and could potentially introduce different issues. I'd recommend to give the ToggleRenderMode change a try first!

    Let me know if any of this was helpful.

    EDIT: Also notice that Deep Profiling does not give you accurate performance numbers due to the additional overhead of profiling every single functional call.
     

    Attached Files:

    Last edited: Jan 31, 2022
  26. Warmacha

    Warmacha

    Joined:
    Dec 13, 2015
    Posts:
    27
    Thanks for the fast reply!

    We are on Unity 2021.1.22 so I'll definitely give the rendertogglemode enum change a shot when I get the chance.

    As for the cells themselves, I put them to the same dimensions as you had yours in the multi scene demo scenes. Each scene has one volume box and they are all the same exact size and are in the same exact spot so there shouldn't be any strange uneven cell overlaps happening.

    I'll let you know how the enum change works out!
     
  27. Warmacha

    Warmacha

    Joined:
    Dec 13, 2015
    Posts:
    27
    We gave the RenderToggleMode change a try and saw that there were some gains. The performance increased by about half a millisecond every spike now

    upload_2022-1-31_17-38-16.png

    The spike happens I'm assuming every time we enter into a new cell, I don't know how you are using the volume boxes during runtime in multiscenes, but is it possible it is checking the positions of all of them at the same time? All of our volume boxes are in the same spot with the same cell settings, so it would be redundant in our case to check all of them every cell change when we only need to check one to know where the player is.

    Will give the preview a shot now.
     
    Last edited: Feb 1, 2022
  28. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Transitioning into a new cell means that the visibility of renderers needs to be updated.

    Do you also see spikes without Deep Profiling? I'm asking because Deep Profiling significantly impacts performance because it records any function call, etc. This becomes an issue when profiling code that is very heavy on function calls and that is true for this part of Perfect Culling as it needs to perform operations for potentially thousands of renderers. At this point the overhead of all the function calls completely blows everything out of proportion because Unity needs to inject profiling instrumentation into all of them.
     
  29. Warmacha

    Warmacha

    Joined:
    Dec 13, 2015
    Posts:
    27
    After implementing it I was interested in it's performance but couldn't find any calls from it without deep profiling, I believe any performance from it gets categorized under the gfx.waitforpresentongfxthread when not using deep profiling. From my testing any spikes seems imperceptible during runtime in non dev builds.

    That being said the preview build definitely has the best performance according to the deep profiler
    upload_2022-1-31_20-19-20.png

    We're just trying to squeeze as much performance as we can out of everything since it is a mobile game, So far this is still immensely better than unity's normal umbra culling and also more precise. Thanks for all the help!
     
  30. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,122
    waitforpresentongfxthread means GPU is the bottleneck, so the CPU is waiting for the GPU to finish work.
    If you want to know your CPU cost when GPU is the bottleneck, look at CPU cost, and deduct the cost of waitforpresentongfxthread from it. Ideally in a build since editor has some CPU overhead.
     
  31. Warmacha

    Warmacha

    Joined:
    Dec 13, 2015
    Posts:
    27
    You're right, For some reason it didn't occur to me that waitforpresentongfxthread was probably almost non existent when deep profiling due to the cpu no longer outpacing the gpu. Regardless, without deep profiling the only perfect culling I find in the profiler is an ongui update.
     
  32. ckohlmeyer

    ckohlmeyer

    Joined:
    Apr 17, 2021
    Posts:
    40
    I'm having an issue with a large scene. There is a main play area that works very nicely with the baking volume. However, we also allow the players to fly around where ever they like. When leaving the volume, the nearest cells give undesirable results.

    I tried making a second volume with large cells to cover this area, but it is overriding the smaller, higher res volume, even when you're inside that smaller volume, rendering its culling ineffective.

    Am I missing something with using multiple volumes? Can they only be used on separate sets of objects?

    Is there any other way to deal with out-of-bounds than cull or clamp-to-nearest? In my case, just disabling the culling when out of bounds would be a better option.

    Even better would be a way of marking cell density. Perhaps a density volume, or cell density automatically adjusted based on density of geometry. That would allow for a much larger volume without increasing memory usage by much.
     
  33. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    The main problem using multiple volumes on the same or a similiar set of renderers is that they might disagree with each other (Volume 1 says it is visible whereas Volume 2 says it is not). This is especially true when the resolution is not the same. So that might not be ideal.

    However if you already know for sure that you do not want the volume to perform any culling you can just straight up disable the volume or the GameObject and it will be ignored until you enable it again.

    If you roughly know where the player is when flying around you might also be able to add a PerfectCullingPortalCell. What it does is that it will not clamp the cell position to the closest cell in the volume but rather to the closest portal location.

    It might also be possible to not just clamp the position to the closest cell but perform a raycast to select a more appropriate cell. I made a note to add that as a feature as well.

    It sounds like the first approach (disables PerfectCullingVolume after entering a trigger) would be the easiest approach. If you cannot implement this yourself please let me know and I can implement that for you. :)
     
  34. ckohlmeyer

    ckohlmeyer

    Joined:
    Apr 17, 2021
    Posts:
    40
    Thanks for the quick reply, Patrick!

    We also came to the same conclusion and made a system to generate a trigger to match the dimensions of Volume 1, and toggle between Volume 1 and Volume 2 depending on if you were inside of it or not.

    Luckily your system does a great job of detecting the volumes getting turned on and off! So it works very well.

    I do think the addition of variable cell size based on geo density could be amazing. Just something like combining 4 cells together if there isn't any geo nearby
     
    PatrickKa likes this.
  35. Warmacha

    Warmacha

    Joined:
    Dec 13, 2015
    Posts:
    27
    This seems like a simple question, but I can't find anything about it on here or in the docs, Is there a simple way to mark a renderer to only be an occludee? Have some walls that get removed and don't want them occluding things behind them, but still want them to be culled out if not being seen.
     
  36. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Due to how the asset works the only way to do this is to make renderers transparent. The current version only allows to enforce this on a per material basis though.

    The way you would do that is:
    - Duplicate your material or create a new one
    - Put the word pc_trans into the name of the material to enforce transparency
    - Assign it to the desired renderers and bake
    - You can assign the original material after the bake finished because it is no longer required

    Obviously this is a bit clunky and thats why the upcoming update will add it as an option to the PerfectCullingRendererTag. If you want I can send you a preview of the upcoming update tomorrow.

    EDIT: I already sent you the preview version but that one is a bit outdated so it does not have this feature but as mentioned I could create an updated one tomorrow if you want.
     
  37. Warmacha

    Warmacha

    Joined:
    Dec 13, 2015
    Posts:
    27
    Sure send it on over! we're not doing anything super crazy with it so the last preview build worked just fine with us.
     
  38. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    407
    hey Patrick, I bought perfect culling yesterday, but I'm having trouble getting it working, in particular the method you describe above. I have a large scene about 250k objects, which is spit into multiple scenes and after trying a test bake I got an error, so I checked it out using your multiScene demo.

    here is what I'm doing just in case I'm misunderstanding the setup

    1. Opened these scenes

    upload_2022-2-6_23-16-13.png

    2. Select the menu option Perfect Culling/Bake All

    Result - I get the following errors

    upload_2022-2-6_23-18-16.png

    Koenigz.PerfectCulling.PerfectCullingBakerNativeWin64..ctor (Koenigz.PerfectCulling.PerfectCullingBakeSettings perfectCullingBakeSettings) (at Assets/Koenigz/Perfect Culling/Scripts/Baker/Native/PerfectCullingBakerNativeWin64.cs:235)
    Koenigz.PerfectCulling.PerfectCullingBakerFactory.CreateBaker (Koenigz.PerfectCulling.PerfectCullingBakeSettings bakeSettings) (at Assets/Koenigz/Perfect Culling/Scripts/Baker/PerfectCullingBakerFactory.cs:25)
    Koenigz.PerfectCulling.PerfectCullingBakingBehaviour+<PerformBakeAsync>d__15.MoveNext () (at Assets/Koenigz/Perfect Culling/Scripts/PerfectCullingBakingBehaviour.cs:205)
    Koenigz.PerfectCulling.PerfectCullingBakingManager.EditorUpdate () (at Assets/Koenigz/Perfect Culling/Scripts/PerfectCullingBakingManager.cs:192)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <ac4382394009481fa61779d0ab47a96f>:0)

    I'm using editor version 2021.2.10f1

    any idea?
     

    Attached Files:

  39. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Hey,

    Yes, this appears to be an issue in more recent Unity versions (probably due to all the C# updates and some changes in behaviour introduced by that). You should be able to just open the Perfect Culling Settings (using the menu or find it in the project) and check the "Use Unity for rendering" checkbox.

    Let me know if you run into any other issues. Always happy to help!
     
    Last edited: Feb 6, 2022
    punk likes this.
  40. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    407
    thanks that got me going
     
  41. BeauKnows

    BeauKnows

    Joined:
    Dec 13, 2021
    Posts:
    5
    Greetings, I'm very interested in this plugin. It seems like exactly what I need to get the fps of my highly detailed scenes under control. But before I buy i'd need to know:

    Does it currently work with Unity Terrain and ProBuilder shapes/structures?

    If not, are there any plans to support those in the future?

    Thanks!
     
  42. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Unity Terrain support will be added in the next update (already in review by the Asset Store team). I haven't tested ProBuilder shapes but as long as the MeshRenderer is not destroyed (to maintain a stable reference) it should be no problem.

    I attached the documentation for the Unity Terrain support so you can review it as well.
     

    Attached Files:

  43. BeauKnows

    BeauKnows

    Joined:
    Dec 13, 2021
    Posts:
    5
    I just purchased and am now learning how to use PC in my scenes. yay!

    EDIT: I posted an error and just realized the solution was posted directly above me, disregard :D
     
    Last edited: Feb 9, 2022
  44. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    The update 1.1.4 was also approved today. This includes the functionality described in the Terrains.pdf documentation I attached in my previous post.

    Just wanted to let you know and of course also feel free to reach out if you run into any issues or you have additional questions! :)

     
  45. BeauKnows

    BeauKnows

    Joined:
    Dec 13, 2021
    Posts:
    5
    Hello there, and Thanks!

    So Perfect Culling is working wonderfully with my map structures (my fps have gone from the low 40s to a solid 120fps in most areas), but I'm having issues with my terrain (after baking my map, the terrain doesn't appear at all in Test Mode).

    Could you please help me understand the correct step-by-step method of using Terrain with the Perfect Culling baking process? These are the steps I've been using so far:
    1. Create Terrain
    2. Add "Perfect Culling Terrain (Script)" to Terrain
    3. Add "Terrain to Mesh Utility" to Terrain, and create a Mesh in the Hierarchy
    4. Go to Perfect Culling Volume and drag this new Mesh into the "Additional Occluders" array
    5. Clear bake groups
    6. Click "Open Renderer Selection Tool" Now this is the part i'm not clear on: So I select my map architecture, but am I supposed to include the Terrain and/or the Mesh also in the Bake? Or should it just be the map Architecture alone, leaving the "Additional Occluders" mesh to account for the Terrain.

    Also, is it ok to have the Perfect Culling Baking Volume box extend under the Structures/Terrain?

    PC-Box.png

    In my map there is an underground room that I would like included in the Perfect Culling bake, but I see there are now multiple Probes underneath the Structure and Terrain that might cause culling issues (if I understand your tutorial video).

    What would be the best way to include a single structure under the game map in a proper Perfect Culling bake?

    I appreciate any help you can provide. Thanks!
     
  46. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Hey,

    Before update 1.1.4 was released you had to manually handle the terrain to mesh conversion using the Terrain to Mesh Utility. Since 1.1.4 you should only need to add the Perfect Culling Terrain script and it does perform all of this under the hood.

    So the steps should be:
    • Create Terrain
    • Add Perfect Culling Terrain script to terrain
    • Go to Perfect Culling Volume and clear bake groups
    • Add map architecture renderers (no need to add the terrain/mesh. This is also true for the "old" mesh utility approach. The mesh is actually an EditorOnly mesh and only used for the baking process. You still need the Unity Terrain).
    Your volume should be sized to encompass the size of the playable area. If the player cannot go under the structure there is no reason to include it in the bake because it wastes memory. Furthermore sample points that are located below the level could potentially see larger parts of the level (due to backface culling) and store this information. During merge-downsample step this information could spread into other cells and reduce culling effectiveness.

    You can automatically exclude cells using sampling providers (there is a doc for that). But you can also do it manually by placing exclude volumes.

    I hope this helps. Feel free to ask again if things are still unclear though! Also if you think you did everything correctly and it still doesn't work maybe try do reproduce the problem in a test scene and just send it to me via mail and I can see if there is maybe an issue in the asset itself. I will also double check again that everything works correctly tomorrow though.
     
  47. BeauKnows

    BeauKnows

    Joined:
    Dec 13, 2021
    Posts:
    5
    Quick update: I followed your instructions above and my Terrain is working again! (also implemented the Exclude cells for the basement area of my map) Thanks!

    Also, quick question about Portals Cells: should these be placed on each door mesh or doorway throughout my map? How and where would you typically use Portal Cells for best effect?

    Thanks again!
     
    Last edited: Feb 17, 2022
  48. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    236
    Portal cells are only useful if you are making use of multiple PerfectCullingVolumes and/or your player can leave the bounds of your PerfectCullingVolume. By default the sampling cell will be clamped to the closest cell in the grid. This can result in undesired culling because the closest cell might not be the best one to select.

    For instance in a procedural dungeon you have entrances that connect different level parts. You would place a Portal Cell near the entrance to tell Perfect Culling: Please find the closest Portal Cell and use that cell for looking up visibility information.

    So it is a tool to give you more control over that and can be pretty powerful but if you are not doing anything like that you should never need it because if everything is contained inside the same PerfectCullingVolume the system will figure out doors, etc. on its own and it should not require any manual work.

    There is a demo scene so you could boot that up and see how it changes the culling behaviour. Probably easier than my explanation. :rolleyes:
     
  49. BeauKnows

    BeauKnows

    Joined:
    Dec 13, 2021
    Posts:
    5
    Ahh ok, that makes sense. Thanks for the clarification!
     
  50. wj640520

    wj640520

    Joined:
    Jun 9, 2017
    Posts:
    6
    Hi @PatrickKa,I tried to test your TestPrefab put into a new scene, but when I hit the play button, it always show an red message
    "Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
    The following scene GameObjects were found:
    !ftraceLightmaps"

    how can I fix it?
     

    Attached Files: