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. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Is it possible to occlude GameObjects which are instantiated at runtime?
     
  2. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Yes, and that's exactly why its dynamic.

    Procedural contents will be culled, even if its not baked (Unlike Unity's Umbra Occlusion).

    The reason why this asset is damn good!
     
    elmar1028 and frenchfaso like this.
  3. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    @elmar1028 yes, as @Gekigengar kindly pointed out, InstantOC is a fully dynamic occlusion culling system, as such it can do occlusion culling in real-time, without any need of baking/pre-calculation: runtime instantiated prefabs/game-objects, moving objects, procedural content etc.. all good :)
     
  4. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Sweet! Thanks a lot! Will buy it for sure ;)
     
    frenchfaso likes this.
  5. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    You are welcome!
    Thanks! Great to hear this :)
     
    elmar1028 likes this.
  6. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    BTW. Unity 5 is out (wohoo)

    Is it compatible with it?
     
  7. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Yep! It's already compatible with Unity 5, in fact, InstantOC is much faster with U5,
    thanks to the new Physics system in Unity 5 --> you can now use a much higher Ray Samples value, with less overhead!
    And I'm just polishing v 2.2.0 which takes advantage of the new rendering/lightning pipeline to achieve a much cleaner/lighter support of real-time shadows (geeky details coming in a post within a few days!)
     
    elmar1028 likes this.
  8. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello there,
    just submitted InstantOC 2.2.0 to the Asset Store, there are now 2 parallel versions:
    • one for Unity 3.5 to 4.x
    • one for Unity 5 and up
    in both versions I've added a final solution to the IOC Tag mask bug (works now on all platforms included Webplayer)
    in the Unity 5 version, I've upgraded the real-time shadows support, which is now lighter and cleaner.
    And of course the Unity 5 version has now an updated demo scene with the new material :) (unfortunately it still looks ugly, I suppose I'll have to come up with a nicer demo!)
     
  9. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Bought your asset. Set everything up according to your tutorial (which is outdated). But all objects marked as specific layer has disappeared, but still there. I am making a 2D game, what do I need to do? I also have 2 cameras: 1 is player camera and another is a minimap. I put IOC script on a minimap camera.

    Also, it would be nice if you had a documentation page on your website.
     
  10. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello elmar1028,
    I think there has been a misunderstanding,
    as mentioned in the InstantOC FAQ, occlusion culling techniques in general, are not useful in 2D games.
    Occlusion culling is very powerful in FPS/3PS projects with many models, and much occlusion going on.
    I will arrange a refund for You, if You don't want to keep InstantOC, perhaps for future 3D projects!
     
  11. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    224
    I just bought this to play around with it. Once you add the IOCCam component to the camera it starts polling in the editor for the component doing something, which renders the the editor entirely useless for any component on the camera (it takes 1-2 seconds to get a click to register, if it even registers). I suspect it is serializing something constantly. Commenting out the editor stuff removes this polling. You can see the wait cursor popping up every half a second or so. This happens on your samples as well on a fresh project, although less frequently. My project is quite large so I suspect the serialization takes longer.

    Also, why are there no reasonable defaults for the component when you drop on the camera derived from the camera's settings?

    Unity 4.6.1f1
     
  12. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello DirtyHippy,
    thank you for your purchase, it's a known issue, one other user reported same behavior, I'll send you a private msg with a fix (and instructions to apply it); an official update is already on it's way to the Asset Store.
    Good point! Will add that for sure.
     
  13. Jalechah

    Jalechah

    Joined:
    Mar 12, 2014
    Posts:
    10
    Hi,
    I mentioned that I was having an issue with flickering in my scene on the assets that are being affected by the IOC.
    The flickering is affected by the Hide Delay. I'm making a street view of sorts. and the buildings that are close to the camera seem fine (don't flicker). I've tried playing around with the Sample Slider on the IOC HUD but no luck fixing it. They still flicker. The timing of the flickering is affected by the Hide Delay Slider. Please help!
     
  14. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Use Unity LOD (Umbra) for scenes that are not procedural.

    It seems to me that the town is static anyways, just bake an LOD with Umbra and you'll be fine.
     
    Last edited: Mar 20, 2015
  15. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Jalechah,
    buildings are rather big objects, even if distant from the camera, so there shouldn't be any flickering issues..
    would you mind sending me some screenshots that I can inspect, to understand the kind of scene you have?
    Do the buildings use approximate collliders, or precise colliders (mesh colliders)?
     
  16. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    when i set the objects to their specific layers( 'IOC' for me ) the objects are gone.. i'm using 4.6.3 unity
     
  17. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello cjrussel14,
    thank you for your purchase!
    How does the hierarchy of these objects look like? Is there a parent-child hierarchy?
    Do you use TAGs auto-setup or do you place manually the IOClod script on these objects?
     
  18. Jalechah

    Jalechah

    Joined:
    Mar 12, 2014
    Posts:
    10
    [/URL][/IMG]
    Unfortunately I can't Bake any of the built in features because all the buildings are randomly generated in the Start function. This is why the instant OC has been so useful to my project.


    Pics:

    All the Buildings are now using Mesh Colliders. The green highlighted buildings in the picture are the buildings that suffer from the flickering. (I have also tried using box colliders but that caused a bit of popping )

    here's the Main Camera info
    I'm not sure what other values might help with the issue. If you need any other info just let me know and i'll provide it as soon as possible.
     
  19. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    i didn't mess with the setup, i use the default one. i insert the script manually
     
  20. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    @Jalechah what are your InstantOC settings? (Ray Samples, Ray FOV, Precull Check, etc..)
    usually enabling "PreCull Check" and increasing "Ray Samples" a little bit helps a lot with flickering.
    In some cases, it may also help grouping near objects together (place them under an empty game object, and assign the IOClod script only to this parent game object).
     
  21. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    @cjrussel14 would you mind sharing with me a sample scene that exposes the problem, so that I can inspect it and find out what's wrong?
     
  22. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    do you plan on fixing everything for unity 5 release? i just imported it :
    Code (CSharp):
    1. Assets/InstantOC/Editor/CrossPlatformInput/CrossPlatformInputInitialize.cs(8,18): error CS0101: The namespace `UnityStandardAssets.CrossPlatformInput.Inspector' already contains a definition for `CrossPlatformInitialize'
    2.  
    and 50 warning because of it use an obsolete version of standard asset, would it be possible to make a version of instantOC "clean" without the standard asset stuff? if i delete the standard asset folder:

    Code (CSharp):
    1. Assets/InstantOC/Scripts/IOChud.cs(3,38): error CS0234: The type or namespace name `FirstPerson' does not exist in the namespace `UnityStandardAssets.Characters'. Are you missing an assembly reference?
    2.  
    not usable in unity 5 right now for me if there is dependency on unity 5 beta assets:(
     
  23. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    That's strange,
    I use it on Unity 5 without problems, in fact, the latest version already comes with a custom build for Unity 5 that takes advantage of the new lightning/rendering pipeline for a lighter/cleaner support of realtime shadows.
    I'll do some tests and report back soon.
     
    Last edited: Mar 27, 2015
  24. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    im using the last version of standard assets for AI, the version included in your package is older, so conflicts came from here, would it be possible to package the demo inside an .unitypackage ?
     
  25. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Are you using the Standard Assets that comes in the Asset Store?
     
  26. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    no the one that we download within the installer then import using Assets>import package
     
  27. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    That's the same that you find in InstantOC!
    Would you mind sharing with me a sample scene that exposes the problem, so that I can inspect it and find out what is going on?
     
  28. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    the project is pretty big right now, i have succeed in cleaning it anyway, now i have two problems, when i select the camera with IC script and see it inspector window, i have 2~4 fps when i run the scene and editor is extremly slow, as long as i select an other object it run fine.

    second problem is object popping when we move or quickly turn the camera, i have tested almost all combination of FOV/max rays/timer its still pop few seconds later or even if i enter an area for the first time all object renderers will be enabled over 5 ~ 10 second
     
  29. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Just saying that mixed versions of the assets do exist. I have found at least 3 versions of the Ethan skinned model too.
    Also the car gearing breaks when switching up versions, as does the 3rd person controller and few other things I probably forgot. (oh yeah 3 different folder naming structures, the avatar for walking 3rd person gets mangled, err... there is probably more)

    Many Authors are simply name-spacing the EXACT version they want to bundle., or renaming the classes to their own unique names (as functionality may change going forward). Others have replaced all references to Standard (or Sample) Assets with something free and unique to just forget about the problem.

    Basically bundling "Standard" Assets is shifting sand. Don't build your house there...
     
    Last edited: Mar 27, 2015
    frenchfaso likes this.
  30. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    @twobob good point, I'll take the renaming approach.
     
    twobob likes this.
  31. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    That's a known (rare) issue, I'll send you a patch with a pm right now, the final update is on it's way to the Asset Store.
    Good values are:
    Ray Samples: 200-400 for mobile 300-600 for desktop
    Ray FOV: 10-20 more than Camera FOV
    PreCull Check: enabled (for full-screen in-editor preview and/or final builds)
    This should be fine for every popping/flickering issues, unless you have very small/distant objects and poor occlusion in your scene, in such cases, no occlusion culling technique will be of help, you'll have to use LOD (which InstantOC also provides) and/or geometry/material batching.
    Could you send me some screenshots, so that I can understand the kind of scene you have and point you in the right direction?
     
  32. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
  33. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Ok, now I see :)
    the small gray stones and the grass objects are really too small, you should group them together and/or parent them to bigger objects, for instance, you could group the grass and the stones that are near a tree with the tree together, so that when InstantOC "sees" the tree, it will also unhide near grass and stones objects.

    The hierarchy should be as follow:
    • Parent (empty game object) IOClod script (or IOC Tag)
      • tree (mesh and collider, IOC layer)
      • grass_1 (collider not required)
      • grass_2 (collider not required)
      • stone_1 (collider not required)
      • stone_2 (collider not required)
    or also this way:
    • Tree (mesh and collider, IOC layer) IOClod script (or IOC Tag)
      • grass_1 (collider not required)
      • grass_2 (collider not required)
      • stone_1 (collider not required)
      • stone_2 (collider not required)
    I would say, colliders for grass and small stones are not required, because with high probability, InstantOC rays will hit first the tree collider and with the above hierarchies, InstantOC will automatically show/hide all child objects.
    Let me know if this helps!
     
    Last edited: Mar 27, 2015
  34. Jalechah

    Jalechah

    Joined:
    Mar 12, 2014
    Posts:
    10
    Hey guys, the flickering problem seems to have sorted itself out. thanks.
    Is Instant OC unity 5 ready? I tried to move my project over and i'm experiencing some buildings turning bright purple instead of being invisible. Not sure if it's due to the invis shaders in instant oc or something else.
     
  35. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Jalechah,
    glad to hear this!
    Yes, it's ready and optimized for Unity 5, but having moved from a unity 4 project you probably have the unity 4 version of InstantOC, just open the Asset Store from Unity 5 and re-download and import InstantOC, this should get you Unity 5 optimized version.
     
  36. DDDiscover

    DDDiscover

    Joined:
    Dec 10, 2013
    Posts:
    17
    Hello Frenchfase,
    I really hate the popping effect of the LOD system of Unity.
    Does this InstantOC solve this? If so, I will certainly buy this!
     
  37. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello DDDiscover,
    thank you for your interest in InstantOC!
    Do you mean the sudden switch from one LOD level to the other? Currently it's the same with InstantOC, you probably should search for some LOD system that does some smooth "cross-fading" between levels.
    I will inspect this possibility for some future update, but it will probably be added only to the Unity 5 branch of InstantOC (the new universal material/shader should make it possible in a cleaner/easier way then before).
     
  38. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi frenchfaso,

    Is there a fix for the problem DirtyHippy mentioned before? Two weeks now and im having the same problem. I cant use IOC for the moment. Using unity 5.0.1.

     
  39. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Project Mysh,
    the official update has yet not landed on the Asset Store, I will send you a PM with the patched version right now.
     
  40. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hy Project Mysh,
    I just sent you the patch, let me know if it helps.
     
  41. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there frenchfaso,

    Thanks for the fix.
    If you're working on the next version , I propose two ideas to improve your asset:

    1. Disable the general control of LODs in IOCcam, and use Lists to create infinite amount of LODs in IOClod (or at last, maximum of 7 LODs). General control of LODs its ok but in real world, in a final product, for optimization reasons, all developers tweak every model LOD separately, without exceptions. If you want to keep the General control of LODs in IOCcam, you could use a LOD multiplier (as the default quality settings from unity).

    Example code using infinite List to get all renderers from child obj:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class LodIOC : MonoBehaviour {
    5.  
    6.     public List<Renderer> Lods;
    7.     int LODnumber;
    8.  
    9.     void Start () {
    10.         Lods = new List<Renderer>();
    11.         for (int i=0;i<transform.childCount;i++){
    12.             Lods.Add (null);
    13.         }
    14.         foreach (Transform child in transform) {
    15.             LODnumber = int.Parse(child.gameObject.name.Substring(name.Length-1));
    16.             Lods.RemoveAt(LODnumber);
    17.             Lods.Insert(LODnumber, child.gameObject.GetComponent <Renderer> ());
    18.         }
    19.     }
    20. }
    The result of this code is an ordered list of renderer components of LODs (Lods[0] = Lod_0, Lods[1] = Lod_1, etc...).

    2.
    Send a float to the material (unity LODgroup uses unity_LODFade.x) and configure the LOD system to work wtih cross-fade transitions.
     
    Last edited: Apr 15, 2015
  42. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    You are Welcome!
    actually, you can already customize each InstantOC LOD, just change settings in the IOClod panel, this will override the general LOD defaults in IOCcam panel
    that's on the to-do list of InstantOC, in the meanwhile, you can combine InstantOC with the excellent QuickLOD from chillersanim
    currently inspecting this possibility for the Unity 5 branch of InstantOC
     
  43. FaberVi

    FaberVi

    Joined:
    Nov 11, 2014
    Posts:
    146
    Hi frenchfaso, I have a problem with the occlusion of objects behind walls ... That is if I see a wall behind objects, in the same direction are not closed .. There is a way to "lock" the view up to the wall so no Render objects behind?
     
  44. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello D3m0n,
    I'm sorry, I'm not sure to understand your issue, could you perhaps provide some screen-shots to point out the problem?
     
  45. FaberVi

    FaberVi

    Joined:
    Nov 11, 2014
    Posts:
    146
    upload_2015-5-21_19-27-6.png

    The shower and toilet should not be rendered because they are behind a wall and not "visible", it is possible to solve in some way that I do not?
     
  46. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello D3m0n,
    sorry for the delay!
    Sure, just add an IOC Tag and IOC layer also to the wall game-object, this way it will occlude the objects behind and InstantOC will hide them.
    Let me know if this helps!

    PS: while testing in editor, disable "PreCull Check", this ensures predictable behavior with multiple views in editor.
    Remember to enable it always for full-screen preview and final builds!
     
    FaberVi likes this.
  47. DivergenceOnline

    DivergenceOnline

    Joined:
    Apr 19, 2015
    Posts:
    244
    While i'm waiting on that file you mentioned; Do you have to assign both the tag and layer to objects you want to occlude, or can you just assign that tag? Because I got some strange lighting when i put objects on the layer.
     
  48. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    basically you need both, you have 2 options:
    ioc layer + ioc tag
    ioc layer + manually add IOClod script to object (for overriding global settings)

    PS: update is almost ready
     
    FaberVi likes this.
  49. FaberVi

    FaberVi

    Joined:
    Nov 11, 2014
    Posts:
    146
    Unfortunately the layer of the wall can not be set on the IOC, as I share parts requiring another layer set, you can overcome this limitation with maybe only the tags?
     
  50. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello D3m0n,
    no problem, you don't need a specific layer, just set the layer on which the wall is, in the "Layer mask" on the IOCcam panel. It's a mask, so you can specify more if needed.