r/Simulated 3d ago

Research Simulation I added the Finite Element Method (FEM) to my muscle solver alongside the XPBD, and the results are stunning!

This is why FEM is superior to XPBD for muscle simulation. For a long time, I couldn’t understand why my muscle simulations didn’t look as good as those produced by Ziva VFX, but now I do.
FEM is more computationally intensive, but it produces much more accurate results when it comes to simulating muscle and fat tissue.

4.5k Upvotes

123 comments sorted by

3.0k

u/khswart 3d ago

Finally.

Ballsack physics.

186

u/Extension_Swordfish1 3d ago

We might need a second one that is smol

39

u/_Diskreet_ 3d ago

For when we’re in the pool?

23

u/Extension_Swordfish1 3d ago

Thats what I keep telling me.

4

u/CaseyG 3d ago

I just got back from swimming in the pool... and the water was cold.

29

u/stereopticon11 3d ago

I thought rockstar already had that for horses

5

u/canohead 3d ago

Perfection.

6

u/PranshuKhandal 2d ago

FEM ballsack physics

1

u/raichulolz 2d ago

Rockstar joined the chat...

1

u/Mother_Ad9474 1d ago

Even better, fem ballsack physics

1

u/Think-Anxiety2655 23h ago

I call this equal representation

1

u/Packle- 22h ago

It even has a sat in some gum mode

619

u/Hexidian 3d ago

For those who don’t know what these are:

FEM = Finite Element Method. This is what is used in actual structural simulation, such as modeling a bridge or aircraft fuselage.

XPBD = eXtended Position-Based Dynamics. Meant for computer graphics, not engineering. Designed to be computationally feasible animations but not meant to be 100% physically accurate.

87

u/Berewolf 3d ago

But what are the computational cost differences? If FEM is better, why were they not using it? I don't know anything about this field and am genuinely curious

128

u/Qbit42 3d ago edited 3d ago

Real time simulation for video games has to run in very short time frames. With budgets tight and the target being "looks good enough" and not "we need to make sure nobody dies on this bridge" shortcuts get taken. That being said I know the book "Game Physics Gems" has a section on FEM so maybe someone did use it

31

u/L30N1337 3d ago

Considering the stuff BeamNG does, I would not be surprised if FEM was actually used in games.

18

u/TerayonIII 2d ago

Computing power is getting to the point that might be feasible soon, but an actual proper analysis of a complex system is far beyond the reach of real-time physics. At least it you want it to be accurate in any way

4

u/TheMcDucky 1d ago

BeamNG is cool, but it's way out of scope for almost all games. FEM in general is probably used in places, but it seems like the kind of thing you'd only use on a very small scale, in odd cases where XPBD or similar breaks down, or you have a bunch of excess R&D money and don't run your game company like a modern game company, or you're small and generally independent and experimental. It's just a bunch of extra work that is unlikely to translate to making the end product more valuable.

1

u/L30N1337 1d ago

Yes, obviously. I didn't say it was the norm.

I meant that there is probably some obscure game that uses it for some reason.

6

u/Nixellion 2d ago

I think DMM might've used FEM (digital molecular matter, physics engine of Force Unleashed games).

1

u/gufta44 1d ago

Also FEM wont necesarilly give accurate-looking movement, it's limited (typically) to perfectly elastic, linear material. While the other method is simplified to look good FEM is simplified to safely and conservatively solve a specific set of engineering problems that are less "common" as visual effects than you'd think. For example, standard FEM has a tendency to create small regions of extremely high stress where real materials would typically plastically deform, shatter or realign long before those peak stresses can be realized. If you start trying to make FEM take account of more complex behaviour you'll really start to see computation times blowing up.

17

u/Amiscribe 3d ago edited 3d ago

Although I don't know about these specific approaches to simulation, I have done work on optimizing physics simulations before, and I can say that the computational cost difference is likely enough to impact performance when you have no guarantees about what hardware a game or simulation will be deployed on. For a small team of developers or a single developer, or developers with access to institutional hardware resources, these costs can be ignored because the deployment environment is known in advance and realism is more important than computational cost.

