Why Meshes Are Superior To Unions And How To Easily Convert Them

@DanTDM_Rocks999 As the replies on MissingFeature’s post mentioned, there’s no significant performance benefit to converting it to a mesh. Meshes are better because unions are poorly optimized in Studio, just changing the file type is unlikely to change anything.


Meshes are better to use because there’s great software out there that allows you to optimize its triangle count to keep the same approximate level of detail while removing unnecessary tris, which unions do not allow you to do.

8 Likes

Although this is certainly a good method in converting unions to meshes, I’d recommend cleaning them up and optimizing them beforehand as to get better results. As @posatta has also mentioned, there is no signifcant performance boost however, it should help you somewhat :

First off, lets say you had a more complicated union that has multiple negates + merges/union.


https://gyazo.com/6639bdfb324fb831dcf00aa142111dfb

Now what we want to do is take the image and convert it to a obj of course. Taking it into blender via wavefront object by clicking “import” in “file” for “obj” does allows us to get the mesh into blender.


https://gyazo.com/02d03c1d179fc0d76d906dac4a3a067b

Once you’ve done that, click the “modeling” tab above while selecting the union. Make sure the union is bright yellow/orange instead of orange to be sure to select.

As you’ll notice here, there are some unneccessary faces/vertices we can get rid of:


https://gyazo.com/bf68b25a4944df8de65bddad6f8d34b0

Now go to “Mesh” and click “Cleanup” and “Merge By Distance”. A menu should pop up below allowing you to change the distance it merges by, change as desire.


https://gyazo.com/586d8c60cb229d292cdad9b35b86de17

Next, click “Face” above and click “Tris to quads”, this can allow you to more easily have better lighting/faces.

There are also various methods you can use to optimize/change the union however you’d like, if you want to get rid of the odd lighitng as well, enable autosmooth:


https://gyazo.com/fb9029195820b0c6cccdcf2451ab0a1e

However, if its greyed out for you, press space (a search bar should pop up if you did spacebar for search instead of play animation) and type in “Clear Custom Split Normals Data”. Once you’ve done that, you can finally change the angles to fix the lighting:


https://gyazo.com/fb9029195820b0c6cccdcf2451ab0a1e

Now you can export the selection into a obj or fbx. Going back to roblox and exporting as using the same method grants you this:


https://gyazo.com/9532dd4ff52f5a5faaf04499cb97e6f1

For further optimization, you can set the render fidelity to automatic if it allows you (there is a current bug that sets it back to precise only sometimes).

Change collisionFidelity to box for best optimization however, for best collisions, set it to PreciseConvexDecomposition for the best possible collisions, for something inbetween, change it to hull or default. (Or if you don’t care about collisions, set cancollide to false)

And now you’ve got a full fledged union to mesh :+1:

https://gyazo.com/27701b1784e73544f23533a77f6e7108

63 Likes

Out of interest, is there any way to convert a mesh to a union?

(My use case is very specific, I’m not just being stupid)

1 Like

Thank you for this tip! I don’t know much about Blender, but have it installed just in case. I will list your post as a solution for others to see.

I did see your tutorial, but I wondered if you could do it without the use of a third-party application like Blender. Regardless, I have also learned that Blender can be used to optimize your union, so I will be providing a link to your tutorial at the bottom.

There is a period of corruption. After that, I’d say about a week the CSG is stable and does not corrupt. I’ve been using my same old prefab union furniture in everything I build for four years now without any problems. Corruptions can occur even a day after, oddly enough in my experience. It happens ~5% of the time for my big furniture pieces of twenty parts or so. Which is more likely than you’d think.

As for the lag, I am near certain it comes down exclusively to the number of triangles and by extension vertices of the mesh. CSG is notoriously bad with this, and even if it weren’t where those vertices go is not a conscious decision.

If you can model externally, you should, but if you can’t, you shouldn’t be bothered by it.

1 Like

Adding to this, a quick reminder is that unions’s CSG can be easily fixed with the studio software by lowering level of detail and it’s collisions.

