Skip to main content
GameDev.net gamedev.net
🔒 Locked

Brush-based CSG vs static mesh

Started by scarypajamas Feb 14, 2017 at 10:15 PM 15 replies 9.1k views
Original Post
scarypajamas
scarypajamas
Theory question: Whats the benefit of using brush-based CSG over static meshes for constructing world geometry? It seems to me everything boils down to polygons at the end of the day. What does using CSG buy you?
Could you be specific with your answers. I've read in a few places that performance with CSG is better, but the same articles omit what kind of performance they are talking about.
Infinisearch
Infinisearch

Could you post links to the articles... I'm interested.

Isn't brush-based CSG a relic of the quake era and BSP based levels? I think most modern games use static meshes.

-potential energy is easily made kinetic-
Hodgman
Hodgman

Brush based CSG is usually used at the content creation stage, and is converted into a static mesh during development, before the game even runs. It's just a different way to author content.

So you're comparing static meshes vs static meshes...

Infinisearch
Infinisearch

@[member='Hodgman'],

Sorry to bother you but you seem to have "been around the block"... am I misremembering things or was brush based CSG used in level editors like hammer and other BSP based engines?

-potential energy is easily made kinetic-
Hodgman
Hodgman

am I misremembering things or was brush based CSG used in level editors like hammer and other BSP based engines?

Yes the Quake engines really popularized the CSG->BSP workflow, but even UE4 and Source still support CSG based mesh creation. There's also a bunch of CSG plugins for Unity, such as this.

It's a particularly good workflow for people who aren't experts at 3D modelling, but who want to quickly block out the shape of a level -- e.g. level designers :D

swiftcoder
swiftcoder

It's a particularly good workflow for people who aren't experts at 3D modelling, but who want to quickly block out the shape of a level -- e.g. level designers :D

Or programmers. My programmer-art CSG is way better than my programmer-art 3D modelling :D

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Krypt0n
Krypt0n
CSG also avoids common issues when it comes to BSP creation, e.g. Meshes are watertight, no degenerated faces, unused vertices. BSPs can be still useful for fast, rough culling, collision detection, audio propagation (which all basically boils down to some ray queries).
scarypajamas
scarypajamas

Thanks everybody for your replies. They were very insightful.

Infinisearch
Infinisearch

Could you post links to the articles referred to in your original post? I'm still interested.

-potential energy is easily made kinetic-
scarypajamas
scarypajamas

Could you post links to the articles referred to in your original post? I'm still interested.

Maybe its an Unreal specific thing, but their docs state: "Even though Static Meshes are better performance-wise, Geometry Brushes can occasionally be used without any serious impact as long as the geometry is simple."

Random forum posts, mostly Unreal related, seem to agree with the docs.

It would seem to me (intuitively anyway) that CSG would be faster for building a BSP since a brush will likely have fewer splitting planes than a complex mesh.

swiftcoder
swiftcoder



It would seem to me (intuitively anyway) that CSG would be faster for building a BSP since a brush will likely have fewer splitting planes than a complex mesh.

Maybe I'm misunderstanding you, but CSG in this day and age is surely being baked to static meshes, and not rendered via BSP tree.

Modern GPUs are really good at rendering static meshes.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
scarypajamas
scarypajamas
It would seem to me (intuitively anyway) that CSG would be faster for building a BSP since a brush will likely have fewer splitting planes than a complex mesh.

Maybe I'm misunderstanding you, but CSG in this day and age is surely being baked to static meshes, and not rendered via BSP tree.

Modern GPUs are really good at rendering static meshes.

What about for collision? Have BSP's been superceded?

Krypt0n
Krypt0n
 



It would seem to me (intuitively anyway) that CSG would be faster for building a BSP since a brush will likely have fewer splitting planes than a complex mesh.

Maybe I'm misunderstanding you, but CSG in this day and age is surely being baked to static meshes, and not rendered via BSP tree.
 
Modern GPUs are really good at rendering static meshes.
 
What about for collision?  Have BSP's been superceded?
that's very case by case dependent. Even mesh vs mesh.
Some low poly, huge level mesh, might be faster with BSP, a very complex mesh with smooth surfaces might generate an insanely huge bsp, while being super easy/fast to handle with an OBB or even grid based organization.
Hodgman
Hodgman

In most physics engines, you give it a static mesh and it converts it into some kind of internal format (perhaps, BSP, perhaps not) without you having to care :)

FWIW, in the Bullet physics engine, they use BVH.

If all your brushes are additive though, you can use the brushes directly as colliders, which actually has quite a few benefits over triangle soups!

scarypajamas
scarypajamas

If all your brushes are additive though, you can use the brushes directly as colliders, which actually has quite a few benefits over triangle soups!

Forgive me for my ignorance, I picked up Real-Time Collision Detection by Christer Ericson not that long ago and my expertise on the subject isn't quite there yet. Would you be able to elaborate on some of those benefits?

I'll take an educated guess: Triangles are more granular and would create more nodes in a BVH (e.g. a single triangle consumes one node) whereas brushes can be thought of as a node by themselves (e.g. all the triangles making up the brush consume only one node).

Hodgman
Hodgman



Would you be able to elaborate on some of those benefits? I'll take an educated guess: Triangles are more granular and would create more nodes in a BVH (e.g. a single triangle consumes one node) whereas brushes can be thought of as a node by themselves (e.g. all the triangles making up the brush consume only one node).
Sorry, I should've just mentioned at the time :lol:

Yeah, if the model is quite blocky or otherwise made up of primitive shapes, then a representation using primitive shapes will be more compact than a triangle mesh. The extreme of this would be if your model contains lots of perfect spheres -- a sphere primitive is a single entry in the tree and very easy to test for collisions against, while a trimesh requires a huge number of triangles to accurately represent a sphere.

Another benefit is that primitive shapes have a very well defined inside and outside. If you spawn an object deep inside a sphere, the physics engine knows that it's colliding with the sphere and should be pushed up to its surface. If you spawn an object deep inside a sphere-made-of-triangles, the physics engine has no way to know that the object is "inside" the sphere -- it only knows whether the object is touching the surface or not. In general this means that physics engines are better at resolving penetrating collisions when using solid primitive shapes than when using tri-meshes.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.