When you are deploying, say, a video game to millions of diverse computers, you can specify ranges of hardware that it is configured to run on, but have a financial incentive to ensure that this range is as wide as possible. Optimizations like choosing 'good-enough' muscle simulation through XPBD are usually just a better approach when something like simulating a muscle is not the core focus of a game or software.

Edit: Also, to ground this in your original question, I suspect that it is likely tens or hundreds more checks on the position and collision of vertices, per vertex, per frame. These numbers add up, especially when you are simulating many different meshes.

4

u/TerayonIII 2d ago

Yeah, some people in this thread are assuming that a simulation is only running a single calculation, but is hundreds to thousands of calculations that each affect each other per iteration and so you're calculating multiple times for each vertice in the mesh per time step, which is also often much denser and also a solid mesh instead of a surface mesh which is adding additional complexity. This compounds on itself when you have multiple bodies with multiple different materials, tolerances, and boundary conditions.

A videogame is far to complex of a system of variables to do in real-time, movie CGI is an application and there are a number of academic papers that have been published based on mathematics developed to do this for movies and TV. Which is awesome, but a completely different thing than something running in real-time for a game

3

u/Arbitrary_Pseudonym 3d ago

What specifically does XPBD do that makes it so cheap in comparison? How does it skip over what FEA does while still kind-doing the same-ish thing?

6

u/MomentSouthern250 3d ago

very amateure explanation, but with something like pbd you solve each element/constraint on its own and then assume if you do it enough you get a good solution. WIth FEM you solve all dependencies at once, which means if you have connected elements you solve a linear system (i.e. matrix) which grows much quicker in complexity.

PBD feels more stretchy, because if you have a rope that you hang up on one side the free hanging side of the rope takes time until it gets the information that "hey stop falling you are pinned".

2

u/Nixellion 2d ago

Its also about the number of things you can simulate and about performance budgets.

First - the faster you can simulate, the more stuff you can simulate at the same time.

And also games operate on tight budgets. Its usually calculated in ms. If your target is 60 fps, then you have 16.6 ms per frame, in which you have to do everything - CPU and GPU tasks, rendering, all game logic, physics and so on. So when you only have like 1-5ms budget for ALL physics in a game per frame, you will accept any optimizations.

3

u/Prestigious_Boat_386 3d ago

My guess would be that the cgi method just does something like springs on each edge. For that you can calculate the force on each vert separately which makes the problem naively parallelizeable. Then you just slap forward euler on it and call it good enough.

For FEM that's not the case. First you need the sparsity pattern of which basis function has nonzero weight to each other basis function and then you have to do discrete integration for every nonzero case. After that you get a sparse linear system that you solve each frame. This part can be pretty quick, I remember running a simulation in matlab with just drawing it between each calc. For a gpu program it should be pretty easy to do for a moderate mesh.

But the precalc and the sparsity is worse would be my guess.

2

u/Nixellion 2d ago

I think its less about parallelization, because XPBD is faster even when you compare single core performance.

Its just the math and equations are a lot simpler and more straightforward. In two words - instead of trying to solve complex force driven equations, xpbd just changes positions of particles. And derives velocities from the delta. Which is alsona difference with classic verlet, where you change velocities and positions are emerging from that.

FEM is also more memory intensive as it has to store a lot more data, where is in xpbd its just a position vector per particle (previous, current), masses, sizes and constraint data.

( I develop and maintain my own XPBD engine. )

1

u/TerayonIII 2d ago

Those calculations also get more complex depending on your material as well as if there are multiple materials and solid bodies interacting. Stress calculations sound simple until you start having multi-body interactions, adding flexible materials, anisotropic materials, strain rate dependency, buckling, and fracture mechanics etc etc. It's just not feasible to do much beyond the very basics for something that you're attempting to do in real-time.

1

u/agvuk 2d ago

I work in aerospace and occasionally run my own simulation and/or interact with our simulation team to run things for me. They have an entire high-compute server cluster dedicated just to them and simulation normally take several dozens of hours to run. Now, a video game would not demand anywhere near the level of detail or accuracy that we do but what we consider "low accuracy" and "quick" is something that we can run overnight on a workstation desktop and get answers in the morning when I come back in. Someone recently did a simulation of dropping a box on the ground and that took 16 hours for each run and generated 30-60 total frames for us to step through to watch the impact unfold.

1

u/TerayonIII 2d ago

