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
    Hy Chillersanim,
    Unitys dynamic batching is kind of "choosy"..

    http://forum.unity3d.com/threads/102739-How-to-get-Dynamic-Batching-to-work

    give a look especially at the last post.
     
  2. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    Yeah thanks, i was trying to say it hahah.
    The Terrain Collider is the key.

    Enjoy this free bump
     
  3. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Hmmm, even if I add multiple objects from the same prefab, they don't get batched.
    Even if I directly place some models from the source (same model but multiple instances) somewhere, they don't get batched.

    I use .jpg as texture so it has no alpha. I don't use lightmaps, al objects have the scale 1,1,1. I don't use shader (unless your script would use them what I don't think...), and I don't instantiate any objects by code...

    I do not understand the following sentence:
    "layering other objects in between objects trying to batch can break batching"
    That doesn't mean parrenting, does it?

    Short to explain how I import and setup my models.
    I save the .blend (I'm using Blender) file somewhere in the assets folder.
    From the importet object I set the materialsearch to project wide, the normals to calculate, delete all materials and reimport so that no material doubled.
    After that I set up the LOD for a single object and after that I create a prefab wich I use from that moment on.

    Do you have any idea what I could possibly have forgotten?

    Greetings
    Chillersanim
     
  4. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    You put the tags and the layers?, that sounds strange.
     
  5. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Well i put the tag to ioc and the layer to IOC, as shown in the tutorial from InstantOC.
    Is that the answer to your question?

    Greetings
    Chillersanim
     
  6. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    I mean in the camera and in the object
     
  7. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Hmmm no. I didn't change the camera settings, but only the object settings.

    The camera tag is MainCamera, the Layer is undefinied.
    The objects tag is ioc and layer is IOC.

    Edit:
    I will look tomorow, and if I don't find the failure, I will create a new discusion, so that this one doesn't get filled with offtopic stuff ;)

    Greetings
    Chillersanim
     
    Last edited: Apr 22, 2013
  8. Psyckosama

    Psyckosama

    Joined:
    Mar 20, 2013
    Posts:
    88
    How does this perform in comparison to SmartLOD?
     
  9. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Psyckosama,
    thank you for your interest in InstantOC!
    InstantOC and Smart LOD are 2 different products with an area of overlap:
    InstantOC is a Dynamic Occlusion Culling solution for Unity, with built in ray based LOD.
    SmartLOD is an excellent LOD solution for Unity. (no occlusion culling)
    Thus it would be not fair to compare a "Dynamic OC + LOD" solution vs a "LOD only" solution.
    Please take a look at the faq, to gain a deeper insight on InstantOC, and the video tutorials, to see how to work with InstantOC in Unity.
    Feel free to contact me if you have further questions.
     
  10. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Hmmm, I once bought smartLOD. But on the store, there was only an old version wich threws errors (I'm using Unity 4.1.2f1). Additionaly to that I saw after the trade, that the discussionto this tool wasn't used for over a year. After that I decided to use frenchfaso's OC, with which I am verry happy. ;)

    Would be great if those two tools could be combined for maximum performance (or do I think something wrong?).

    Greetings
    Chillersanim
     
  11. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    I'm glad to hear that :)
    It would be awesome if you could find the time to leave a review on the Asset Store!
     
  12. Etienne-L

    Etienne-L

    Joined:
    Apr 24, 2013
    Posts:
    5
    Hello Frenchfaso,

    I have a big scene, but it is filled with a huge number of trees and grass and small mountains (mountains I mean the terrain appearance.. and on some places a "mountain" hide the vision of some objects on scene)...

    The entire scene is not filled with big objects like houses... there are only few houses and some animals spread on the scene.
    Will the InstantOC work to speed up this kind of scene? ;)


    Best Regards,
    Etienne L.
     
  13. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Etienne,
    thank you for your interest in InstantOC!
    Are the trees and grass from the Unity terrain system?
    InstantOC cannot manage this kind of trees and grass, they are automatically managed by the built in terrain system.
    But if you have normal game objets that you use as trees, then yes, InstantOC will do dynamic occlusion culling on them and if you provide different lods for your tree models, InstantOC will also do LOD management on them.
    Game Objects like buildings, animals, etc.. (not terrain system trees and grass) that are behind mountains/hills etc, will be correctly managed (and hidden) by InstantOC.
     
  14. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    So...I did some testing, to see...if maybe, just maybe InstantOC could compete with Unity's built-in tree system.

    This are just quick and dirty test results, just my initial tests. Please don't hold my feet to the fire on these, ok? :)

    That being said:

    I used Forester Pro to create a nice maple tree. Nothing -too- complex, but a nice one regardless. 3981 verts, 5192 tris, 2 submeshes blah blah.

    First, I placed 4000 of them with Unity's mass place. I cranked up Tree Distance, Billboard Start, and Max Mesh trees all the way to max. So there were 4000 trees effectively, full meshes, no billboards.

    The framerate I got was about 25 fps. Eeeeh.

    Ok, I then ran a script that created 4000 instances of these instead, at the exact same position as the terrain trees. For a bit of added fun..I added a random rotation. Terrain trees with rotation so they don't look so bad...wouldn't that be nice?

    Ok. Anyway...
    Results:
    Instant OC runs at about 50 fps, sometimes 48 or 49. That's....
    S***. That's almost double Unity's. AND I was using the full mesh. InstantOC lets you have 3 lod levels. I could have the full mess for 1, a slimmed down mesh for 2, and a billboard (much higher resolution by the way) for 3.

    I'm so excited. The big reason I did this was, my project needs to modify the terrain on the fly, and trees cause a big spike when that happens. Its multiplayer. So if this happens for one person...well, it's odd but no biggie. But imagine if you are playing with 10 (or more) people, all of them digging. Your whole game experience would be a series of hitches in framerate. Unacceptable.

    This (hopefully) totally changes that. I can stream in trees totally independant of the terrain. AND I GET ROTATION. It looks...so nice. Instead of needing several rotated prefabs of the same tree in order to get sorta decent variety...I don't need that at all.

    Also...and I know of others who will like this...you can test collision against the individual trees, instead of just getting a single terrain collider. Nice.

    Forester Pro lets you export models at various levels of detail (including a billboard bitmap).

    So...the downsides that I can think of right now:
    Creating 4000 instances of -anything- does eat up some memory, and also takes a while. I'll look at improving this.
    The billboards don't rotate depending on your view, like Unity's. Honestly...um, I don't know that I care, if I can use meshes or LOD meshes that give even better performance. Hopefully...the billboards will be so far away, it won't -matter-.
    What else...hmmm, nothing right now. It only works with tree meshes, not trees made with the Unity tree creator. I'm fine with that, the trees from Forester are pretty nice.



    Also...
    Just for fun...I put the bumped diffuse shader on the trunks, and the Transparent/Cutout/Diffuse shader on the leaves. This gave me full shadows and such, including leaves.

    I then turned on soft shadows with a directional light. Only then did the fps drop to about 27. Still above what the terrain engine was giving me, with no shadows!
    Anyway...this is very exciting, for me at least.
     
    Last edited: Apr 27, 2013
  15. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    That's awesome! Thank you for doing this tests and taking the time to share the results!
    I'm wondering how much performance you would gain further by also using LODs.. should be another 5-10%.
    Thanks for sharing, jc_lvngstn, can't wait to discover more about your project!
     
  16. ersaurabh101

    ersaurabh101

    Joined:
    Oct 8, 2010
    Posts:
    412
    Is this possible ?

    If i add a point light[Realtime] in the scene, will it be active only when camera hits it ? and once it is out of camera, it is not effecting the GPU, i mean it gets deactivated [light gets deactivated].. I dont think so currently your system activates/deactivates the lights..

    But how do you like this idea ? Your system can even handle realtime lights with proper optimization ;)
     
  17. Etienne-L

    Etienne-L

    Joined:
    Apr 24, 2013
    Posts:
    5
    The game scene are composed by grass and tree (using unity terrain system).
    There are some rocks and houses, but not in a great number.

    but thanks anyway.
     
  18. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    This is very impressive must-buy plugin. Great job!
     
  19. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello ersaurabh101,
    lightning optimizations have not much to do with Occlusion Culling and LOD techniques, but rather with Rendering in general (see rendering paths)
    Unity does already some really nice optimizations on lightning.

    In case of the Forward rendering path (Unity free), lights will be calculated with 3 different techniques:

    - per-pixel (high quality)
    - per-vertex (medium quality)
    - spherical harmonics (low quality)

    By default, only near/important lights will be calculated per-pixel, farther lights will be calculated per-vertex (up to 4 lights), and other, distant lights with spherical harmonics approximation.
    You can specify the "importance" for every light in it's inspector panel, and adjust the max number of per-pixel lights in "Quality Settings"

    In case of Deferred rendering path (Unity Pro), all lights are per-pixel, and it is not the number of lights or the complexity of the scene that affects performance, but the number of Pixels affected by lightning, more in general, the resolution at which you run the game.
     
  20. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Thank you proandrius!
    really appreciate that :)
     
  21. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    Great Plugin, just purchased.
     
  22. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello John G.
    Thank you very much!
    Feel free to contact me if you need help with InstantOC :)
     
  23. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Thank you Jasper Ermatinger, for your awesome review on the Asset Store!
    Really appreciate it! Good Reviews are absolutely the best way to support your developers :)
    Thanks!

    PS: can't figure out what your nickname here on the thread is.. :p
     
  24. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Hehe it's me...
    Didn't know that the unity asset story did use the personal name instead of the nick name...
    Well... doesn't matter.

    I'm happy that you like my review.
    Thought that it was about time to write something ;)

    Greetings
    Chillersanim
     
  25. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Now I see! :D
     
  26. Louis-N-D

    Louis-N-D

    Joined:
    Apr 17, 2013
    Posts:
    224
    I'm very interested in this plug in but I do have some reservations.
    1-Why limit the number of LODs? Wouldn't it be nice if we could choose how many LODs we want per object, including empty ones to make objets disappear?
    2-I don't suppose the LOD system plays nice with baked lighting, eh? What I mean is being able to bake lighting onto different object LODs handled by IOC. I predict that my objects will be a mess of shadows as all the intersecting LODs would shadow eachother. Otherwise, one could simply hide the mesh rendering on LODs 1 and 2 and only bake lighting on LOD0, but then you'll get a more noticeable pop and drop in quality as objects switch LODs.
     
  27. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello Louis-N. D.
    Thank you for your interest in InstantOC!
    More/infinite LODs is definitely on the to-do list.
    In regard to lightmapping, it's possible to have it work nicely with LODs, but with some tweaking/hand-tuning.
    With some Lightmapping plugin like this one, it should be easier (per-object baking/saving)
     
  28. Louis-N-D

    Louis-N-D

    Joined:
    Apr 17, 2013
    Posts:
    224
    Am I correct in assuming that LODs and Beast play nice in the Pro version of Unity? Those work arounds don't look like any kind of fun ^_^. I suppose using a custom baking script in conjunction with Light Map Manager 2's ability to ACTUALLY bake selected.. not.. like bake selected and throw out the rest (Unity!!! *shaking fist!). A script could walk through each object showing/hiding LODs one at a time as it baked. Still, not exactly clean and simple! But, as a free version user (for the moment anyway) I will, very likely, be picking this up!
     
  29. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    I'm glad to hear that :)
    you are right, the "bake selected" of Unity is disappointing (at least!) currently the "LODs cycling script" + LightMap Manager 2 is probably the best solution.
     
  30. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    There are actually some dynamic shadow scripts in the asset store.
    I did not test them though, but the demo looks pretty good.

    Even if this doesn't belong to this tread, I will be that bad and post it here anyway ]:)
    http://forum.unity3d.com/threads/102079-Dynamic-shadows-in-Unity-Free-Pro-possibly-Mobile

    Actually, it only works with one light source...
    Using it at the sun and you can possibly get rid of the shadowbaking

    Greetings
    chillersanim
     
    Last edited: Apr 30, 2013
  31. Rico21745

    Rico21745

    Joined:
    Apr 25, 2012
    Posts:
    409
    Am I correct in assuming that this only works for meshes with colliders attached to them?

    For example lets say I have a building, which has an interior made up of other game objects inside of it. I have a collider game object that is separate from the actual mesh of the building facade (they are two different game objects). Will InstantOC work in that scenario and cull the building + all children renderers if they are behind another building? Or will it only disable any renderers that are components of the game object with the collider the ray hit?

    This is pretty important since I have a lot of props/meshes that I don't really want colliders on, like bits of trash and such that are not part of the building mesh itself and are not really things big enough to need a collider, just mesh renderers.

    This is all for procedurally generated stuff mind you, so obviously the Unity occlusion won't cut it.
     
  32. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    @Rico21745
    Hello, and thank you for your interest!
    That's right, InstantOC needs colliders.
    If you have a parent GO with a collider, all children GOs will be managed by InstantOC as one object.
    In your case I would suggest to group for instance, small objects inside the building into a parent GO with a collider set as "is trigger" (lighter on the CPU and the player can go through it). It could be a box collider inside the building (smaller) so that when the player is outside the building, InstantOC hides alll the small stuff inside, but if you look through the door/window, the group of small stuff is shown correctly.
    Simple Colliders especially with the "is trigger" option enabled, are really not a problem for performance. Indeed, in the InstantOC Webplayer Demo there are 5000 houses each with a mesh collider!!! and without the "is trigger" enabled and even though it runs fluid like water :)
     
  33. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Hi!

    I wonder how this thing works and why Unity is not implementing it?

    Tell me this and I'll buy it :D
     
  34. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    It hides all game objects at startup with a specific tag, and then uses ray tracing to find those in the FOV of the camera and shows what it "sees". There's some other stuff here for lighting, etc too.
     
  35. copenhagenjazz

    copenhagenjazz

    Joined:
    Oct 2, 2005
    Posts:
    45
    @frenchfaso; Did I understand it correctly this does not currently work with particles? Is there any workaround to make it work with particles?

    Thanks
     
  36. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    I guess you can just add a collider to the particles and make it a trigger that triggers no function?
     
  37. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    This means it's raycasting all the screen with samples and then calculates if the object it meets is totally hiding the objects behind?

    Isn't raycasting a "slow" function?
    Anyway, the demo really is impressive.

    I still wonder why Unity didn't implement such an easy and immediate solution.
    Any idea?

    I'm near to buy it :)
     
  38. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Yes, but having hundreds or thousands of potentially occluding objects on the screen when they're not visible is even worse.
     
  39. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    That's for sure.
    But now there's one thing I can't understand.
    In his demo I have set up 10000 houses.
    Each house, even if simple, is some hundred triangles.
    Let's say we have 1 million poligons.
    Well, without even having his tool active, my framerate was 50 fps on a 1600 resolution.
    Why I can't achieve this performance AT ALL???
     
  40. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Exactly!
    Thanks SevenBits :)
     
  41. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hy copenhagejazz,
    thanks for your interest in InstantOC!
    currently particles are not managed by InstantOC, I will give it a shot for an update!
     
  42. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hy megmaltese,
    thank you for your interest in InstantOC!
    SevenBits already kindly clarified what InstantOC is and what it does, please consider taking a look at the faq and the user guide for a deeper insight into InstantOC.

    PS: I'm not sure I understood it right, what difference in fps did you get with the demo scene? 50/?
    What cpu/gpu did you test it on?
     
  43. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Your tool is working perfectly.
    What leaves me astounded is that I can't make the same.
    I can't build a scene with 10000 houses / 1000000 polygons and run at 50 fps.
    And I mean: I was watching those houses from the top of the tower.
    How can you have 10000 objects on screen and run at that speed?
     
  44. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Frenchfaso

    Could you please add a LOD multiplier, which depends on the quality settings from unity?
    Perhaps you could directly use the LOD multiplier that is used from Unity Pro.

    Greetings
    Chillersanim
     
  45. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Well that is pretty easy, as long as you didn't disable the LOD, the houses far away were lowpoly versions of the houses nearby.
    Because of that, you did not have 1'000'000 polygons inside the screen, but a much smaller amount.

    Greetings
    Chillersanim
     
  46. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Sounds good to me! Will look into that.
     
  47. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Exactly!
    Occlusion Culling and LOD are both powerful optimization techniques, when combined together, like in InstantOC, their synergy can be astounding ;-)
     
  48. chillersanim

    chillersanim

    Joined:
    Mar 31, 2013
    Posts:
    219
    Yay

    I think, when you implemented the LOD multiplier, and the in developement LOD (LOD outside the game), then your script may be even more powerful than the Unity Pro LOD. :D

    Greetings
    Chillersanim
     
  49. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    Hi Frenchfaso , good asset, can you do something for only do an occlusion culling, the console give me a lot of errors from the lods.
    Thanks
     
  50. frenchfaso

    frenchfaso

    Joined:
    Aug 12, 2008
    Posts:
    479
    Hello KirbyRawr,
    InstantOC can already be used in all combinations of IOC and LOD:

    - IOC only
    - LOD only
    - IOC + LOD

    If you don't need LODs, take a look at the first tutorial "The basics" to see how to correctly setup your game objects and scene with InstantOC.
    If you have problems, feel free to contact me, I will be glad to help.

    PS: The "IOClod" component is always needed, also if you don't use LODs (if you don't use LODs it will not calculate LODs). It's part of the core of InstantOC.
     
    Last edited: May 1, 2013