Search Unity

Assets [WIP] Dyna Cull (Realtime Culling System).

Discussion in 'Works In Progress' started by N1warhead, Aug 7, 2019.

?

What are you more interested in?

  1. Occlusion Culling

    1 vote(s)
    50.0%
  2. Grid based distance culling

    0 vote(s)
    0.0%
  3. 2D Culling

    0 vote(s)
    0.0%
  4. All the above.

    1 vote(s)
    50.0%
  1. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,473
    Hello and welcome everyone! Dyna Cull is an asset for my game I am making, but I believe I'll be putting this on the asset store soon.

    This video wasn't made directly for advertising this product initially and was moreso targeted towards my games audience so there's a part in it where I mention I don't think I need to explain what the variables are doing on the inspector for it. But they are simple enough that really anyone in here can understand them as I try to keep things as simple as possible.

    In this video I'm showing how performance is before and after enabling DynaCull on 25 terrains generated with MapMagic full of trees, bushes, etc.

    All in all, there's tens of millions of trees, bushes, etc generated in real time through map magic.

    Current supported features
    • A Distance Grid Based culling system. (For 3D)
    • A Occlusion Culling system (Still needs work). (Only for 3D)
    • Auto Scene Culling for non-terrain scenes.

    What I want to add before asset store release.
    1: A bit more optimization where can be found.
    2: Occlude objects instantiated later in the game (For example - you shoot a bad guy and he falls to the ground). If he's within the cell, he becomes part of the cell and thus when the cell turns off, so does he.
    3: Occluding AI enemies - sort of the same concept as above, only this time simply occlude the Renderers so the AI logic can still do its work to save on Geometry rendered.
    4: 2D Culling System.

    If there's anything else you'd like to see featured in this, please feel free to mention it here! Or if you have any questions I'm open to answering them all to the best of my abilities.

    Thanks everyone, David.

     
    Last edited: Aug 10, 2019
  2. OliverJackman

    OliverJackman

    Joined:
    Aug 2, 2019
    Posts:
    3
    Amazing!
     
    N1warhead likes this.
  3. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,473
    Thank you :).

    Yeah if it wasn't for making this my game would simply be impossible go make. I'm on a 6 Core AMD Ryzen and a RX480 graphics card also, so the 50ish FPS I get after turning it on is amazing.

    I'm certain though that once I focus more on the Occlusion Culling performance will be even better. This video is with the grid based distance culling only.
     
  4. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    825
    Will this integrate with existing scenes (complex), does it automatically cull objects, or do you have configure things like what occluders are in effect? What price will it cost? :)
     
    N1warhead likes this.
  5. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,473
    Yes this will simply just work.

    There's only two steps involved.
    1. Drag and drop DynaCull Master into your scene (This contains information it needs to run: such as cell sizes, etc).
    2. Choose either DynaCull Map Magic (For map magic scenes), DynaCull Terrain (for single Terrain)
    (Being worked on now) Manual Culling zones for non-terrain based culling, and 2D game Culling.

    Even with DynaCull Terrain, you can simply just drag them to as many terrains as you want, it's not strictly for a single terrain globally, it just handles that specific terrain it's on. So you can have 90 terrains if you want with this script on them and it will simply just automate and work.

    However for non-terrain scenes I've decided to go the route of manual culling zones unless I find a better way of handling scene sizes automatically. It's easy to do this with a Terrain - because we know the sizes of terrains by simply doing float s = terrain.terrainData.size.x;

    So a manual culling zone you will simply drag and drop it into the scene and simply adjust the gizmo size to encompass an area you want (E.G. - entire level, part of a level, etc) and - done.

    And this system is very easy to not cull certain things if you don't want too. Below is the inspector as it currently is.

    DynaCullMaster.jpg

    • Select which Culling you want to use - Distance, or Occlusion.
    • (I'll make PlayerTag optional - and give a GameObject slot - but to revert to the tag if nothing is put - so it works for MP games).
    • The update rate is simply for distance culling, so how often to check distances between player and cell. I found 1 second to be a perfect balance so it's not running every frame.
    • How far from a cell do we want to be before we enable it?
    • Cell height - For terrain, didn't see a need to add height layers multiplying the calculations (cells on top of cells).
    • Cell Height Offset: do you want to lower or raise the cells to make sure they encompass the entire chunk within the terrain if it dips lower than you want.
    • Culling Type: GameObject, Trees, Trees and GameObjects.
    • Game Object Layers: If Game Objects are to be culled, select what Layers you want cull and avoid the others as they don't matter.
    As you can tell, it's fairly simple to understand and grasp. The last part is what I think you are most interested in though - cull only the types of objects you want.

    I haven't yet come up with a price, I am sorry for that. It won't be too long before I have one though.

    I hope this was helpful. If you have any other questions feel free to ask away!

    Thank you,
    David.
     
    khos likes this.
  6. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    1,809
    One question - what's up with the floating vegetation? lol

    also about the water, why not modify the terrain a bit after placing the water? like raising the "rim" of the pool/puddle a bit, if you place the water before all the vegetation you can have it so that the closer to water the more veg there will be (I don't know the tool you use for the generation though so i don't know how simple it is to do in your setup)
     
  7. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,473
    LOL I know right haha. Well the water - I had working how I wanted, then started adjusting things with Map Magic for biome generation which broke the water as I started changing curve values and such.But then I got addicted to working on the culling system and made it my priority lol. So had to go back and fix it afterwards.
     
    SparrowsNest likes this.
  8. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,473
    I have figured out how to avoid doing manual culling zones, I have figured out how to get the entire scene bounds now. So things will simply just work now.
     
  9. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,473
    Here's a small gif showing off a small scene culling. It generates a grid of cells based around a specific layer of my choice. Using the camera to give an example of the distance based culling.

    It is height based as well. So it detects objects lower and higher and collects them as well. There's a few frames in this Gif that shows a cube higher in the air. Sorry I didn't realize at the time I didn't have a good angle.

    Going to be doing some various testing with it just to make sure this version of it is efficient and try and find any bugs that may or may not exist. This is just a sample gif.

    If I find no issues with it, I'll get the 2D Culling built in - pretty much same concepts as this version, just in 2D.
    Then I'll be focusing on Occlusion Culling (Which is already built - just not very efficient at this moment).

    [EDIT]
    To anyone wondering, no this culling system isn't using colliders to cull and uncull, so it's not a trigger based system. In fact - none of this system has colliders at all nor does it collect items with colliders, it collects anything that has a MeshRenderer on it. I will also be offering Character culling as well, so an enemy for example can be culled - and still function its normal AI logic such as walking around.
    [End of Edit]

    CullingSystem.gif
     
    Last edited: Aug 9, 2019
    Bartolomeus755 likes this.
  10. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,473
    Hey everyone just wanted to keep you all updated.

    After days of playing around with SetTreeInstances - I simply couldn't find an efficient way of handling tree data without causing massive spikes. So I've decided to simply replace terrain trees in real time with GO trees and pooling with Jobs so I can make this system entirely avoid any spikes in performance. (I'll even attempt to make this into ECS), but honestly never dove into ECS yet so I'll at least give it a shot.

    In the long run I think this is a better way to handle terrain trees (not sure if anybody uses Tree Creator now'a days), but SpeedTrees automatically support billboarding so we're good on that part. Plus turning them into GO trees in run time I can give it random Y rotations as well. I'm nearly done getting the Occlusion culling set up (At least the initial form of it), I haven't yet gotten to culling behind things as of yet, but one step at a time and that's culling and unculling objects based on camera angles at this moment.

    But yeah, just wanted to keep you all updated. As soon as I get the jobs system working correctly I'll post up another video.

    If anyone has any questions, please feel free to ask!
    Take care everyone, David.