Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

M2HCulling: Optimize your game - culling system for Unity

Discussion in 'Scripting' started by MikeHergaarden, Jun 21, 2010.

  1. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    M2HCulling - Occlusion culling system for Unity



    Integrate M2HCulling in your project and greatly boost your games performance within 30 minutes!

    This document, and accompanying Unity project, help you address performance problems in your Unity application. Starting with a brief introduction to general optimizing techniques for Unity games after which I will show you my Unity occlusion system which greatly improves rendering performance.

    Links
    Download M2HCulling pdf
    Download M2HCulling project folder





     
  2. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    whoa, thank you for sharing!

    time to investigate the advantages of this culling method over the internal Unity3D culling method
     
  3. GeneralGrant

    GeneralGrant

    Joined:
    Jun 10, 2010
    Posts:
    977
    *noob*

    Whats culling?
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,600
    if you read the material that comes with it, you will know :)
     
  5. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    i'm fairly familiar with culling ;-)

    and I just read the pdf, looks good, seems to offer a bit of customization over the culling already in there. cool
     
  6. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Unity 2.X only does frustum culling, any objects that are in front of your camera (in the cameras view) will be rendered, even when they are behind other objects such as your levels walls. M2HCulling can also cull these objects for a significant performance boost.

    In this case, disabling the rendering of objects that aren't visible to save you rendering performance. For more info read the pdf.
     
  7. GeneralGrant

    GeneralGrant

    Joined:
    Jun 10, 2010
    Posts:
    977

    Isn't that, like, already in Unity? What makes this one so special?
     
  8. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Nope, see my previous post where I quoted zhx. Unity renders your entire level even if you're facing a brick wall.

    Unity 3.0 will have a cool occlusion system, but 2.X does no more than some frustum culling. Please read the pdf for the whole story. In the pdf are two simple example project that go from +/-100 fps to 300FPS using the M2HCulling.

    M2HCulling will make no difference in 2D games or topdown games, but for 3D games, say FPS games, it makes a huge diference (easily 200%+ boost, depending on your level&culling design).
     
  9. GeneralGrant

    GeneralGrant

    Joined:
    Jun 10, 2010
    Posts:
    977
    Sweet. This is awesome.
     
  10. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    I'm guessing this is for non iPhone Unity seeing as how there is a full fledged occlusion culling system built into Unity iPhone (in addition to the standard frustum culling). Have you compared the performance? I would imagine the built in one has a major advantage of being written in C++...
     
  11. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Yes this has been made for mac/pc standalone/webplayer, but should run on iPhone too. I have not compared the iPhone culling as I've no access to a mac these days.

    The coding language shouldn't really make a difference performance wise as culling is not something you need to recalculate every frame. Calculations/setup is done in front.

    I guess with a good culling setup there shouldnt be much of a difference in using my culling system or unity iPhones culling system.
     
  12. Creative

    Creative

    Joined:
    May 8, 2010
    Posts:
    184
    You don't stop amazining me :D
     
  13. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    after further checking into this awesome script, I have to say wow thank you!
    I wonder how this compares to the built in iPhone culling, as that was the system I'm accustomed to, and was originally referencing with my statements. If anyone can offer any insight into this specifically it would be much appreciated.

    This rocks for the desktop!!!
     
  14. King Gamer

    King Gamer

    Joined:
    Jun 22, 2010
    Posts:
    25
    LOL, Found a glitch. Since there is no coolision detection on the roof of the simple example worlds you can jump out in the manual version off of the barrels that are stacked horizontally into a "room" with no exit that is also outside of the culling areas in most casses.
     
  15. synapsemassage

    synapsemassage

    Joined:
    Jul 27, 2009
    Posts:
    325
    Your system might be an alternative for iPhone Basic users as Occlusion Culling will be a pro-only feature with Unity 3.
     
  16. liverolA

    liverolA

    Joined:
    Feb 10, 2009
    Posts:
    346
    this is awesome
     
  17. afalk

    afalk

    Joined:
    Jun 21, 2010
    Posts:
    164
    Just pulled this down and took a look - fantastic bit of work -- THANK you so much for sharing it with us!
     
  18. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Great, same for Unity (free/indie) then. Nice!
     
  19. mikesgames

    mikesgames

    Joined:
    Apr 16, 2010
    Posts:
    1,071
    Thanks for the cool resource dudes!
     
  20. KevS

    KevS

    Joined:
    Apr 21, 2010
    Posts:
    51
    Very interesting project, very useful ! Thank you.
    But it looks like we can't rotate the areas.

    With the auto mode i suppose it's because the using of Bounds. What about the manual mode ?
     
  21. cmasterenko

    cmasterenko

    Joined:
    Jul 10, 2010
    Posts:
    67
    I just tried to apply this to an iphone project of mine to see how it would work and the auto mode gave me an error. In the CullingArea_Auto script I get an error on (25,16) error cs8025: parsing error. I don't usually work with c#, so if anyone could point me in the right direction as to what I can do to solve this I'd really appreciate it as I'd love to play with this and see how it does.
     
  22. Xsnip3rX

    Xsnip3rX

    Joined:
    Aug 29, 2009
    Posts:
    197
  23. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    Without a doubt, a FANTASTIC script. You sir, are a genius. Works great and does exactly what it says on the tin.
     
  24. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Unity 3 ready!
    This now also works on Unity iphone(basic). Furthermore I've greatly improved the performance of the automatic culling script.
     
    Last edited: Sep 28, 2010
  25. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    Does your updated one still work for 2.6.1? Or is it v3 only now?
     
  26. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    I updated the project to 3.0, but the code should still run on 2.6 too. I'm not using 3.0-only features.
     
  27. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    Thank you for the 3.0 update ! :)
    was there a version change with the 3.0 update you just updated?
     
  28. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    I did improve the automatic cullings script performance. Furthermore there were 'blinks'/flashes sometimes when switching to a new area, these are now fixed too.
     
  29. alaindube

    alaindube

    Joined:
    Jan 7, 2010
    Posts:
    1
    Hi,

    Nice scripts... I ve tried it and all work fine for me... Great.... But, I am wondering if it is possible to use it with more then one scene?
    I use Application.LoadLevelAdditiveAsync(LevelNameToLoad); in my game...

    Thanks
     
  30. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,204
    this.. is.. AWESOME! beyond awesome actually, astronomically insanely awesome!
    Better yet, did you invent culling? I LOVE THIS!
     
  31. n8

    n8

    Joined:
    Mar 4, 2010
    Posts:
    147
    Does anybody have a link to the .pdf? the ones listed here and on M2H's website are broken. I have the project, but i just dont have any docs. Thanks!
     
  32. Davman

    Davman

    Joined:
    Sep 4, 2009
    Posts:
    12
    I have a bunch of problems getting this to run in Unity 2.5. Is it possible you broke something when you upgraded it to work with 3.0?

    Code (csharp):
    1. Assets/M2HCullingSystem_Auto/CullingArea_Auto.cs(64,51): error CS0308: The non-generic method `GetComponentsInChildren' cannot be used with type arguments
    I fixed this by changing the line to:

    Code (csharp):
    1. Component[] allRenderers = cullingObjects.GetComponentsInChildren(typeof(Renderer));
    but then I get:

    Code (csharp):
    1. Assets/M2HCullingSystem_Auto/CullingArea_Auto.cs(24,6): error CS0246: The type or namespace name `SerializeField' could not be found. Are you missing a using directive or an assembly reference?
    And I haven't worked out how to solve that yet.
     
  33. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    888
    Is this better than the built in culling in unity 3?
     
  34. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Nope, I wouldn't dare to claim that. However it is usefull when you cannot use the U3 culling, e.g. on iOS basic or older Unity versions.
     
  35. Udyrfrykte

    Udyrfrykte

    Joined:
    Feb 14, 2010
    Posts:
    156
    Or if you are a poor student using U3 indie!

    Thank you so much, it's working great so far. Just started testing it tonight, but it's working like a charm.


    Is it possible to cull lights somehow?
     
  36. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    I'm glad it's so useful to you :).
    You could add lights to the culling as well, just copy all the MeshRenderer code for the Lights.

    (On Pro: If you switch to deferred lightning mode you will not really need to cull lights any more.)
     
  37. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    607
    I am having trouble downloading this from the link, safari can't open the asset store, is there any other way I can download this? It looks really awesome.
     
  38. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Safari cant open the asset store indeed, when opening the link it should open the store inside Unity though.
    Alterntively simple browse to this package from the Unity asset store manually.
     
  39. PolishRenegade

    PolishRenegade

    Joined:
    Jul 22, 2010
    Posts:
    593
    Leepo, you rock.

    Umbra is a real pain in the ass with embeded zones and high-density scenes. Your system is doing miracles and I haven't even started playing around with the manual setup.

    Thank you so much.
     
  40. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Awesome!
    I thought this project was rendered obsolete by Umbra, but it's indeed often still very useful.
    I also had a project on a deadline in which umbra caused too many glitches (visibly culling too much). Let's hope Unity improves their Umbra implementation though :)
     
  41. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    It is sad, but you are right. For example I am not able to bake anything else then VERY simple scenes, like empty terrain with one house. One is house OK, city crashes. Even with basic settings and preview mode.
     
    Last edited: Mar 7, 2011
  42. Grady Lorenzo

    Grady Lorenzo

    Joined:
    Jan 18, 2010
    Posts:
    407
    This is FANTASTIC! Helps as much as the networking tutorials you created. Which, come to think of it, I never got passed the first couple of chapters...
     
  43. zeldafan_mimo

    zeldafan_mimo

    Joined:
    Jan 27, 2010
    Posts:
    23
    Any How i can Download this Without the Asset Store ? i cant seem to access my asset store :(
     
  44. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,561
    Tried the first post?
     
  45. zeldafan_mimo

    zeldafan_mimo

    Joined:
    Jan 27, 2010
    Posts:
    23
    Whooopss :p Blind Mimo :p thanks Frank
     
  46. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    607
    Do you need to know how to program in order to use this plugin?
     
  47. MERKB

    MERKB

    Joined:
    Jun 27, 2011
    Posts:
    55
    Not to put down your project at all (because I'll be devouring the whole pdf very soon, I daresay :)), but isn't it possible to obtain an occlusion-type culling by adding layers to other objects, then setting the draw distance for those layers?
     
  48. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    No, it has an editor. Feel fre to try it out, its a free package after all.

    That only culls at distance. It sure helps, but there is a lot more to gain by culling objects that are blocked from view.
     
  49. alln2themusic

    alln2themusic

    Joined:
    Feb 3, 2011
    Posts:
    46
    Leepo,

    Does the M2H Culling System work with Unity 3.3? What is the primary difference in the M2H Culling System and the Occlusion Culling system that comes with Unity (I'm using the Pro version)?
     
  50. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    It does work with 3.X.

    Use Unity's culling if you can. However, M2HCulling still has it's use as on some projects Unity's culling is simply too bugged/unpredictable. M2HCulling then offers you more control and predictability. I had to revert back from Unity Culling to M2HCulling on an iOS racing game for example.
     
    Last edited: Jul 8, 2011