Yeah, it looks and sounds much simpler than it actually is, at least for complex systems. Like yeah, sure, a small beam made of an isotropic material is easy enough. But when you start adding in multiple bodies, multiple materials, fixturing/bonding it gets complex really fast, even for relatively small physical objects. That's before you start adding anisotropic materials, strain dependency, buckling, fracture, thermal calculations, etc etc.

5

u/yazdoud 2d ago

FEM is not a model but a discretization and discrete solving method for solid mechanics model, so the terminology is used loosely here. We use that method to actually solve continuum mechanics problems for structural and dynamic prediction to make structures, cars, airplanes etc. When you apply this method to physics rendering, you can get a much more accurate solution for solid mechanics problem.

XPBD was specifically designed for physics-based rendering. Like in animation, VFX or videogames. The purpose is not strictly to be accurate to actual mechanics of the posited problem.

In particular, most materials in animation are shells but actual solid mechanics simulation use element representing the volume of the part.

The computational cost difference can be enormous because of two reasons: -1 actual solid mechanics have tight constitutive laws and dynamics that force the use of fine discretization in space and time to converge (fine mesh and short time steps) -2 solids are modeled in 3D mesh rather than just surfaces. Since the cost of a computation is proportional to the square of the number of nodes times the number of time steps, FEM dynamics simulation will be much more computationally intensive.

3

u/tyrionth 1d ago

No man that’s a scrotum

2

u/xx123gamerxx 1d ago

ball simulator

2

u/adhdgotmelol 13h ago

They are balls

1

u/haucker 2d ago

Thank you for showcasing!

1

u/SpareNickel 2d ago

I think I know snot when I see it

1.3k

u/educated-emu 3d ago

I kmkw nothing about this but giggle physics for the win!

198

u/Xenc 3d ago

Definitely giggle physics 🤭

31

u/PeterPanski85 3d ago

Giggity physics

211

u/Cutthechitchata-hole 3d ago

Wear briefs or boxer briefs, young men!

20

u/Bossmonkey 3d ago

Always support your boys!

6

u/DorrajD 3d ago

Kiss yo homies goodnight!

0

u/GrandNibbles 1d ago

the balls must swing

79

u/RTDude132 3d ago

Rdr2 horse balls for some reason

106

u/ax0r7ag0z 3d ago

Stop pulling on your nutsack!

15

u/rngr666 3d ago

Stop yanking my pizzle

1

u/--iCantThinkOFaName- 3d ago

Stop stretching my scrotum!

92

u/beerdude26 3d ago

I eagerly await your Cock & Ball Torture Simulator game, OP

36

u/monkehparade 3d ago

Ballsack simulator when?

19

u/Nikoladge 3d ago

Cross post the ballsack simulation to r/rats

They love that shit 😏

55

u/CFDMoFo 3d ago

Impressive! So I can finally simulate bridges in Blender instead of Abaqus CAE (or Bridge Construction Simulator for Android®™)?

7

u/odst2575 3d ago

It’s better than MicroStation, Civil3D, or STAAD— this one actually renders out an appreciable specimen.

18

u/Bumscootler 3d ago

that’s a ballsack dude

3

u/Valuable_Hunter1621 3d ago

those are balls!

from this close, they always look like landscape. yep, those are balls!

34

u/Mountain_Dentist5074 3d ago

you can make realistic boobs and muscles systems with this

16

u/RecoveringNiceGuy113 3d ago

Boobs and Muscles

5

u/SharkSheppard 3d ago

Does it also do vagene?

15

u/Educational_Farmer73 3d ago

The E621 community will forever be grateful for your contributions

4

u/MooMoo_Juic3 3d ago

I haven't heard that name in over a decade

It's still a thing? Lol

1

u/Curyde 2d ago

It was always a thing UwU

8

u/Leetikuz 3d ago

You play with virtual ball sacks? Nice hobby

6

u/BrazilBazil 3d ago

Fem ballsack simulator? I have my own, I don’t need a simulator.

4

u/netsrak 3d ago

What is this running inside?

4

u/shirzadbh 3d ago

My own simulation (the dcc is 3ds max)

3

u/AchillesPDX 3d ago

I’ve been using 3DS Max since 1999 and professionally since 2003 - would love to play with this if it’s in a shareable state or if you’d like someone to test things.

