Scene Partitioning

Moderator: andrewmac

  • 1
  • 2
12 posts Page 2 of 2
lowlevelsoul
Posts: 23
Joined: Mon Mar 30, 2015 10:02 pm
by lowlevelsoul » Tue Feb 23, 2016 7:19 am
andrewmac wrote: I've left culling alone for the time being because I want to do it well and try to avoid the pitfalls you describe. You sound experienced on the topic so any advice you can offer is much appreciated.

.....

Essentially I've built the scene processing in a way that lends itself very well to various culling methods, but I haven't settled on one yet.


The only advice I can give here is to implement a common interface. You already have a method for marking dirty scene objects, but just make sure that it extends to the transform and bounds of an object.

There's no way you can implement a single partitioning scheme for an engine that is supposed to be general purpose. As an example, what works well for indoor scenes will be a memory hog for outdoor scenes and what works well for self contained scenes is terrible in all ways for any sort of streaming content. So it's important that you at least define a clear interface for how the partitioning scheme is supposed to work with the render system.

Then other people can write their own schemes, probably as plug-ins ( Ogre does much the same thing) and contribute to the project. If you really want too provide a set of pre-made culling systems, you could always implement a wrapper for the various Bullet scene types and use collision objects to represent the meshes and lights as well as the camera frustum. It might not be optimal, but it would be better than nothing and a good place to start without having to write a lot of code.
andrewmac
Posts: 295
Joined: Tue Feb 03, 2015 9:45 pm
 
by andrewmac » Mon Mar 07, 2016 1:01 am
I ended up implementing frustum culling today. It spawned two new systems I'm quite fond of.

The first are RenderFilters. RenderFilters are attached to cameras and have an early opportunity before rendering to iterate the RenderData to flag anything as Filtered for that cameras render pass. RenderData flagged Filtered will not be rendered. This is how I implemented frustum culling. You attach a FrustumCulling component to an object with a camera and it will cull using the cameras frustum.

Here is the frustum culling implementation:
https://github.com/andr3wmac/Torque6/blob/master/src/scene/components/filters/frustumCulling.cc#L84-L135

The second thing I made are DebugModes. DebugModes are globally registered with macros and can be activated from the console, torquescript, etc. I'll also add a menu in the editor that lets you turn each one on/off. I added a DebugMode for frustum culling that uses the debug draw to visualize the bounding spheres that are being checked against the frustum:

Image

To activate it I just type setDebugMode("FrustumCulling", true); in the console and it activates.
  • 1
  • 2
12 posts Page 2 of 2

Who is online

Users browsing this forum: No registered users and 3 guests