So I’m pretty sure I’m over thinking this - but I want to get some other perspectives on this question:
If I have a Static Mesh with a custom made Collision Object that I made in my 3D Software ( UCX_StaticMesh + StaticMesh ), lets say it has 20 Collision Primitives.
Or I could import the Static Mesh without Collision and build the collision around it with Blocking Volumes.
Is there really any significant performance difference between the two techniques? Custom Made Collision Vs Blocking Volumes?
I did a test with two levels both with 1 directional light and 2,500,000 Poly’s. The first Level had No Collision for the meshes and the second Level had 315000 collision primitives - But in both levels I got 120 FPS with FPS capped at 120 and solid 300FPS with FPS uncapped.
So does this experiment prove that Custom Collision Primitives have almost no effect on performance?
Would be grateful for other peoples input / thoughts on this topic. Thanks very much!
If you double click the mesh you can add a collision to the mesh, automatically (from the drop down menu), simple shapes or convert them then to convex collision. Or you could use the mesh as collision (complex collision, for doors and such) So my point is i don’t understand why you want to make a custom collision, unless parts of the mesh should be walkable, which case i would use a blocking volume, just to save time. And blocking volumes can be setup differently, for continuous collision detection for instance, which affects performance. It really depends on your needs and setup.
There are two things that affect collision performance:
How many primitives are being tested? If you have lots of small objects, only the objects that are “close to” the moving characters are actually tested, the rest have very small cost. This is called “broad phase” collision detection in physical simulation.
What does each individual primitive/primitive test cost? Once you’ve decided which colliding objects are “close to” each other, the engine tests each pair of primitive. Here, a mesh/mesh intersection is a lot more expensive, relatively speaking, than a sphere/sphere intersection. (Intermediate costs are capsule, block, convex hull.) This is called “narrow phase” and/or “contact generation” in physical simulation.
So, if it turns out that only a few small objects are actually tested against each other each frame, it doesn’t matter if they are meshes or spheres or something in-between. However, if you actually want to test 10,000 objects each frame (10,000 movable objects are all “near” other objects) then all-spheres is going to be a lot cheaper than all-meshes.
Hey Unit23 - thanks for your answer! So yes, I am familiar with the various process’s you can use inside Unreal Engine 4 to auto generate collision for Static Meshes - primarily through FBX import options - such as Auto Generate Collision and One Convex Hull Per UCX. And I am also aware that you can use Complex Collision as Simple, by changing the Collision Settings in the Static Mesh Editor. Obviously Complex Collision as Simple is the most expensive option, and I have no need to use that.
The real reason I am asking this is because i just find it far far easier and simpler to create my own UCX Collision Object inside my 3D software, than to use auto generated collision or blocking volumes. With my own custom made collision, I know exactly what I’m getting and can tailor the collision to perfectly fit the static mesh while still using a relatively small number of Polys for the UCX collision object - which is not so easy using blocking volumes. So my preference is always to create my own custom collision, takes like 5 mins. I’m just concerned that all my custom collision assets were heavy on performance. But I’m slowly coming to the conclusion that they are probably fine.
Thx very much for the technical info Jwatte. So i guess from what youve saud my test with 315000 Collision Primitives was not definitive experiment because the assets were spread over a large distance and far from the character.
But yeah i think I’m gonna stick with using my custom made UCX Collision objects. The workflow is so much smoother for me and I reckon it’s probably okay on performance. Cheers!
It’s a game! You can get away with all kinds of risky things, as long as they don’t ACTUALLY happen while the player is playing!
If your level designs will all keep the objects reasonably well spread out, you can go crazy with how compex you make them The CPU is there to deliver great gameplay; there are no points for saving too much of it. (Other than from laptop/mobile gamers who have heat/battery issues.)
I wasn’t even aware that you can import your own collisions, do you use blender or something else? I am not sure if i would need something like that. However, when you merge meshes, for instance floor tiles, the generated collision is always a cube shape, and then you can align the heights. If you would create collision yourself, you probably also want to use cube forms, instead of many different angles, or spheres ofc. Though, for floors and walls you would just need single sided collision, and i am currently not sure if you can delete the other side which is normally automatically created. Just some thoughts
Hi Unit23! Yes you can create your own custom collision objects in any 3D software (Well, i know it works for Blender 3D, Max and Maya and probably Modo). Yes, I personally use Blender 3D for all my game assets.
Making custom collision inside Blender 3D is really easy. I’ll explain it briefly in a moment. But first here’s an example of one of the Static Mesh environment objects for my game, for which a custom collision object is pretty mush essential, just to show why I am using this method:
Here you can see the base Static Mesh (5200 Tris):
As you can see the “Concave” nature of the asset means that an auto generated collision would be useless and using Blocking Volumes would just be a mega pain in the ***.
So yeah to export custom collision asset from Blender -> UE4. Make your low poly collision asset in Blender as a separate object (It must have no holes in the mesh - IE all contiguous geometry, otherwise it can yield bad results in UE4.). Your collision object must be named UCX_ObjectName and must have the exact same Object Name as your Static Mesh, but with UCX_ at the start. Select both your objects and export as FBX. Check “Selection Only” in the export options. Import to UE4 - in the Static Mesh Import options uncheck “Auto Generate Collision” and uncheck “One Convex Hull Per UCX” (That option simplifies collision assets to single collision primitives) and click import. Voila! When you open your Static Mesh in the Static Mesh editor, click the “Collision” button to view collision and you should see your collision as a purple wireframe mesh!
So to answer your last question Unit 23. You cannot have “1 Sided” collision assets / primitives. If you try to make a single sided collision asset, UE4 will create an incorrect primitive that goes off into infinity. Try it you’ll see what I mean. Also that’s why you can’t have “holes” in your collision asset - the collision mesh must be watertight and it must have some volume. The most simple custom collision mesh you can create is a Tetrahedron (3 sided pyramid), and as far as I can tell more complex collision assets are broken down by UE4 into multiple tetrahedrons (the most simple collision primitive).
Thanks for your answers guys - hope you found this all interesting.