Search Unity

InstantOC - dynamic occlusion culling + LOD

Discussion in 'Assets and Asset Store' started by frenchfaso, Jan 18, 2013.

?

Should I strip out the integrated LOD stuf from InstantOC to make the code more maintainable?

Poll closed Mar 4, 2017.
  1. Yes, I never used it anyway

    50.0%
  2. Yes, I've used it in the past but will only use InstantOC for oc in the future

    50.0%
  3. No, I like it better than the Unity LOD

    0 vote(s)
    0.0%
  1. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello ShinfoK,
    thank you for your purchase, great project!
    You don't need to use some particular TAGs and/or LAYERS, just do the following:

    - in IOCcam just add to "layer mask" all the layers you need (it's a mask, so multiple layers are supported)
    - if you need InstantOC to manage objects with different TAGs just add manually the IOClod script to those objects

    as of the hierarchy, you have different options, please take a look at the Video Tutorials and the InstantOC User Guide to see how to correctly setup your objects to take full advantage of InstantOC.

    Let me know if this helps!
     
  2. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Okay, I've been playing around with with the settings a fair bit, and no matter what, I'm having no luck. As you can see in my video, objects are popping in and out even when I'm staring right at them and I'm only a few feet away.

    It's also causing an incredible fps drop in my project too...
     
  3. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    The popping is probably caused by a bad setup (colldiers and IOClod script)
    as for the framedrop, you are using way too many samples! (sorry, didn't noticed it before..) you should use some value between 150-500.

    Would you mind sending me a sample scene that exposes the problem (dropbox, onedrive, etc..) so that I can see how your gameobjects-hierarchy is setup and point you in the right direction?
     
  4. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    I was just messing around with settings then, i've been sitting at around 200 samples atm.

    My project's way too big.

    Did some testing. The way I've got my hierarchy set up:

    Object With Collider
    -----------> Object With Mesh

    I've tried the IOClod on both. On the mesh, nothing appears at all. On the collider, they appear but again, like before... popping in like the video. Tried it with removing the collider parent and just having collider on mesh, same as Object With Mesh.

    Edit: Actually, I'll try and create a small area to show you.

    Edit2: Created a small area. the pop in is noticeably LESS but still very prevalent. Plus a couple buildings aren't showing. My actual scene is quite large (8000x8000 terrain, a large town)... and popping in is happening quite a lot as you can see in the video.

    Creating a package to upload now..

    Edit3: Inboxed you a link. Cheers.
     
    Last edited: Jun 1, 2014
  5. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I felt it a little concerning that this question was ignored as i had bought it in the hope (and assurance) of some capacity to deal with terrain. Simply being let know would be appreciated
     
  6. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello lazygunn,
    sorry for the delay, I completely missed the post!
    I'm currently working on terrain support, and it's looking good, it will be added in the next update for sure, but I can't fix a date right now.
    Please take into account that you will have to "split" terrains with some utility, or use multiple terrains from start, InstantOC will not automatically split/slice terrains.
    If you feel "brave" enough, I will be glad to send you a beta version with terrain support ;-)
    Let me know if you like the idea.
     
  7. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Hey, ive actually got a streaming thing that can split the terrains and i was thinking of using this and that to take care of terrain when i'm using it. Recent idea for particular project is using mixes of voxel and regular terrain based on need in area, will have to experiment i guess. It's okay for now regarding a beta but im glad it's being looked at for the next version, although i may contact if the need to test out terrain OC arises
     
  8. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    I'm not sure if you managed to take a look at my project or not, but I'm thinking I might remove that from my buildings and such.

    I'm thinking of moving from terrain trees to individually placed trees (as I need to interact with them, so this will probably help a lot. I'm thinking the LOD system will help with this too, so I can have trees with colliders only immediately near me, trees as just mesh, then figure out something for the billboard, and hopefully the culling works without pop in on that too.
     
  9. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello ShinfoK,
    I'm currently downloading your scene (will take a while :p) I'm pretty sure the popping issue will be easily pinned out, as for the individual trees, you can certainly use the InstantOC LOD system for them.
     
    snowcult likes this.
  10. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Haha, yeah sorry about that, tried to cut the file down as much as possible!

    Alrighty, awesome. I wonder if perhaps the issue is with the size of my scene (not the one I've sent you)? When I cut the scene down to send to you, the popping was still there but not as noticeable.

    Perhaps you could perhaps tweak some settings and send me just the scene file back so I can look through and see what I did wrong?

    Thanks for the help, again, mate!
     
  11. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello ShinfoK,
    I finally managed to test your scene, the popping problem is caused by missing and not-so-accurate colliders:
    InstantOC "senses" objects through raycasting; to determine what is visible and what is not, it needs colliders (trigger only are ok too). So you basically need rather precise colliders, like mesh colliders (low-poly version are ok) or compound colliders that resemble the shape of the object.
    You can use the same colliders for collision detection and InstantOC dynamic occlusion culling, or you can have very basic colliders for collision detection on a layer of your choice and more precise colliders (set as triggers only) for InstantOC, on a different layer, it's up to you.
    Let me know if this helps!
     
    snowcult likes this.
  12. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    almost works :(

    not everything is being displayed when enabled

    but when i disable using IOChud i get

    Code (csharp):
    1.  
    2. IndexOutOfRangeException: Array index is out of range.
    3. IOClod.ShowLod (Single d) (at Assets/InstantOC/IOClod.cs:401)
    4. IOClod.Initialize () (at Assets/InstantOC/IOClod.cs:115)
    5. IOChud.ToggleIOC () (at Assets/InstantOC/Scripts/IOChud.cs:114)
    6. IOChud.Update () (at Assets/InstantOC/Scripts/IOChud.cs:27)
    7.  
    i'm testing it with Apocalyptic City Pack
    https://www.assetstore.unity3d.com/en/#!/content/17855
     
  13. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Hello Frenchfaso.
    I have now used your product pretty much, but sadly not yet for any published games...

    Anyway, I am working on my own lod system called QuickLod, which is optimized for large open worlds with little covered objects.
    But as InstantOC is unbeaten in rooms and such, I was thinking about making both products compatible.
    My idea is, that the user can switch the two systems whenever he wants, like when he enters or leaves a cave.

    I'm working now on enabling and disabling IOClod and IOCcam on the fly, and wanted to ask you, what exactly InstantOC does to the scene.
    I know, IOClod enables and disables the renderer of child object with certain names.
    IOCcam enables and disables lights when inside or outside the FoV.
    Does something else happen to?

    Be adviced, I do not sell InstantOC with my product, I just want to make them compatible.
    My lod system is not meant as a competition, but rather a complement, as booth products are optimized for different cases.

    Please tell me what you think about it.

    Greetings
    Chillersanim
     
    chelnok and snowcult like this.
  14. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479

    Hello im,
    Most of the times it's an incorrect layer / hierarchy setup in the scene, please double check the following:

    - the game objects that you want to be managed by InstantOC must be on a layer managed by InstantOC
    - either assign manually the IOClod script to this objects, or give them a TAG managed by InstantOC
    - be sure this objects have a collider, for better results use a mesh collider (with low poly version of your model if available) or a compound collider that resembles the shape of your model rather precisely

    Hope this helps, otherwise send me a sample scene that exploits the problem, I'll be glad to check it out!
     
  15. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Hey! I was wondering if there was a better way to do this.

    At the moment, I have four trees.

    -->Parent with trigger collider, IOC tag, layer and IOClod script
    ---->Lod_0 with tree mesh, capsule collider, script for taking damage
    ---->Lod_1 with tree mesh only
    ---->Lod_2 empty

    With just a few trees in, this fine, however running with tens of thousands of trees (placed via terrain composer) on my large island, is impossible and justly, unity crashes as you'd expect. And doesn't like life in the editor.

    Would it be better to just use IOC for occlusion rather than LOD in this case and use unity's built in LOD groups, since the LOD works in Editor as well as runtime?
     
  16. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello ShinfoK,
    it should work, or you can simply enable only the low-poly renderer in editor, and InstantOC will do the right thing when you press "play".
    Couple of questions:
    - is the mesh in Lod_1 a lower-res then that in Lod_0 ?
    - have you tried using only 1 collider for both InstantOC and collision?
    - is the Lod-only option enabled or disabled?
     
  17. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    QuickLod looks great! Let's make our products compatible! I sent yuo a pm.
     
  18. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Thanks, didn't think of that actually.

    It's not lower res, it's the same object as LOD_0, minus the scripts and collider, I'm trying to figure out how to do my own billboards at the moment. not sure if it's as easy as I want it to be lol.

    Well, from your previous comment, it seemed as though I need a collider on the object that has the Lod script on it, right? I also need a collider on the Lod_0 tree because the player interacts with it... though I guess I could go:

    --->Lod_0
    ------>Lod_1
    ------>Lod_2

    I assume that would work.
     
  19. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Thank you Frenchfaso.

    I've sent you an pm back.


    And something else...
    Some users have requested support for transparent objects, I had an idea for that.

    Let's asume, that all transparent objects are marked somehow as transparent, then you could check on the ray impact whether the object is transparent or not.
    Now if the object is transparent, you could fire a second ray behind the impact position with the same direction as the original ray. This ray should be handled the same way.
    You would do that as long, till you reach a non transparent object, you reach a certain max amount of second rays or you have reached the max view distance.
    The rays would only collide once with each transparent object, as the physX uses backface culling for the physics.

    With that way, you can still manage all transparent objects that use lod, but you can also manage objects behind them.
    It would also allow you, to use just one large spherical collider for lamps instead of multiple small ones.

    I have not tested the behaviour yet, but I think it will work.


    Greetings
    Chillersanim
     
  20. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Chillersanim,
    full occludee support is currently under development :p
    as a reminder, a quick and simple workaround until it's released:
    use colliders with "holes", so that some rays can go through and hit objects behind this "pseudo-occludee"

     
  21. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    I'm so happy you guys are going to try to get InstantOC and QuickLOD to work together. And I'm also glad you're working on the transparency issue. Yay! :)
     
  22. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    frenchfaso, quick question - is it possible (or if it's not currently, would you consider a way) to transition LOD changes a little more smoothly, rather than just popping from one LOD to the other?
     
  23. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello ShinfoK,
    I looked a bit into it some time ago, it's on my "wishlist" for the InstantOC LOD part too :)
    After the priorities will be released, I might dig more deeply into it.
     
    snowcult likes this.
  24. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Alrighty, cool just thought it would be worth asking :)
     
  25. ermak86

    ermak86

    Joined:
    Jan 30, 2014
    Posts:
    14
    Hello,

    I have a few questions:

    1. Can I use IOC on "Skinned Mesh Renderer" (moving objects with navmesh) ? If not... can anyone give me some advices how I can optimized them?

    2. Can I use IOC LOD on "Skinned Mesh Render"?

    With "Mesh Renderer" everything is fine, but the problem is another... for example I don't want to see moving objects with Skinned Mesh after 50 meters from camera active view (pointing/watching at them). Maybe if I can hide them behind a wall, but this working only on "Mesh Renderer".

    Thanks!
     
  26. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Hi,

    I need to remove IOC from my project. I have removed all scripts from the camera and untagged my items but IOC doesn't want to leave! :) Whenever I play a scene, the IOC menu is there. I am now getting null errors which point to the IOC scripts. Can you please tell me how to remove them?

    I liked the product but just do not need it in my project yet. Thank you.
     
  27. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    When you remove the asset, you should not get any more errors.
    If you just want to remove it from the scene, make sure that you have removed all following components:
    • IOCcam
    • IOClight
    • IOClod
    • FPSCounter
    • IOChud
    The latest of them is probably the one causing you problems.

    *** Edit:
    Added a missing component to the list.

    Greetings
    Chillersanim
     
    Last edited: Jul 25, 2014
  28. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Thanks, Chillersanim.

    Unfortunately the only way to get rid of the errors was to remove the entire package from my project. I will just import it again if I need to use it. Another thing I would like to know is how to install it, when the time comes, without having the IOC toggle on my screen during play mode. It really ruins screenshots. :)
     
  29. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Oh, I just saw, that there's another component I had overlooked...
    Look at the component "IOChud".
    This component has code dependencies on some other components and shows the hud.

    You have probably a GameObject called "IOChud" somewhere in the scene, as it is delivered as prefab in the package.
    When you remove this GameObject from the scene, you should no longer get any gui from IOC.

    Greetings
    Chillersanim
     
  30. Ernest_P_Worrel

    Ernest_P_Worrel

    Joined:
    Apr 6, 2013
    Posts:
    7
    Hello,
    I just downloaded your asset. I'm having some trouble with it though.

    If I have both the scene and game views running at the same time, I can see in my scene view that the occlusion culling is working. However, whenever I'm playing in the game view, none of the objects pop into view. I can see them pop in in the scene view, but not during game play.

    Any suggestions?
     
  31. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Then what's the problem?
    The scene view contains the exact same scene as the game view, the only difference is the render mode.
    When an object is invisible in the scene view, it is also invisible in the game view.

    It is normaly not good, when objects visibly pop into the game.
    When you still want this to happen, you could reduce the "samples" value.

    Greetings
    Chillersanim
     
  32. Ernest_P_Worrel

    Ernest_P_Worrel

    Joined:
    Apr 6, 2013
    Posts:
    7
    I guess I should have explained a little more, sorry.
    In my scene view, during gameplay, everything occludes as it is supposed to.
    In the "in game" camera, nothing is there. I can see it all render correctly in the scene view, but it never renders in the in game camera. The only thing that renders is the terrain. The collision is still there from all of the meshes, but nothing is visually rendered.
    I have a very heavily modified camera in my game (from the randomation vehicle physics asset). Maybe there is something with the way it renders things? Is there something I should look for in my camera scripts that would stop the models from rendering in game?
     
  33. Ernest_P_Worrel

    Ernest_P_Worrel

    Joined:
    Apr 6, 2013
    Posts:
    7
    Derp..
    It was the culling mask inside the camera properties. I didn't add my new Occlusion layer..

    Well at least now I can say the asset works perfect haha
     
  34. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    I wonder how you have setup the camera, that it worked inside the scene view but not in the game view...
    When no camera is registered in IOC, all objects should be culled, no matter if it is in the scene view or the game view.

    Greetings
    Chillersanim
     
  35. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    @chillersanim, thank you for sticking around here and giving your valuable help while I wasn't there!
     
  36. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Ernest_P_Worrel,
    thank you for your purchase!
    I'm glad everything works well now :)
     
  37. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Teila,
    thank you for your purchase!
    As chillersanim pointed out, to hide the InstantOC Logo from the screen, you just need to remove the IOChud prefab from your hierarchy, it's useful only to test/tweak while developing, it's a good idea to remove it for final builds.
     
  38. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello ermak86,
    thank you for your purchase, I will make some tests with "skinned mesh renderer" and report back, it should work without problems at least for normal skinned mesh renderers (no LOD).
     
  39. wolfen231

    wolfen231

    Joined:
    Apr 22, 2014
    Posts:
    402
    Hi, how would this function and work with two cameras? For example UFPS has a main fps camera and a weapon camera.
     
  40. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello wolfen231,
    thank you for your interest in InstantOC!
    InstantOC works fine with multiple cameras, also in complex setups like "splitscreen", "OculusRift", etc..
    In your case, just apply InstantOC to the main camera (fps) and leave the weapon camera as it is.
     
  41. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    174
    Hi, do the hide function only happen at start of the level? My gameobjects is only hidden when its already at the start of the level, but as the time progress, gameobjects that spawned after that, didnt hide. But if it received rays from ioccam, and get out of sight, the gameobject is hidden. Im having a trouble with gameobject that is instantiated after the start of the scene. I already add the ioclod in theprefab
     
  42. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello IllogicalGames,
    thank you for your purchase!
    I'll do some tests and report back soon, in the meantime, please try the following: disable all renderers of the Prefabs you are going to instantiate at runtime, this should fix it.
     
  43. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    174
    hi i tried disabling the renderer in the prefab object but as soon it is spawned in the scene, the renderer is enabled on its own. i have no idea how, but i think it think it received the ray when it spawned. and when it move into rayview, and move out again, its hidden
     
  44. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Do you have the "Precull Check" option enabled on IOCcam? This should only be enabled for fullscreen tests and/or final builds, it's an advanced optimization for drastically reducing flickering of distant/sparse objects.

    PS: I've done some tests (with "Precull check" disabled while in-editor), instantiated prefabs are correctly instantiated with disabled renderers and become visible only when "viewed" by the camera.
     
  45. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    174
    i did try with precull checked and unchecked. both with same result. and i forgot to mention that my main cam is instantiated after the scene load instead of it already in the scene from the start. does this make any difference?
     
  46. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    This could possibly cause the issue, let me do some more tests, I'll report back soon.
     
  47. IllogicalGames

    IllogicalGames

    Joined:
    Apr 16, 2013
    Posts:
    174
    Keep me posted ;)
     
  48. adde210

    adde210

    Joined:
    Aug 28, 2014
    Posts:
    27
    you have made many new stuff in your assets so i ask you kindly if you can do new tutos. thx appreciate it ;):) i am not that good in eng so i need videos to learn :/ i bought this and i can't figure out how to get it work (specific video on your assets and how to setup thx :)


    i really need help whit this
     
    Last edited: Sep 2, 2014
  49. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Hey frenchfaso
    Have you been able to continue working on your part of the compatibility?
    I've been asked multiple times, when the full compatibility will come, so I'm sure that there's plenty of interest.

    Greetings
    Chillersanim
     
  50. bhads44

    bhads44

    Joined:
    Feb 19, 2013
    Posts:
    37
    Hi,

    Purchased this yesterday. But now wondering is there any advantage applying this to trees as opposed to Unity's in-built system?
    Also, for rough terrains, are the rays angled vertically as well as horizontally?

    Thanks.