Some tips on making '2d' unions faster

Hello!

I’m currently working on a drawing game. Because the number of parts required to have an enjoyable experience is relativly high, we opted to using unions to combine them and reduce significantly the lag that they caused.

Currently, the most significant issue is the time it takes to union all of the parts togheter. Our proccess is to wait until there are more than 500 individual parts and then union them. The time taken for an individual union is ~0.3s when using wedges instead of blocks for the lines (flat face). This isn’t a lot but we have cases where it could become an issue.

We wanted to ask people who know more about unions if there would be any ways to make this process faster?

One trick we know will work but which we don’t know how to achieve is artificially removing the useless faces (sides and back as the drawings are 2D) of the bases used for the drawing. We know that this involves modifying the unions mesh data but we don’t know how so if someone could help us, you are welcomed!

I once made a drawing system for fun, and I used meshes for the paint object.

I gave the mesh only one face, which was on the top/front surface and I gave it a cylinder shape with very few polygons in it, making it an Octagon. I did this in blender, if you’re going to ask how.
image

I then limited the minimum distance between 2 paint objects depending on the brush size and the distance between the paint objects.

This could easily handle tens of thousands of parts easily with no performance impact (Until you selected them all in explorer, hehe)

I tested the system with a friend of mine, and we drew on a wall for around 10 minutes with no impact on either of our frames per second.

But to answer your question, I don’t think there is a way to make unions faster. You’re probably better off doing something similar to what I just described to fix any performance issues.

1 Like

Roblox has a really hard time handling lots of parts at the same place (after 10K it starts to lag on my relativly powerfull pc).

I was running this on a GTX 970, as 120fps with few to no drops, while there were 10k parts on screen at once. I have since upgraded to a 2060, but again, it ran really well on a 970 which anyone with a low budget gaming computer should have at this point.

As for mobile, tablet and console, I’m not too sure how it ran because him and I tested in studio.

But then again, its only rendering a single face instead of 6 or more, taking a lot less rendering power.

Also,

This helps a lot with there being too many parts.
The math would be something simple like BrushSize/1.5, with BrushSize being the size of the part on the X and Z axis (Y being around 0.05). Its exactly what I did, and it ran perfectly fine.

Having this limiter again, really helps with frames and keeping the amount of parts down, as well as also avoiding Z-Clashing if you set your parts up correctly. Again, this is where the Octagon shape comes in really well, with it being able to have very little Z-Clashing.

Also, your solution of using unions will start to be a bad one once there are a lot of polygons, as unions have a polygon limit to them. This will slowly cause the quality of the lines to deteriorate over time.

In all my tests, have lots of part in the same place causes lag when moving the camera. Idk if this is because I have a amd card (because both my desktop and laptop which experience this have an amd) but for me this occurs. If you want I can send you a benchmark studio file so you could try running it.

I would like to see how my computer runs the benchmark file, and again, have limits for how close parts can be put together!