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. 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:
    479
    @SOULSSAGA
    Thank you very much for your purchase and your kind words!
    I'm really glad you liked InstantOC :)
    For suggestions/support/etc,, you can mail me at frenchfaso@live.com
    It's always great to have early beta testers! I'll organize some beta early access program.

    PS: Your project looks amazing, I would be pride to have it on the "Powered by InstantOC" web page.
     
  2. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    I did some tests, and gotta say, looks very, Very promising:
    Without IOC: drawcalls: 7700, fps: 16
    WITH IOC: dracalls: 600, fps: 66 <-- NICE!!!

    And this was only for floors, walls, ceiling. And there is still lot of objects to be IOCed. I need to run couple more test, and try few things more, but i'm already pretty sure i'm gonna use this for ..like everything :)

    Couple question;
    why do you add sphere collider to camera?
    Is there any other function for tag, but adding ioclod script to tagged gameobjects?


    I was thinking to modify your script to add ioclod, based on the layers i have chosen, so i could skip tagging part ..and this way i dont need to create new empty gameobject just for tag (i need tags for other reasons, and there is many different tag in layers i want to ioc).
     
  3. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    If you decide to modify the script, please share, I would also like to use the layers for tagging.
    but I have not tried it recently, I thought this was already implemented?



    Could you make it so I can select more than 1 tag, just as with the layer mask?
     
    Last edited: Oct 4, 2013
  4. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    I dont think so :) We are talking about copyrighted code here.. i can tell you how to do it, but cant share code, modified or not.

    Good idea.. didnt think of that. That should be easy. Tags are just strings, so you can make an array and loop.
     
  5. carl010010

    carl010010

    Joined:
    Jul 14, 2010
    Posts:
    138
    I think this would be amazing to have.
     
  6. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Added to the to-do list :)
     
  7. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Glad to hear this :)
    The sphere collider serves to the "PreCull check" option. It's only a trigger, so it's extremely light (no collisions).
    Yep, the TAG option serves only for automatically adding the IOClod component.
     
  8. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    Will this work if I have a mini-map camera which would view the whole scene from afar say in a RTS style game. Would there be less draw calls?
    Or is the reduction in draw calls on a per camera basis?
     
  9. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello PerfectlyInsane,
    thank you for your interest in InstantOC!
    InstantOC is a dynamic Occlusion Culling system and LOD. With Occlusion Culling, the system renders only the objects visible from the camera at any point, thus reducing draw calls. You can use it successfully with more than one camera (split screen, OCULUS Rift, etc..) so also with a MiniMap camera.
    However, in the case of a MiniMap camera, you will have to set it all up in a smart way for maximizing the performance boost.
    Let' say you have a minimap that shows almost the whole scene from a very high point; in this case the dynamic occlusion culling would render all object seen by the minimap camera (more then the ones seen by the FPS/3PS/Main camera), thus reducing the benefit of Occlusion Culling.

    One way to do a better MiniMap for Occlusion Culling would be to have a pre-rendered texture for all the static parts of your world (terrain, static objects, etc..), assign it to a mesh (square, circle, etc..) and frame it with the minimap camera, which would be synched with the movements of the main character. You could then add icons for moving objects (parent them with the real ones) and put them on a layer that is rendered only by the minimap camera.

    Please take a look at the InstantOC website, where you can find the Manual, the FAQ and some Video Tutorials to help you get a deeper understanding of InstantOC and find out if it suits your needs.
     
  10. hay78

    hay78

    Joined:
    Sep 25, 2011
    Posts:
    41
    I'm doing forest terrain environment with lots of trees, plants and rocks. Will this InstantOC cull the trees and plants which are using custom shader Moving vertex (so the leaves are animated using rgb vertex color information and the leaves has transparancy )
     
  11. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello hay78,
    thank you for your interest in InstanytOC!
    InstantOC uses colliders to "sense" game objects and render them if visible from the current camera position in realtime. For great precision it is normally better to use mesh colliders (low poly version of the original mesh is optimal choice) or compound colliders.
    So I guess the answer to your question is, it depends.
    Currently you can't have vertex-animated mesh colliders in Unity (perhaps you can achieve this in a custom way, but it would probably be really slow..)
    So it would not be the best solution to use it on a per-tree basis, BUT you could parent a bunch of trees in a group and assign a collider that resembles the shape of the tree group, that way, InstantOC would cull group of trees, the groups near the player would be visible and the distant/occluded ones would be hidden. You could also take advantage of the integrated LOD system in InstantOC and use non-animated/low-poly version of the tree groups.
    Please take a look at the InstantOC website, where you can find the Manual, the FAQ and some Video Tutorials, to gain a deeper insight about InstantOC and better understand if it suits your needs.
     
  12. loadexfa

    loadexfa

    Joined:
    Sep 2, 2008
    Posts:
    214
    I'm having an odd issue with InstantOC. I configured it in my scene, played it in Unity and everything works well. I like what gets turned on and off and in the game window there is no popping in or out.

    When I build for mobile (Nexus 7, iPad 2), it doesn't work nearly as well. Some models will pop on the edges and I've tried tweaking values to prevent this from happening with no success. In addition, some models will not show up even when the camera is pointing directly at them. Nothing like this happens when I play the same scene in Unity.

    Any ideas on what I could be doing wrong?

    Thanks in advance.
     
  13. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello loadexfa,
    thank you for your purchase!
    There shouldn't be any difference, that's weird.
    Could you please send me a sample scene that exposes the problem, so that I can test it on my Nexus and find out what's going on?
    You could use something like Dropbox or Skydrive to share it with me.
     
  14. loadexfa

    loadexfa

    Joined:
    Sep 2, 2008
    Posts:
    214
    Thank you for the fast response! I will prepare an example and share it with you sometime today.
     
  15. Adragen

    Adragen

    Joined:
    May 4, 2013
    Posts:
    25
    Hi i just purchased this tonight and set everything up exactly as your documentation say's and it does nothing? I am getting no performance increase toggling IOC on or off and am not even getting any visual reply to as if it were working, i also followed your video tutorial step by step and still nothing, i'm sure i may be doing something wrong as i can see so many having good results but for the life of me it just isn't working...please help :)
     
  16. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Adragen,
    thank you for your purchase!
    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

    Keep in mind that if you want to see the "effect" of InstantOC (hiding/showing game objects), for instance from a TOP view in the editor (while playing) it's better to turn off the "PreCull Check" option in the IOCcam script.
    Also, in small scenes with few objects, especially on PC with powerful graphics-cards, occlusion culling in general does not help much; it's in big levels with many game objects and/or especially on mobile (constrained power) that you see the full power of this technique and of course of InstantOC.

    If you have trouble setting up InstantOC please send me a sample scene that I can inspect, to point you in the right direction.
     
  17. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    This is on my next buy list :D
     
  18. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    615
    Is there pop in when switching lod's with this asset?
     
  19. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello blueivy,
    thank you for your interest in InstantOC!
    Please take a look at the InstantOC webplayer demo (or download one of the builds) to see InstantOC LOD system in action.
    The Houses in the demo have 3 Lods.
     
  20. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello POLYGAMe,
    well, thanks :)

    PS: Your country is awesome! The most beautiful trip i've ever done.
     
  21. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Is this hard to set up? I have a game where the player can switch from a first person camera to a (different) third person camera to an overhead camera whenever the player wants. Is there a lot of scripting to get InstantOC to work with three cameras like this? Thank you!

    Nice demos by the way, I like the Nexus 7 one since I am also targeting Android.
     
  22. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello eridani,
    Thank you for your interest in InstantOC!
    To use InstantOC with multiple cameras you only need to add the IOCcam component to every camera and when you switch active camera in your game, simply disable the inactive cameras. That's it!
    If you eventually get InstantOC, I will be glad to help you with the setup.
     
  23. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Please help. This sounds great but as soon as i run my scene i get the error:

    "screen position out of view frustrum" then some coordinates

    Also any object thats on the specified tag/layer is invisible even when i am looking right at it? I can still collide with it
     
  24. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello TheAMes,
    thank you for your purchase!
    could you please share with me a sample scene (via dropbox/skydrive/etc,) that I can inspect to see what's wrong?
     
  25. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Whoops my bad. I didn't change the samples it was on 0! I'm an idiot!

    I have a problem though. I have a bunch of crates along a corridor and they keep flickering visible a then invisible. Very quickly. I changed the delay and it's better but it just waits the amount of time then hides one or 2 then shows them again and hides others. I probably just need to change the settings but I'm not sure what.

    I don't know if it's related but it's a fps and it has view bob so even standing still the view slowly moves up and down but it's not enough to warrant hiding the crates. Hope I'm making sense
     
  26. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello TheAMes,
    please check the following:
    - try a higher "Sample" value (300-400)
    - set the "Rays FOV" to your camera fov + 10 (so if camera fov is 60 set Rays FOV to 70)
    - are the box colliders of the crates same size as the crates?

    PS: view bob should not be a problem
     
    Last edited: Nov 18, 2013
  27. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Do mesh colliders cause a problem? I'm not sure as I'm not at computer but they may be mesh colliders
     
  28. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Just read mesh colliders should be fine. I'm sure I tried all different values and it done the same thing but I'll retry in the morning. I'm using the realistic fps asset if that make a difference
     
  29. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    The FOV fixed it thank you so much!! This is an awesome asset!!!

    I have one more issue and not sure its fixable.

    I have glass in my game, obviously instantoc hides everything behind the glass, is there anyway to get around this?
     
  30. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello TheAMes,
    glad to hear this!
    Glass is not a problem, simply use a collider with "holes" for the windows, or even no collider at all for the glass parts of your model.
     
  31. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Thanks for the reply but this isnt an option for me as my glass can be shot and smashed, so needs a collider and material
     
  32. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hy TheAMes,
    please try one of the following:
    - put the glass on a layer not managed by InstantOC, the rays will pass through, but InstantOC will not hide/unhide the glass
    - add a second collider to the glass object (with holes) and put this collider (and only this) on a layer managed by InstantOC
    with the second option you will be able to both, have the glass getting smashed and also be managed by InstantOC.
     
    Last edited: Nov 21, 2013
  33. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Thanks for the suggestions. I managed to get around it in a similar way. I moved the glass to a different layer not managed by ioc which stopped it hiding things behind it but also as you say stops the glass from being hidden.

    My glass is a child object of a window frame. The frame is included on the ioc frame and tag. So all I done was via script hide and show the child glass object by subscribing to the on render visible and invisible events of the parent window frame. Works a treat. Thsnks for the quick responses I'll leave a review on your asset in the morning. It's definitely the best asset I have purchased. Our game wouldn't even be possible if it wasn't for this so I'll be sure to put you in the credits
     
  34. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Thank you very much for your kind words! Really appreciate it!
    It would be awesome to have InstantOC in the credits of your game, and if you agree, I would be glad to have it on the "Powered by InstantOC" gallery on the InstantOC webpage.
     
  35. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Thank you, your asset is now on my to-buy list! I do have a question about using your system with a mesh-combining LOD system on the Asset Store called Mesh Baker 2. Can you give me any insight on how they might be able to work together? I posted a question to the owner of that asset as well, which I will post here, so you can give me any advice. Thanks again!

    Message to other asset owner:

    Hello I'm new to Unity and I have a question about optimizing on mobile, so please bear with me.

    I don't have Unity Pro. I was wondering if Mesh Baker 2 will work with any of the off-the-shelf asset store occlusion culling systems like InstantOC, which shoots out raycasts from the current camera view and turns off the renderer of any object that isn't hit.

    I'm trying to understand the advantages of drawcall reduction vs occlusion culling.

    Let's say I have 1000 mesh rocks in my scene, your system can combine them all into one giant mesh at runtime right? That would reduce the drawcalls from 1000 to 1? But now if the current camera view sees just one rock, it will now render all 1000 rocks, correct? So now even though the drawcalls have been reduced dramatically, the amount of vertices always being rendered will be way higher than using a culling system.

    I assume a culling system will only make drawcalls for the amount of rocks currently seen by the camera...so for example if there are currently 10 rocks in view, that will be 10 drawcalls, but with much much fewer vertices. Can you tell me what performance will be better? 1 drawcall with lots of vertices, or 10 drawcalls with much fewer vertices?

    Or maybe I could combine both strategies...maybe I could use your system to bake out groups of rocks that are clumped close together, so instead of one large mesh I could have maybe ten groups of 100 rocks each. Then I could feed those groups into an occlusion culling system and cull any group not seen by the camera. So it would be sort of a compromise between drawcalls and vertices rendered.

    Please let me know what is possible for the best performance using your system possibly together with culling, with Unity Free. Thank you!
     
    Last edited: Nov 23, 2013
  36. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    @eridani
    thank you, glad to hear this :)
    The next update of InstantOC fully supports Unity's dynamic batching, so effectively combining both techniques (should already be live.. will publish it next week).
    As you pointed out, if you bake many meshes in a single mesh, InstantOC will treat it as a whole, but if you can bake groups of objects together as you suggested, I suppose it should work fine.
    Regarding the question "what is better, batching or occlusion culling", I think there is no single answer, it depends on the scene (how much geometry, complexity of materials, etc..), occlusion culling techniques will probably scale better for very large scenes with lots of meshes occluding each other; but if you manage to use both techniques, well, then you get the best results!
     
  37. joeee19

    joeee19

    Joined:
    Jul 14, 2012
    Posts:
    56
    Looks good so!
    Culling is effective terrain?

    I want to make the system open world games for iOS using the Terrain.
     
  38. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello joeee19,
    thank you for your interest in InstantOC!
    InstantOC will effectively hide objects behind a mountain, for instance a village/city, etc;
    if you want to show/hide portions of the Unity-terrain, you could achieve this with some utility like this one.
    Please take a look at the Manual, the FAQ and the Video Tutorials, to get a deeper insight into InstantOC, and see if it suits your needs.
     
  39. Jasper1900

    Jasper1900

    Joined:
    Mar 15, 2013
    Posts:
    26
    Do you also include a script wich let you render a low poly version (like in the LOD) if you have more than a certain number of objects rendered?
     
  40. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello semmie1900,
    thank you for your interest in InstantOC!
    I'm not sure I completely understand your question...
    InstantOC includes a LOD system, you have to provide the low-poly models, it does not automatically do polygon reduction.
    For more info about InstantOC, please take a look at the InstantOC website where you can find the Manual, the FAQ and the Video tutorials.

    Hope this helps :)
     
  41. fos_smookie

    fos_smookie

    Joined:
    Jul 7, 2013
    Posts:
    5
    Hello Frenchfaso,

    We have purchased your InstantOC asset. Is there any swift way to get information on current LOD displayed? We need that information to get access to bones for characters that use your lod system.
     
  42. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello fos_smookie,
    thank you for your purchase!
    yes you can do it this way:

    first, change the "currentLod" variable in the "IOClod" script from private to public:
    change this line in "IOClod"

    Code (csharp):
    1. private int currentLod;
    to this:

    Code (csharp):
    1. public int currentLod;
    then, in your script, you can access the "currentLod" variable like this:

    Code (csharp):
    1. int currentLod = myGameObject.GetComponent<IOClod>().currentLod;
    It's an int value, from 0 to 2, with
    0 for the high-res lod
    1 med-res
    2 low-res

    Hope this helps, feel free to contact me if you need more info.
     
  43. fos_smookie

    fos_smookie

    Joined:
    Jul 7, 2013
    Posts:
    5
    Hello, thanks for swift answer, that was very helpful indeed.

    We are also looking the issue with animator controllers. How can we set it up so that there is no significant drop in performance?

    Should all lods receive animator controllers or maybe you have another walkaround for this? What about synchronizing animators between LODs?
     
  44. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Glad to hear this :)

    Would you mind sending me a sample scene with an animated LOD group so that I can do some tests?
     
  45. mohitj

    mohitj

    Joined:
    Mar 30, 2013
    Posts:
    12
    Hello,

    I just purchased your IOC app. I ran into couple of problems and your help is really appreciated. When I run my game in Unity editor it runs but I am getting following error:

    IndexOutOfRangeException: Array index is out of range.
    IOClod.Update () (at Assets/InstantOC/IOClod.cs:139)

    On iOS it is crashing and while previously I was able to get at least 15 FPS on iPad 3, I am getting only 3 FPS, before it crashes.

    Please let me know how can I be able to solve this problem,

    Thank you,

    With best regards,

    Mohit
     
  46. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Mohit,
    thank you for your purchase!
    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!
     
  47. mohitj

    mohitj

    Joined:
    Mar 30, 2013
    Posts:
    12
    Hi,

    Thank you for your recommendation. I will check and get back to you soon. I was using the Default layer as most of my object are in that layer and assigned it in the IOC editor. Maybe I need to change that and create a separate IOC layer.

    With best regards,

    Mohit
     
  48. mohitj

    mohitj

    Joined:
    Mar 30, 2013
    Posts:
    12
    Hi,

    I think the problem was I was using terrain in the IOC also and that was giving the error. After removing it I did not see any error. Is there a way to make it work for certain sections of the terrain also. For examples the trees.

    Thank you,

    Mohit
     
  49. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Mohit,
    the Unity terrain system manages the trees (grass, detail objects, etc) on its own, if you want InstantOC to do occlusion culling and/or LOD on tree models, you have to place them in your scene as normal game objects/prefabs.
    Nonetheless you will have correct occlusion culling for game objects behind hills and mountains for instance; substantially, you can use Unity terrains as occluders.
     
    Last edited: Jan 2, 2014
  50. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    Hi. Frenchfaso.

    I have just bought IO, it works great but I have a question.

    For the characters, they animate so their physics collisions are very simple. Now, I do understand that it is difficult to make character to occlude the others when their collisions are not very accurate, so that is ok with me. However, is it possible for them to be just occludee? Meaning if their collions are hidden by the others they don't draw. They don't need to contribute to the occlusion. This is super useful for me. The same goes to the lights.

    Any ideas?