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

Easy Cull - An alternative frustum culling system

Discussion in 'Works In Progress - Archive' started by freakdave, Nov 16, 2014.

  1. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Hello Internet!

    I'd like to show you what i've been working on in my free time.
    Easy Cull (working title) is an alternative frustum culling system which i've already used in many game prototypes.

    To explain the system to you, let me show you a little screenshot:



    Objects that are within the culling sphere AND within the camera view frustum will be rendered. Everything else will be hidden. The objects can either pop in/out or smoothly fade in/out (adjustable).
    Fading does only work with shaders supporting alpha blending (e.g. transparent shaders).
    Objects that should be culled are "cached" before the game starts.
    You are also able to define tags for objects which you want to cull.

    The reason why i wrote Easy Cull is because i wanted to avoid visible assembly of the horizon (especially when using terrains) while still being able to cull everything else.

    Webplayer demos (hit the button to activate Easy Cull):
    3D Demo
    2D Demo

    Video overview:






    Documentation:
    Documentation (PDF)

    Status:
    Easy Cull is finally available on the Asset Store. Get it here:
    https://www.assetstore.unity3d.com/en/#!/content/27178

    Let me know what you think, thanks :)
     
    Last edited: May 23, 2015
    Mohamed-Anis likes this.
  2. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    Can this be used with 2D Scenes?

    Just curious here :)
     
  3. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Hah, being a 3D guy i've never thought about using this with 2D scenes until now. Thanks for asking!
    Technically it should be doable, i'll do some tests and will let you know how it worked out.
     
  4. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    You asked for it and here is the result:


    It's basically the same approach as shown in the 3D demos, but I've modified the code to explicitly use Unity's 2D API (for obvious reasons).

    You are free to try the 2D webplayer demo here:
    2D Demo (hit the button to activate Easy Cull)

    If you have any comments, suggestions, etc.. please let me know, thanks :)
     
  5. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,605
    I think the fading in should be less noticeable or faster. ;) Otherwise, looks good. I'd buy it already(I'd think an asset like this would do well at 10-15 dollars).
     
  6. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Thanks for the feedback, the fading speed can be modified from within the inspector.
    I'll try to expose some of the settings for you in the demo so that you will be able to test it a little bit more.

    Once I've completed my todo list (which hopefully won't take too long), i'll put the package on the AS.
    Right now i'm implementing support for dynamic objects (instantiated at runtime).

    I'll keep you posted :)
     
  7. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    I've updated the demos and exposed some variables for you guys.
    You are now able to control the fading speed along with other things.

    Updated webplayer builds:

    3D Demo
    2D Demo

    Have fun :)
     
    Last edited: Dec 14, 2014
  8. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Hey folks,

    I've updated my first post with videos showing the setup of Easy Cull (excuse my bad english, i am not a native speaker).
    The webplayer builds have also been updated with support for instantiated objects.

    I'll now continue with writing the manual / documentation.
    Once this is done, i'll release Easy Cull on the Asset Store for 10 dollars (introductory price).

    Cheers :cool:
     
    carking1996 likes this.
  9. BelfegnarInc

    BelfegnarInc

    Joined:
    Jun 29, 2014
    Posts:
    32
    It could be a lot faster to check sphere-to-sphere (your sphere with object renderer's bounding sphere) intersection manually, depending on scene complexity. It require only one IF check and will not require the presence of Collider on each object that you want to cull. Did you try it?
    And what about realtime shadows? After all, the volume occupied by Collider is not the same as Collider + shadow. It may cause an incorrect appearance / disappearance of object's shadows.
     
    Last edited: Dec 14, 2014
  10. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Thank you for your suggestion.
    I've already managed to get rid of the collider requirement and i'll include it in the final build :)

    As for realtime shadows: i've already seen this behavior before, but to be honest i have no idea on how to overcome this problem. I'll make sure to mention this in the documentation though.
     
  11. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,605
    Why not make it so instead of showing right inside the camera view, it shows just outside of it, so things load before the player sees them, showing shadows and all.
     
  12. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Yep, looks like we both had a similar idea, this is what i have right now:


    Basically i am using a 2nd orthographic camera (which renders nothing) and its frustum area in conjunction with the main camera's frustum + culling sphere.
    I've tested it with Unity's Stealth Game project (because that's the project where i first saw the realtime shadow problems) and so far it's very promising. I've been able to reduce the amount of realtime shadows popping in/out to a minimum :)
     
  13. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Ok, just wanted to let you know that i've finished the documentation.

    I guess it's time to submit the package to the Asset Store now, right ;)
     
  14. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
  15. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Does this work with Point Lights?
     
  16. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Only with a workaround. You will need to add a mesh renderer component to the point light's game object AND enable "Disable Game Object". See the attached screenshot below. explanation.png
     
    Last edited: Dec 14, 2015
    julianr likes this.
  17. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Thanks, much appreciated.
     
  18. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Hi again! I've applied Easy Cull to a vehicle. I have a rotating camera for when I reverse, the AI that I have placed in the cull are not being seen when the camera is looking behind, only in front. Is there a boundry that only culls the front?

    I'm guessing I may need to add another camera, but facing the other way, or will using the 2D Easy Cull with a 360 view frustrum work on a 3D game?
     
    Last edited: Jan 3, 2016
  19. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Hi Julian,
    please send me your invoice number in a private message and I will assist you in fixing this problem. I already have an idea of what might be wrong here.
     
  20. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    PM'd you - thanks!
     
  21. Pauloxande

    Pauloxande

    Joined:
    Feb 8, 2014
    Posts:
    110
    Hello friend, I'm trying to put easy cull with UFPS and it's not working
    Knows how to solve this.
     
  22. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Looking into it, i'll keep you posted.
     
  23. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    This should solve your problem i hope:
    UFPS_ECL.jpg
     
  24. Pauloxande

    Pauloxande

    Joined:
    Feb 8, 2014
    Posts:
    110
    show friend works
     
  25. DarkDeivel

    DarkDeivel

    Joined:
    Aug 31, 2016
    Posts:
    127
    This asset is still relevant?
     
  26. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342
    Good afternoon. I use the world of Streamer. It loads the chunks in real time. Will the work you have with such a system ???? I'm frightened by the fact that objects should be made by all the child objects. without this, how can? DO NOT ADD OBJECT TO THE PARENT.
     
  27. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Still alive?
     
  28. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Yes, still alive.
     
    helloworldgames likes this.
  29. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Im rendering a 2d grid of sprites, 10k sprite renderers and want to achieve following in frustram culling:
    - i call a function on ur easycull which returns me all those sprite renderers which are currently being rendererd by it?

    i dont want to use onBecomeVisible/Invisible as thats not what i ineed.

    So can i achieve this with your plugin?
    If not, can you add this feature?


    Thanks
     
  30. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,299
    Hello,

    in a game with a voxel / chunk based engine like Minecraft (the world contains chunks, which are all in my case 10x10x10 meters large), would your culling System help to make Rendering faster?

    Thanks :)
     
  31. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Yeah, no problem, I've just added 2 methods:


    Here's how it looks like in the Inspector:


    I will submit the changes as soon as possible. Thanks for your feedback!
     
    helloworldgames likes this.
  32. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    That really depends on how much renderers you will throw at ECL. If you're in a mobile (phone/tablet) scenario, it might help. If you're on a PC, chances are that even more renderers would need to be processed which will (sooner or later) lead to worse performance. I would really like to give you a definite answer here, but really, it can only be assessed on a case-by-case basis.
     
  33. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60

    Thank you, my question is i want to use it pure 2D situation where my camera is orthographic and showing 2d grid of sprite renderers. I use camera size as a zoom to either show all 10k cells or only few, and this when im showing few i want this function so i know which few are visible by camera

    Update:
    So i dont want a sphere, i want a normal 2d orthographic camera which returns all the visible objects
     
    Last edited: Jun 5, 2018
  34. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Rest assured, i've also updated the 2D systems (in your case, the CullingBox script) :)

     
    helloworldgames likes this.
  35. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342
    I will get an answer to my question or not?
     
  36. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Oh, I am very sorry, I missed your post! :eek:

    So the way how it works is that ECL has a parent object with all children (game objects with renderers) that will be enabled/disabled as needed. You can set up this parent object before you start game, but you also have the possibility to register/unregister new children per code. Currently it is not possible to do this without a parent (master/root) game object. So if "Streamer" supports loading objects/chunks from within other game objects then the answer will be yes, otherwise no.
     
  37. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Hi Just to be sure, im currently using orthographic camera, so all i do is use your plugin and it will automatically work? i dont want to change my current implementation. please advise so if it works for me then ill buy immediatly.

    Update:
    As i have over 10k sprites, so i really dont want your code to loop through those 10k objects to give me visible list as i can do that myself and dont want this due to performance issues. i want a method that detects what are visible (which will b few dozens) and then return those
     
    Last edited: Jun 15, 2018
  38. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,459
    I like the look of your asset, I have a large/complex scene, question: Do all objects to be culled need a collider?
     
  39. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    No, just a Mesh Renderer. Colliders are not needed at all.
     
    khos likes this.
  40. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Unfortunately it's not possible to just return visible objects without going through the whole list. You could experiment with Unity's Renderer.OnBecameVisible() though.
     
  41. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,459
    Thanks! Sorry I have another question, will this work in Unity 2017? I notice that it shows 2018 version. Does it use features only available in 2018?
     
  42. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Yes, it will even work with Unity 5.x
    It shows Unity 2018 because I submitted my last update with this version.
     
    khos likes this.
  43. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342
    Good day. I wrote to you in the mail about the problem. Before buying, I want to get an answer. can you solve my problem after purchase or not. I'm interested in buying, but you have been silent for a week.
     
  44. freakdave

    freakdave

    Joined:
    Nov 18, 2012
    Posts:
    78
    Hello Alex3333, I can only give support for purchased versions of Easy Cull from the Unity Asset Store. Easy Cull obtained via other "sources" is definitely excluded. With that said, I can NOT give you a 100% guarantee to solve your problem, but I will try my best to do so. As for refunds, please refer to Unity's EULA.