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

Introduction
Hello ROBLOX Developer Community! This is my first time posting a tutorial here, so please send me plenty of feedback in the replies.

Today I will be explaining why meshes are superior to unions and how to still be able to enjoy using CSG.

Unions can corrupt
If you have ever used unions before, you may have encountered a time where your unions corrupted. This is a known problem, and although there are ways to fix this, it is more reliable to just use MeshParts instead, which shouldn’t face the same problem.

Unions can only scale proportionally
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 MeshPart also enlarging or shrinking.

Unions are laggier
At the moment, this statement may not be true. However, in the ROBLOX Developer Conference 2018, it was announced that MeshParts are indeed better than unions. You can watch it here.

How to Easily Convert Unions To Meshes
It is so easy that you can do it in just 2 steps.

  1. Export the union
    image
  2. Create a MeshPart
    image
  3. Click on the folder icon next to MeshId and select your .obj file
    image

Congratulations! You have now converted your union into a mesh. This is incredibly useful, especially if you do not know how to use third-party modelling apps but know how to use CSG, but want to prevent corruption, have control over scaling, and want to improve performance.

Edit: Be sure to check out @MissingFeature’s tutorial as well, which is a bit more complicated, but involves importing to .obj file to Blender for optimization and enhancement purposes: How To Convert Unions Into Meshes

Thank you for reading my tutorial. Once again, please do leave me some feedback and critique

26 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

1 Like

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

2 Likes

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

1 Like

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

4 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

27 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:

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.

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

I think this tutorial its ok, but there are some things that you haven’t noticed @DanTDM_Rocks999 , i have exported this model (wich is made with unions) and i experienced this issue (wich i don’t know how to fix, please if you know how to fix it, correct me):

Also:

  • you don’t get textures, you get vertex painting, and there is no way to convert VP to textures (correct me if im wrong)
  • unions has a limit of 5k triangles, if you made a model with more than 10k triangles (wich is the max capacity of triangles), and then you imported it it will not export, if you reduce the triangles, the model will not be the same
  • Unions doesn’t corrupt (well, that never happened to me lol) however there is a way to recover them
  • Unions are regular parts :arrow_down:
  • if you lag a lot with unions (wich happened to me a lot of times), you change RenderFidelity > Precise to Automatic, and lag will be reduced a lot
  • When exporting unions to meshes, you can get really much errors, like this:

(Pretty disturbing if you ask me)

Notice some places that the triangles goes “dark” :arrow_upper_left:
Decals doesn’t exports rightly too, notice the white parts of the model, well, there goes the decals, and there is no way to include them on a texture (correct me if im wrong)

Hope this helps!

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