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

Introduction
Today I will be explaining why meshes are superior to unions and how to convert your unions to a mesh.

Why Meshes Are Superior To Unions

1. Unions can corrupt
If you have ever used unions before, then you probably know that they can corrupt randomly, which could potentially ruin hours of hard work. Although there are ways to fix this, it is more reliable to just use meshes instead, which shouldn’t be corruptible, and can easily be reuploaded if a problem arises.

2. Unions can only scale uniformly
When scaling a union, you will be unable to scale it individually on just one axis; it will automatically enlarge or shrink the union to maintain it’s original proportion, which is annoying to me, especially when I want to reuse something but also want to make it have a different proportion. Meshes, on the other hand, can be scaled just like parts and can be stretched without the entire meshes also enlarging or shrinking.

As of June 15, 2022, Roblox has changed union scaling behavior, which allows non-uniform union scaling. You can read about it here.

3. Unions are inefficient
In the 2018 Roblox Developer Conference, it was announced that meshes are indeed better than unions. You can watch about it here.

Here is a helpful post explaining exactly how unions are inefficient. You can read about it here.

Converting Unions To Meshes

1. Export the union
image

2. Create the mesh
image

3. Upload the file
image

Optimizing Meshes

Be sure to check out @MissingFeature’s tutorial as well, which involves importing the file to Blender to optimize it. You can read about it here.

Congratulations
You have now converted your union into a mesh. This is incredibly useful, especially if you want to use Roblox’s CSG instead of third-party modelling software, but want to prevent corruption and improve performance.

78 Likes

SolidModels (Unions) and Meshes are (iirc) basically the same behind the scenes, it’s just one can be separated within Roblox.

Not 200% sure if this is the case, but iirc you can use a SolidModel’s ID in a SpecialMesh or MeshPart.

Roblox * fyi

4 Likes

I believe someone has already made a post on how to convert unions to meshes and, it goes into much more detail in my opinion

Edit* This post is much more simple I suppose

4 Likes

This tutorial shows the much better way on how to convert it, whereas mine shows a more complicated way to convert.

2 Likes

@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?