Ok so, I’ve found the key to POSSIBLY do the most “advanced thing on roblox” (people are lazy and don’t think hard), Ok so. imagine it like this,
You have two balls,
Green is the collison (literally just a ball part thats invisible with cancollide on)
Blue is the editablemesh (cancollide off etc)
So, When the balls are seperated and not grouped together, they will render their own editablemesh.
Now, another example when they are grouped / together.
Here are 2 groups, same colors as before. When they are together, they will use ONE editablemesh to render themselves.
Now, I think you get what im saying here.
How do we. (Yes you and me, cause i know people will kickstart this into a bunch of madness),
Calculate the area of those balls, convert it to verticie positions, and make a editablemesh? While trying to keep it as optimized as possible?
To sum it up. How do we take the area of a group of balls, Use a singular editablemesh to wrap them together.
i wrote this at 12 am please dont get on me for how bad i explained this
Looking deeper, this might be the method many fluid simulation departments use, but have custom physics controllers for their particles. so Yes, This is literally is the key to making Water on roblox. Crazy huh…
Some fluid departments also add quick-calculating to determine if a particle is being realistic or not, as shown here.
To optimize, you’ll of course, have to use a meshpart for the collisons, (so you can take the verticies, i believe), but makesure there isnt much verticies, to simplify the editablemesh scanning.
Yes i know, it wont look the same as what you’d expect from more creditable fluid simulation, but that’s because we dont have a custom physics controller, If anything, I just first wanna knock out how we’re gonna even make a editablemesh like this.
EditableMesh would be very laggy and demanding on the device. It would work though. Normal methods use shaders to connect fluid particles. A simple way to do this is using raymarching. Sadly the Roblox engine does not have a shader editor.
If the physics solver doesn’t have rigid collision with other particles (allowing them to almost overlap the same position), there are algorithms for searching which particles are the closest to any one particle, and it’s possible to just use the positions of particles that are “surface particles” and construct the mesh that way. To get the rotation of vertices (so the triangle is visible) you have to know the general direction where there is the least particles or which direction the closest grouping of particles are. Raymarching is the better solution for rendering the water, but until we get support for actual shaders, trying to render a water simulation (and computing the physics), we probably won’t get close.
Anyways check out this awesome video https://youtu.be/rSKMYc1CQHE?si=P4Hyap8XT32wwHj1
Then we start one by one, no?
Each particle would have 4 verticies, almost like a square.
It reads those verticies and generates a hull around both of the particles.
So in our test scenario, lets have two particles. We stick them together.
Is there any current method on generating a hull of these two particles? if there is, we have hope.
I’m a bit late but I’d like to try to give an answer.
Many fluid simulations dont really try to render a mesh of the fluid, but instead change their rendering system! The ones you mentioned in the video come from something called raymarching! This technique is similar to raycasting, except it has one peculiarity:
Raymarching used SDF’s (Signed Distance Functions), which are these mathematical formulas which allow us to render basic objects with defined properties, such as spheres, cylinders, cubes, etc.
A wierd consequence of using SDF’s is that you can then unite different objects!
As you can see, these two spheres merge, forming this wierd effect! Put enough spheres, or change the distance at which they merge, and boom! You can simulate a liquid.
As a note, raymarching is pretty resource intensive, so I’m not sure how it would work in roblox real time.
Heres a link to a website about liquids and raymarching, although there are hundreds out there.
Woah! That’s really cool! I would love to see your implementation! I’ve always wanted to get into liquids and real time rendering, but for now I’m sticking to my smoke solver, which kind of makes it impossible to render without trilinear filtering or volume raymarching (so slow).
This mesher actually just reminded me of an SPH project I was working on! I had to stop because I couldn’t render in real time, but I’ll definitely look back at it now!
I think what you might be looking for is some sort of voxel or remeshing algorithm.
Essentially, you map all the particles to a voxel grid, calculate how “full” each voxel is and based on that you generate a bunch of triangles (like a rounded cube) and connect vertices to neighboring voxels.
Algorithms similar to what terrain systems use.
Also be wary that this will likely be very slow even if you manage to multi-thread it somehow.
You’re doing all of this in Roblox Lua after all and parallel Luau isn’t exactly well-optimized for communication between actors.
Okay, here is a place that’s using my SDF mesher. It’s uncopylocked, feel free to use on Roblox.
The basic idea is that you create an sdfData that contains 3 functions - one that gives the extents, one that evaluates the signed distance function, and one that does any precomputation you might need. There are 2 built-in functions, one of them creates 2 animated spheres that are smoothly unioned, the other looks in a specified folder and unions all block and ball parts in the folder into a single mesh.
It’s using a meshing algorithm called Surface Nets, which is similar to Dual Contouring, but a bit simpler.
Could we get a documentation pages, on what the functions do and so, I’m quite confused and frankly im just reading the code throwing functions together hoping they work. If not, could you make a basic example script that converts all ball parts in a folder in workspace using SDF? (and make it work for any amount of parts?)
I noticed with this as well, present issues in topology, (when transparency 0, and using glass material, some corners of the SDF are invisible, also it has a inability to make SDF’s from moving balls with a velocity, usually.
The text in the video is just apart of the blob-cluster system i made, if any particle gets past a maximum distance it destroys itself, and also a always-updating accuracy text from the center position of the blob.
This is some insane work. I am a shader nerd who makes SDF marched scenes for fun, so this will be awesome to play with! I have been wondering if using SDFs in Roblox would ever be beneficial, really cool!
If this truly uses SDFs in the way that I am imagining, this is an amazing project. I’ll have to check it out
The SDF raymarched scenes are amazing, although this example uses a slightly different method. Instead of implementing the surface at the same time it is rendering it in the GPU, it’s creating a mesh from the SDF on the CPU.
The main advantage of this approach is that you get a mesh out, which can then interact with the rest of the roblox engine, like physics and collision, etc. The main disadvantage of the method is that instead of pixel-perfect shapes, you get a mesh that approximates the shapes, so it’s not quite as perfect.
I definitely understood this part. It’s perfect for the fluid simulation since you can use common SDF functions such as “smooth minium”. This method naturally gives you the approximation of the volume itself, so you don’t have to worry about actually knowing which spheres (or even individual vertices) are along the boundary of the fluid, it’s like brute-forcing the shader method on the CPU, but I think it’s still better than the alternative.
I still haven’t checked it out though, I’ll be sure to do that soon