Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

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:
    477
    Hello micuccio,
    I've looked a bit into the issue, it seems SpeedTree objetcs are special objects in Unity 5, so I'll have to investigate further to see if it's possible to support them in InstantOC and if it is, I'll push an update as soon as I can.
     
    micuccio likes this.
  2. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    @unit102
    WOW! These seem like CAD/Architectural models! Not really suited for realtime usage.
    You are right, your best option is to first try to tear down the polycount before using them in Unity.
    Glad to read this :)
     
  3. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    120
    Hey thanks for your effort!
    I hope you can manage to include even these trees in the "culling system" :)
     
  4. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hello there,
    I'm finalizing an update with 2 long awaited features, after all, it's Christmas time!
    :)

    PS: I'll do a post on the InstantOC blog soon, with all the details!
     
    hopeful, Gekigengar and chiapet1021 like this.
  5. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    120
    Sorry to be pedant...
    Is there any news concerning this Speedtree objects?

    thanks
     
  6. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hello micuccio,
    no problem! I haven't yet grabbed Unity 5, my plan is to start a Unity Pro monthly subscription January 1, so I will be able to download the Unity 5 beta and immediately start the testing.
     
  7. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hy there,
    I just published InstantOC 2.1.0, should be online in 3-5 days.
    a quick changelog:
    • added terrain occlusion culling (needs multiple terrains)
    • added occludee support (good for transparent objects for instance)
    • added multiple TAGs support
    • added "Precull Check" support to lights
    I'll do a blog post with some more details about the new stuff!
     
    Last edited: Jan 17, 2015
    hopeful and chiapet1021 like this.
  8. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Good evening Gentlemen,
    in this post, I've described the new stuff in more detail.
     
  9. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
  10. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Lately some users weren't able to setup InstantOC correctly, and got objects disappearing, errors, and framerate drop... and they expressed their disappointment in form of a BADREVIEW™ on the AssetStore (without trying first to reach me for help!).
    So please, contact me if InstantOC does not work for you, it's mostly due to some setup problem.
    I would love to make it dead simple to use, but scenes are very different, and game object hierarchies can be very intricate. As far as I would really like to include a big green button "ENABLE INSTANTOC", there will be always some tweaking involved in getting it work in every possible situation.

    Now that I've taken this out, I would like to hear from you about the work-flow, do you think it could be more fluid, or easy to get it the right way? Is the Readme not clear? Should I do some more/updated video tutorials? (this one is definitely on my to do list)
    Thank you for your help, any bits are welcome!
     
  11. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    Hello. I'm considering the purchase for my procedural game, this looks like an ideal solution if it does what you claim!

    If I have a mesh with a hole in it, say, a doughnut shape, or a mesh with a cutout shader, or transparent shader so you can see through parts of it, will this solution be able to handle those situations?

    Thanks :)
     
  12. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    I just found some information in previous pages that suggest the system uses colliders. I guess that means it's not suitable for me as I only put colliders on the things I want to be occluders or occludees based on how close certain things are to them. Looks like good work though, pity I can't really use it!
     
  13. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    @Shinyclef
    Hello Shinyclef,
    thank you for your interest in InstantOC!
    Yes you can, you have 2 options:
    if it's a completely transparent object, then you simply mark it as "occludee" (new in InstantOC 2.1.0!)
    if it's a mesh with a hole, or a mesh with a cutout shader, you use a collider (or more if you use compound colliders) that resemble(s) the shape of the object (including holes)
    If you send me one or more objects with the topology/characteristics that you need, I can make a short video demonstrating it.
     
  14. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    That sounds quite good. Unfortunately my situation is a little bit different. My world is made of many objects that have cube shapes in the mesh (think blocks and chunks in like minecraft). The individual blocks get box colliders only when certain objects approach them, otherwise I go over the collider limit very easily. So, most of the objects I want to use as occluders and occludees have no colliders, until particular objects get very close to them.

    Here's another question though, do occludees also need colliders? I'm assuming they do.
     
  15. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,961
    Not sure if this strategy would work for you, but you could possibly set up a small number of large trigger colliders that could bring chunks of your scene into view at a time. Something like that could also help you manage your individual object colliders.
     
  16. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    Thank you for suggestion. It's another thing to consider. :) I'll keep InstantOC in my mind.
     
  17. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    @hopeful nice idea, should work pretty well.
    @Shinyclef yep, occludees also need colliders.
     
  18. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Glad to hear it :D
     
  19. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    I'd like to give a big thank you to Frenchfaso for his excellent support and willingness to do so, also making a great asset! I'd recommend this asset to anyone.
     
  20. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    I wonder if you could consider this idea in a future release, when adding the various scripts, have a window show up in which you want to have objects added to the occlusion culling, then once you drag/drop your objects into this window you can control things more with your asset, e.g. check that they have colliders added :) I'm just thinking of a way for your nice asset to check that all components are configured correctly .
     
  21. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Thank you very much khos85, for your kind words and appreciation!
     
  22. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    This is a good suggestion! I'm currently thinking on how to make the work-flow more fluid and error-proof..
     
  23. thendricks

    thendricks

    Joined:
    Aug 14, 2012
    Posts:
    44
    I'm having a problem with IOC, the frame rate drops and half the objects disapear when I'm right in front of them, which si a shame as I really need this tool for my mobile game, look at the images to see what's happening (Everything was set up properly by following the tutorial)
     

    Attached Files:

  24. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hy thendricks,
    thank you for your purchase!
    There is probably some problem with TAGs and/or layers and colliders, could you send me a sample scene which exposes this issue, so that I can inspect it and figure out what exactly is going wrong?
     
  25. thendricks

    thendricks

    Joined:
    Aug 14, 2012
    Posts:
    44
    Sorry, I didn't realise that I disabled my Colliders, It's now working
     
    frenchfaso likes this.
  26. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Glad to hear it!
     
  27. thendricks

    thendricks

    Joined:
    Aug 14, 2012
    Posts:
    44
    I found something(fixed), when trying to build my game I kept getting an error saying that UnityEditorInternal doesn't exist in this context in IOCcam. Something that you might want to add to prevent this(Line 40, IOCcam):
    Code (CSharp):
    1. #if UNITY_EDITOR
    2. tags = UnityEditorInternal.InternalEditorUtility.tags;
    3. #endif
     
  28. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Thanks for sharing thendricks!
    I'll push an update asap!
     
  29. unit102

    unit102

    Joined:
    Nov 13, 2014
    Posts:
    26
    I need this fix as well, I get "UnityEditorInternal" bug!!
    I wasted a full day trying to fix it with no luck, that's why i came here :(
    I am using Unity 5 for my gigantic scene (over 5+ million verts!!) but still InstantOC takes care of it :D
    InstantOC rocks!
     
  30. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Sorry for that! Did the fix suggested by @thendricks work for you?
    Glad to hear this! :cool:
     
  31. unit102

    unit102

    Joined:
    Nov 13, 2014
    Posts:
    26
    If i should write this script somewhere please explain to me how (explain in a high details because I don't know where :D ) so I don't ask you again..
    I actually tried to write it in IoCcam "#if .... " in top of the script but it doesn't seem to work.. I don't know really... I didn't write a single line on my own in unity except modifying some scripts as suggested from people in the net so I can shut Unity's mouth from screaming red line errors when I press Run time or create a build files and make it just work! :D


    tell me in details where exactly I should write it and does it start with Hash? "#" and I will do it !
    thanks guys
     
  32. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    I'm currently investigating this issue, and unfortunately the mod suggested by @thendricks does not fully solve it.
    I'll post here (and on the Asset Store) a complete fix ASAP!
     
  33. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Contrary to what I thought initially, this does not fix the issue, it does compile without errors, but it disables the TAG autosetup (introducing runtime errors, not visible in the build).
    I'll post a fix as soon as possible!
     
    Last edited: Feb 2, 2015
  34. thendricks

    thendricks

    Joined:
    Aug 14, 2012
    Posts:
    44
    Thanks
     
  35. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hy everyone,
    here is the final fix:
    in the IOCcam.cs script, you have to substitute this line (40)
    Code (CSharp):
    1. tags = UnityEditorInternal.InternalEditorUtility.tags;
    with the following lines:
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.      tags = UnityEditorInternal.InternalEditorUtility.tags;
    3.      PlayerPrefs.SetString("IOCtags", string.Join(",", tags));
    4. #else
    5.      tags = PlayerPrefs.GetString("IOCtags").Split(new string[]{","}, StringSplitOptions.None);
    6. #endif
    If you edit your TAGs (add/remove/edit), you should play the scene in the editor once, before starting the build, so that InstantOC becomes aware of the new/changed TAGs.
     
    Last edited: Feb 3, 2015
  36. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hello Folks,
    I've published the fixed version (2.1.1) on the Asset Store, should be on-line in 3-5 days.
    To apply the fix right now, just follow the instructions in the previous post.
     
  37. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hy there,
    InstantOC 2.1.1 is live on the Asset Store.
     
  38. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    421
    Changelog?
     
  39. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hello Gekigengar,
    it's a maintenance release, it includes the IOC Tag mask-fix described 2 posts above.
     
  40. unit102

    unit102

    Joined:
    Nov 13, 2014
    Posts:
    26
    thanks :)

    It works !
     
  41. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    You are welcome!
     
  42. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Currently testing InstantOC on Unity 5 RC1, it's freaking fast!
    You can pump up the Ray Samples like never before (how about 3000 rays/frame :) ) with near-zero overhead!
    (thanks to new Physics system I suppose..)
    The lights-occlusion-culling automatic probe setup is also a zillion times faster!
    (thanks to immense better prefab instancing I suppose..)
    I'm totally impressed with the performance improvements in Unity 5.

    PS: testing on an Intel Core i7 2Ghz (Laptop)
     
    Last edited: Feb 11, 2015
    hopeful, Gekigengar and chiapet1021 like this.
  43. thendricks

    thendricks

    Joined:
    Aug 14, 2012
    Posts:
    44
    a slight problem: not culling on mobile, works perfectly in editor
     
  44. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    What about on mobile? How many rays is too many on older hardware? Thanks!
     
  45. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hello thendricks,
    that's weird, on what mobile OS are you having this issue?
    Which version of InstantOC are you using?
     
  46. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hy eridani,
    I'll do a test on WindowsPhone 8.1 (Lumia 620) and report back soon!
     
    eridani likes this.
  47. thendricks

    thendricks

    Joined:
    Aug 14, 2012
    Posts:
    44
    I'm using a Samsung Galaxy S3 mini, the latest version of InstantOC (2.1.1 from the asset store) and I've also tested on an Xperia Z3 compact, I haven't yet tried IOS, it may just be a problem on android. On both devices there is no culling.
     
  48. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    It seems like PlayerPrefs is not working on some Androids, please try the following:
    in the IOCcam.cs script, change this block:
    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR
    3.      tags = UnityEditorInternal.InternalEditorUtility.tags;
    4.      PlayerPrefs.SetString("IOCtags", string.Join(",", tags));
    5. #else
    6.      tags = PlayerPrefs.GetString("IOCtags").Split(new string[]{","}, StringSplitOptions.None);
    7. #endif
    8.  
    to this:
    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR
    3.      tags = UnityEditorInternal.InternalEditorUtility.tags;
    4.      string str = string.Join(",", tags);
    5.      File.WriteAllText(Application.dataPath + "/InstantOC/Resources/tags.txt", str);
    6.      UnityEditor.AssetDatabase.Refresh();
    7. #else
    8.      tags = ((TextAsset)Resources.Load("tags", typeof(TextAsset))).text.Split(new string[]{","}, StringSplitOptions.None);
    9. #endif
    10.  
    also add this line at the top of the same IOCcam.cs script:
    Code (CSharp):
    1.  
    2. using System.IO;
    3.  
    This should work almost on every platform/device permutation, except for the WebPlayer target, which needs the original version :p
    Will check for a universal solution (comprising WebPlayer builds) soon!
     
    hopeful likes this.
  49. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    421
    Hello, I read the user guide PDF, and is thinking of purchasing InstantOC,
    I have a few questions though,
    does the OC & LOD only runs in automated periodic interval? (Every update())
    Or can it also be made to run when a function is called?
    I am thinking of an OC which does not run every update, but only when its needed,

    Does this work with more than one IOC Camera?

    If I don't need the OC, and only needs the LOD,
    does it simply use Vector3.Distance instead of raycast? (The raycast is only necessary for the OC after-all.)

    Why doesn't it support more than 3 LOD?
    I don't think it is that hard to implement more than 3 LOD.
     
    Last edited: Feb 18, 2015
  50. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    477
    Hello Gekigengar,
    thank You for Your interest in InstantOC,
    via scripting you can enable/disable InstantOC at runtime, or modifying it's parameters.
    It's usually not needed, because contrarily to what you would expect from something using raycasts, InstantOC is rather lightweight and fully optimized. Especially if you use Unity 5 (the new Physics, and thus raycasts, is a LOT faster!).
    Yes it works with more cameras, it has been already successfully used in splitscreen setups and VR setups (OculusRift).
    It can be used in 3 ways:
    - OC only
    - LOD only
    - OC + LOD
    It's a ray-based system, so it will always use rays, also in LOD only mode, but in this mode you need far less Rays than you would need for OC (LOD only has virtually zero overhead).
    Ray-based LOD is in some cases smarter than distance-LOD, because it will use lowest poly model of occluded objects, even though they are "near" the camera (but hidden behind a wall for instance).
    Adding more LOD levels is on the todo-list, but currently I'm working on code-refactoring to enable extensibility with other LOD systems.
    InstantOC and QuickLOD are already playing nice together, so if you need a more advanced/customizable LOD system, you can use InstantOC for dynamic occlusion culling and QuickLOD for LODs.
    I hope this helps, feel free to ask more questions to get a better grasp on InstantOC!
    Please read also the InstantOC FAQ to see if it suits your needs.
     
    Gekigengar likes this.