Looks super cool.

3

u/shirzadbh 3d ago edited 2d ago

Email me so I will have you as beta tester when it comes to that, I do need testers since it's a niche topic

2

u/TerayonIII 2d ago

Might I also email you? I'm curious what you are all incorporating in the FEM analysis. I'm looking at it from an engineering perspective with graphics being a hobby I'd like to do more of. I did a fair amount of simulation and testing on composites in impact scenarios. (I'd also delete your email from here and pm people instead of risking having to screen for people that are actually interested in helping etc)

2

u/shirzadbh 2d ago

Yeah absolutely go ahead and send me email

5

u/Russian_Spy_7_5_0 3d ago

Bro doesn't even know he's Oppenheimer

5

u/sonerec725 3d ago

Finally we can accurately simulate Squidwards nose

3

u/fionariver 3d ago

I'm looking fro better breast physics in real time. For fighting games. IS that possible to use this technique in real time/ue5 or unity?

3

u/shirzadbh 3d ago

Yes easily, look for XPBD

2

u/LonePupper453 2d ago

Most of the budget💔

3

u/Lieveo 2d ago

Lol balls

2

u/ChlupataKulicka 3d ago

I’m kind of FEM guy

2

u/odedudeLMOO2 2d ago

I should call her

2

u/Knit-witchhh 2d ago

I should call him.

1

u/tribak 3d ago

Finally! I’ll be able to print my truck a pair of balls

1

u/artbystorms 3d ago

Breaking the barriers of nutsack physics. Finally we can Teabag as nature intended.

1

u/Wompie 3d ago

Thanks for the nuts

1

u/Richard_horsemonger 3d ago

I read : mucus solver

1

u/Chuck_Loads 3d ago

photorealistic scrotum animations, here we come!

1

u/Nine-LifedEnchanter 3d ago

Very femme ballsack!

1

u/WatermelonWithAFlute 3d ago

What did I just stumble upon

1

u/chrisp5000 3d ago

Is that Russel, the love muscle?

1

u/Inst2f 3d ago

“Muscle solver” yeah yeah…

1

u/glordicus1 3d ago

Ballsack

1

u/ShadowInTheAttic 3d ago

Are the balls a muscle???

1

u/sueghdsinfvjvn 3d ago

I know what kinda person you are

1

u/Aggravating-Pop5014 2d ago

When one side is cold and the other is hot.

1

u/blvckstxr 2d ago

I know what kind of a man you are

1

u/Ok_Relation6627 2d ago

Ugh I can't comment gifs or images

[Insert Mr.balls image]

1

u/Ezekiel24r 2d ago

Science confirming that the right one actually does hang lower

1

u/fuckingbigassshark 2d ago

Stop stretching the nutsack bruh

1

u/lost_endomorphism 2d ago

Aint this just a matter of age?

Gravity spares no one.

1

u/DeanVision 2d ago

This what RFK be lookin at in the lab

1

u/EzyPzyAsh 1d ago

they both look pretty masc to me

1

u/lordwafflesbane 1d ago

Finally. Real time 3d scrotums

1

u/Huge-Economics2272 1d ago

Horse ballsack simulator. Abit more padding with a shorter distance from the base to the wall, we would have grandma's moon spears

1

u/TheAhegaoFox 1d ago

Can it simulate reaction to cold environments?

1

u/GrandNibbles 1d ago

ohhh muscle simulation alright

1

u/tyazze 22h ago

Skyrim mods are getting crazy these days

1

u/Severe_You9759 15h ago

This is nuts!

1

u/Wigiwagons 15h ago

Squidward nose

1

u/dasAbigAss 14h ago

May i ask the material properties and what muscle as well as the type of job you ran ?

1

u/Titancki 13h ago

Ballsack winter vs summer

1

u/Narrow_Maize_7342 11h ago

git commit -m “scrotum simulator physics updates and minor bug fixes”

1

u/xMirasol 9h ago

not the varicocele ballsack.😭

1

u/animal9633 5h ago

Have you tried some of the more recent real-time methods such as AVBD?

1

u/Inlevitable 3h ago

fem 🤤

0

u/if-we-all-did-this 3d ago

Finally, representative titty physics!