Search Unity

[RELEASED] SECTR VIS: Dynamic Occlusion Culling

Discussion in 'Assets and Asset Store' started by MakeCodeNow, Feb 21, 2014.

  1. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,034
    Okay, I've fixed #2, but the occluders still aren't working. Do they disable individual objects that they fully occlude, or do they rely on sector bounds? My sectors are rather tall, not sure why, so often extend higher than the occluders, even though there's nothing up in the sky there. Is that the problem?
     
  2. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,034
    I'm also having some weird problems with culling (normal, not simple). Here's a video: http://www.eduweb-labs.net/portal-occlusion.mp4

    When the player-camera moves through some portals, many in-view objects are disabled. If the player-cam keeps moving forward, after about 5-10m, those objects activate again, though there is no other portal in the area. This happens with 3-4 portals, but not with the other 15. I can't see any difference in the portal setup. Any ideas?
     
  3. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    That's exactly correct. For non-squarish buildings, two occluders placed in an X can work well.
     
  4. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    It looks like that's happening because there is a gap between those sectors. Generally it's better for sectors to overlap a bit.
     
  5. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,034
    No, the two sectors definitely overlap quite a bit. Looking closely, I see that the portal between those sectors is in the left sector, but just outside the right sector. Which roughly corresponds to the zone where the right sector disappears. Do portals need to be inside the sectors that they connect to?
     
  6. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,034
    Now I'm trying to get occlusion culling to work in one of your demo scenes. See screenshot. I created an occluder and placed it right in front of the stack of crates, with the camera on the other side. Yet the crates are still rendered.

    This is for a game I'm aiming to release in a week, so if I can't solve these two problems today (getting occluders to work, and the strange way that some sectors are disabled at times), I'll have to find another solution. Which would be a drag, since I've put a lot of time setting up SECTR....
     

    Attached Files:

  7. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    They shouldn't, no. Can you post a video?
     
  8. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    That's an artifact of shadow culling which I explained earlier. Turn that off and you'll see the results you expect.

    Regarding SECTR VIS generally, I'd suggest you use simple culling at least. That seems to work well and will give you a lot of gains. Or use streaming to get even more unloaded.
     
  9. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    PS - sorry to hear about the time pressure. Occlusion culling is a complex thing and it's hard to apply that to a complex scene for the first time while under tight deadlines.
     
  10. PixelNAUTS_Alex

    PixelNAUTS_Alex

    Joined:
    Sep 14, 2012
    Posts:
    51
    Hey There!

    First off i'm really digging this asset, fine work!

    A couples questions for you.

    1. Do Occluders work with "Simple Culling"?
    2. Is there any way to use portals without manually setting up the front and back sectors? I'm working on a proceduraly generated world and cannot set them manually. If not, would you have any suggestions on an ideal way to use SECTR?


    Thanks!
    -Alex
     
  11. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hi! Good questions.

    1) Right now they do not work particularly well with simple culling. I'm looking into fixing that for an upcoming release.

    2) You can set the Front and Back sectors programatically. Just write to the FrontSector and/or BackSector properties.
     
  12. bluemoon

    bluemoon

    Joined:
    Dec 14, 2012
    Posts:
    84
    I'm not getting any error messages but it looks like Vis is no longer working? I thought something must be interfering with Vis so to make sure I setup a new project with just sectr complete. Still no error messages but no culling. here is a vid I made of your demo scene. This one is simple culling but none of the other demos worked ether.

    I'm using Unity 5.3.0f4 and Sectr Complete 1.2.1a

     
  13. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hi. Thanks for the update. Something must have broken in 5.3. I'll check it out later today. Have you tried it in 5.2 recently?
     
  14. bluemoon

    bluemoon

    Joined:
    Dec 14, 2012
    Posts:
    84
    I went ahead and created a new project with Unity 5.0.0f1 and I still had the same problem. I also tested 5.2.2f1 all the same.

    While I was at it I tested the demos for the rest of sectr. Audio works fine but I did get some error on the HDR demo. Stream works but crashes the editor once in playmode after the sectors are exported and the project is built. it seems to happen only when sectors that have been unloaded are loaded again(player back tracks the way he came).
     
  15. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    That is all super weird. I've tested extensively on many versions of 5.x and not had those issues. However I've been running mostly 5.2.1 so will try 5.2.2 and 5.3. Unity 5.0.0 was very buggy which is why SECTR is actually exported from 5.0.1.

    What version of SECTR are you using? Are you running on windows or osx? Also, which version of Unity were you using when you got the stream crash?
     
  16. bluemoon

    bluemoon

    Joined:
    Dec 14, 2012
    Posts:
    84
    I'm running windows 7. I've been able to duplicate the stream crash on both 5.2.2f1 and 5.3.0f4. I am running the 64bit versions if that makes a difference. sectr version 1.2.1a.

    I work weekends so most likely wont be able to get back to this until Tuesday.
     
  17. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    It's very kind of you to look into this in such detail. I'm back from holidays travels and looking into this myself now. Trying to repro on OSX (my main dev computer) using 5.3.1 but will switch to Win 7 if I can't repro here.
     
  18. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    FYI that I can repro both issues.

    I've reported the STREAM crash to Unity. Hopefully I'll have more info soon. Please let me know if it's blocking you.

    Regarding VIS, it actually is working, but the Picture in Picture broke in Unity 5.3. You can see that it's all working by playing a VIS demo, turning on the Unity Stats overlay, toggling culling, and watching the batch numbers go up and down. For the PiP, I'll update the demos in the next version of SECTR, but you can try it yourself by adding a SECTR_CullingCamera component to the PiP object and setting the CullingProxy to be the VisPlayer.
     
  19. UltraTM

    UltraTM

    Joined:
    Dec 8, 2013
    Posts:
    215
    Hi i have a Question,

    is it possible to also cull terrain sections of an unity terrain?

    cause we have a terrain 4000x4000 and also only the terrain uses a lot of performance.
    Thats why im focusing at sectr complete.
    we have a huge openworld and want to get as much performance as possible.
    But i only see demos and videos with floors and rooms.
    and in the complete demo 2 terrains.
    What about an big terrain or is there a way to split an terrain into more parts to be able to cull them
    like a zone system.

    you load 1 terrain tile and the 8 around when you are moving or something like that.
     
  20. Shawn67

    Shawn67

    Joined:
    Jan 2, 2014
    Posts:
    2,196
    This is what Sectr Stream does. Well, what you can do with Sectr Stream. It is a bit more flexible than that. You can actually configure how many neighbors you want to load. It also has the ability to divide a large tile into a grid of small tiles as well.
     
  21. UltraTM

    UltraTM

    Joined:
    Dec 8, 2013
    Posts:
    215
    But i need to tile my terrain by myself or to do this?

    cause the big terrain tookes a lot of performance. Thats why im looking for something to get more performance. Like World Streamer.
     
  22. Shawn67

    Shawn67

    Joined:
    Jan 2, 2014
    Posts:
    2,196
    Sectr Stream, which is in Sectr Complete if you have it, does that. You tell it how you want to segment the terrain into a grid and it divides it into Sectrs with the option to split into their own scenes even. I think World Streamer is a similar product but not sure if it segments a large terrain tile like Sectr Stream can. Never looked at or used World Streamer so I have no clue. But from your descriptions of what you are wanting to do, that is what I did with Sectr Stream when I was testing some stuff with it this past summer.

    Pretty powerful what you can do with it. We have kind of derailed Nathan's Sectr Vis thread. I'd recommend you check out the information and skim the posts in the Sectr Stream thread and then post any questions you may have about it there. It is really a quite powerful streaming tool. :)
     
    MakeCodeNow likes this.
  23. UltraTM

    UltraTM

    Joined:
    Dec 8, 2013
    Posts:
    215
    Thank you very much for that informations :)
     
  24. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    215
    I am not certain I am doing everything correctly, however it all seems correct. When I open a door into a room I get a blip, one bad frame. I used the profiler to show me WTF was happening. It seems that I get a 100ms blip in SECTR_CullingCamera.OnPreCull(). Even more specific it seems to be in Cull Join. I will attach an image so you can see what I am talking about. If I am reading this right that call is taking .1 seconds effectively dropping a frame.

    I should add I am using DunGen and purchased this because it works with DunGen. I am also using UFPS.

     
  25. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hi. Thanks for the detailed post. The problem is a bug in Unity/Mono threading. Sometimes they randomly stall a thread for 100 ms. The simplest workaround would be to set the number of worker threads back to 0 (the default). With something like dungen you should still get good VIS performance even without worker threads.
     
    hopeful likes this.
  26. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    215
    Wow that was fast! I just posted, Yea that did it, I had set the Worker Threads to 2... crazy.
     
    hopeful likes this.
  27. TDH_DrThirteen

    TDH_DrThirteen

    Joined:
    Jul 3, 2014
    Posts:
    42
    I generate all my levels entirely procedurally.
    Can I use SECTR VIS in that case or does it need manual adjustments for it to work?
     
  28. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    189
    I believe you can, but haven't tried it at runtime personally. I've generated portals and sectors on the fly with my own editor scripts though so you're not required to use the SECTR Vis tool to draw out portals & associate with sectors.

    The main thing you'll need to work out is deciding how your procedural level is divided into sectors and any rules for placing portals (or maybe just using door/connection information between rooms, depending how your procedural generation works)
     
  29. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Yes. It's totally fine. As a good example, check out DunGen which had optional SECTR VIS support.
     
  30. TDH_DrThirteen

    TDH_DrThirteen

    Joined:
    Jul 3, 2014
    Posts:
    42
    Thanks for the replies.
    My scene mostly contains of a terrain combined with a cave system that consists of individual gameobjects.
    Do you think that SECTR VIS would still be helpful for my project?
     
  31. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,963
    What matters is if you have a lot of separate little meshes that are occluded by geometry. That's what VIS works best with. It can keep the GPU from having to render all the things that can't be seen anyway.

    If you have done mesh combining and have a lot of large meshes, this could in some ways defeat VIS, as if it could see just one part of the mesh it would render the whole thing. Best to combine only those meshes which can be seen at the same time -- so something like combining the different parts of a single chamber into one mesh would be fine (in most cases). Then when VIS sees a part of the chamber, it will render the whole thing.

    Now, if you have the streaming part of SECTR already, then another very similar way to handle it would be to have each chamber be a separate sector, and use neighbor loading (or whatever) to load each adjoining sector when you are ready for it. VIS could still be helpful in that circumstance, it just depends on the details of what you're doing.

    Overall ... yes, VIS could significantly speed up the rendering for a cave system game, if you are going from first person viewpoint. In that situation virtually everything outside the current chamber is occluded, so it wouldn't have to be rendered. If you are doing a top down view - where you can see into many chambers at a time - the results would be helpful but less dramatic, as there would of course be less occlusion.
     
  32. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Exactly what hopeful said :)
     
  33. gammaker

    gammaker

    Joined:
    Feb 8, 2014
    Posts:
    11
    I'm using SECTR VIS for Dynamic Occlusion Culling with Dungen asset.
    When Camera pass through the SECTR_Portal, Game screen flicker.

    How do i do to avoid this?
     
  34. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hmm. That usually happens if there is a gap between the sectors. You can try adding a Member to your camera and setting portal determined to true, but probably you need to ask the dun gen team to look into the bug.
     
  35. mbbmbbmm

    mbbmbbmm

    Joined:
    Dec 28, 2013
    Posts:
    58
    Hi! Is it possible with SECTR VIS to have multiple culling domains active at the same time?
    Can I for instance load multiple scenes additionally (or alternatively split an existing one occlusionwise) and have each one load with their individual occluders, occludees and portals, in a way that they don't interfere with each other?

    I am trying to make a (static) portal system and I need to have one camera influenced by two or more independent sets of occlusion data.
    And also all that should work with the SteamVR plugin. Can SECTR VIS do that?
    Thank you!
     
  36. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Good questions. For the multiple scene case, you can have multiple cameras each with their own view of the world and they won't affect one another. There is not currently a way to assign some sectors and portals to one camera and some to another. The cameras will respect layers for culling, but not actually for the graph traversal.

    Regarding SteamVR, I haven't tested it and it probably doesn't work currently. I plan to look into VR culling more when I have a chance as it's an increasingly popular request.
     
  37. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    189
    Hey MakeCodeNow

    I've implemented the other type of portals in my game, Prey/Portal style- see through into an area that is elsewhere in the level. This might get confusing, so I will call my portals FakePortals, and yours are SECTR_Portals.

    I'm just starting to look at how I can get SECTR_VIS working with these.

    I made it a little easier on myself, all the FakePortals are created exactly where SECTR_Portals are, they use the same HullMesh that each SECTR_Portal uses as well. The reason for doing that is to allow some parts of the environment to be reconfigured by the player- even though it's just a rendering trick.

    I'm curious if you have any ideas for the best way to hijack SECTR's culling.

    Usually I'd just have one camera involved, but now these FakePortals use a second camera, so naturally when I'm viewing through one of the FakePortals, SECTR is often culling the room that it should see.

    SECTR_Portals are all disabled, until the associated FakePortal is connected to the "correct" room (a SECTR_Sector), then the FakePortal is disabled, and SECTR_Portal is enabled to work like normal.

    What I was thinking is during the culling, I can add a check that sees if the SECTR_Portal is disabled, but also has a FakePortal associated... if so, then the culling jumps to the FakePortal's sector....

    Problem I'm expecting though is since my camera is not there, the culling will fail anyway.

    So I'm wondering if I should just go for multiple SECTR_CullingCameras, and also if the off-axis projection used for these FakePortals will screw up how SECTR uses the camera frustum, or if it will just generate a frustum using the off-axis projection matrix I've set.

    any suggestions are appreciated!
     
  38. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    I think that having multiple culling cameras is the "right fix" as long as you save more than the culling costs.

    PS - I have one culling optimization ready to submit that will make ApplyCulling() faster in some scenes. Email support@makecodenow.com if you want to get it early.
     
  39. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    I'm wondering if it's possible to have a LOD setup on the proxy meshes. If this is possible I could have higher res proxy meshes closer to the player and lower quality ones further away.
     
  40. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    Also I'm having trouble where sector may crash on export all function. My terrain is 4000x4000 and export all seems to be stuck but I can't tell. I'm trying to break that into 256 pieces. Exporting each section manually is a pain in the butt.
     
  41. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    It is not. The idea is that the proxy mesh is the low detail version and there loaded sector is the high detail version.
     
  42. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hard to tell without looking at it. Is it crashing or just hanging/taking a long time? If it's just taking a long time, try letting it run over night.

    I'd also recommend a lower number of sectors. If you did .5k squares that would be 64 total tiles. Much more manageable.
     
  43. invadererik

    invadererik

    Joined:
    Oct 31, 2010
    Posts:
    126
    Hi I've been playing with stream and I feel like a cross between the vis culling camera and the neighbor loader would be great. Basically something like Neighbor Loader With Visibility... i.e. you have a max neighbors to load, but you only load the neighbor if its within the max and portal visible, the most possible simplified version of the cam cull + neighbor loader. You can optimize the cull using only the neighbors. Would be great = ] .
     
  44. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    This is very similar to what the door loader is intended to do. The main problem with literally doing loading based on direct visibility is that visibility can change rapidly (like looking around in an FPS) so there is a lot of thrashing as you load and unload and load and unload.
     
    hopeful likes this.
  45. invadererik

    invadererik

    Joined:
    Oct 31, 2010
    Posts:
    126
    you could maybe add an unload lag (specified by user) ?
     
  46. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    Is there a way to use the LOD sectr script on a terrain and a lower quality mesh with proxy mesh being the lowest quality mesh? I can set it up where it works but I can't get it to export.
     
  47. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Yeah, it's possible that could work but potentially still pretty thrashy. If you want to try it yourself, it wouldn't be a ton of work to write a loader like that.
     
  48. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    If you use Unity terrain it will auto LOD while the terrain is visible. If you want to use the proxy mesh feature but use a low res version of the terrain as the proxy, you'd need to convert the terrain to a mesh, something that SECTR does not do for you.
     
  49. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    Yea I have that working but I'm wondering if there's any way to have a terrain loaded in where you're standing. Then have a non terrain mesh on the adjacent sectors, then a proxy mesh for everything else. I tried to set that up but I can't get the sector to export.
     
  50. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    In SECTR there is only loaded and unloaded, and either real geometry (loaded) and proxy geometry (unloaded).