This is false, both unions and meshes are the same, the only way to make them less laggy is to either use a 3rd party software, specially on meshes to reduce it’s triangle count, yet there’s another way and I show it here:

1 Like

Nice tutorial, but I’m probably going to be staying with CSG unions. Mostly because I don’t build, and I’ll be using realtime CSG to create unions. Great for people who build a lot though!

https://www.youtube.com/watch?v=rBrILsiVdtQ&feature=youtu.be&t=1667

I got that information from an RDC conference made in 2018. I don’t know if this is false now, but that’s why I believe meshes are less laggier than unions.

Just to clarify, my tutorial didn’t mean that CSG shouldn’t be used. You should and can use CSG, but once you are done, you can just easily convert it into a mesh, which is better as said as my tutorial.

Do you have a recent source (e.g. a tech demo) to show this?

Both of them pull the data from roblox.឵com/asset, both of them (internally) render as OBJs; the only difference is that SolidModels can be easily pulled apart and built in studio, the only possible losses could be in studio when actively editing a SolidModel.

1 Like
2 Likes

Thanks for this great tutorial, it helped me a lot. I thought I had to put in blender and do weird stuff until I saw it was simple! :smiley:

Your welcome! I just want to say that my way is very simple and does not need Blender, but in my post I have provided a solution that uses Blender just to help optimize the mesh before you upload it. Otherwise, it’s as simple as that.

1 Like

Unions behind the scenes will actually seperate each generated triangle into it own seperate face meaning every draw call behind the scenes is drawing each triangle seperate rather than generating a triangle strip

1 Like

How do i turn a mesh into an union?

Ok this is an old topic but it was marked as solution for some reason when its not right. When you export the mesh into blender and remove the triangulation, if you import it back to roblox it will retriangulate itself. So you’re not actually cleaning up the mesh at all. Every mesh gets triangulated when you import it to roblox automatically to be compatible with game rendering. So if blender says you have a mesh with 500 triangles, sorry to break it to you but in reality you will end up with 1000 triangles once you import to studios.

So if you’re trying to optimize unions you created in studios, the only way to do that is to just learn blender and recreate the model there.

3 Likes

(Sorry for late response)

Thats what I thought of at first when I was re-reading the post however:

Roblox’s triangulation system is different than blender’s way of triangulation. This method works the best when:

The object is complex/complicated CSG.
The object has messy triangluation/wireframe.


To test this theory, I took an object with a fairly complex CSG. (The wireframe in studio and in blender)

As you can see, yes, the object has the same wireframe and contains roughly the same amount of triangles. (You can read the “TriangleCount” which is 1668 in studio and 1664 which is close enough, roblox does something odd I guess).


So, as the test, I took the mesh from studio (In picture) and did the same process, Merge by distance, tris to quads.

After that, I checked the tri count.

The amount is 973 HOWEVER. As you stated:

So, as a test, I exported the optimized mesh back to studio and compared:

The highlighted object is the one with the optimizations, the one infront is the csg.

Of course, we want to check the tri amount but for some reason mesh parts cant show TriangleCount.
So instead, we’ll be exporting the optimized meshpart back into blender.


The results?

Non-optimized

Optimized

Of course, if I’m wrong, please correct me, ty :+1:

Something I’d like to mention that is slightly interesting: (Ignore my awful naming)
image
“testingtrianglesobject” is the original csg model exported from studio. It has 219 KiB.
“testingobjectagainmeshed” is the optimized model that was exported from blender. It has 66 KiB.
:testingAGINONELASTTIME" is the optimized model that was exported from studio. It has 212 KiB.
Also, the mtl for the optimized one contains more?

:man_shrugging:

2 Likes

Not really. Meshes have different system that allows for pre-baked geometry and strengthened support for instancing.

Unions use an active CSG binary tree calculation.

Just gonna say that the later versions of Blender don’t do that anymore and instead you should press F3.

Also, there shouldn’t be any problem if this method is applied for every union that’s created no matter the size or complexity?