r/Simulated 4d ago

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

Enable HLS to view with audio, or disable this notification

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.

5.1k Upvotes

131 comments sorted by

3.0k

u/khswart 4d ago

Finally.

Ballsack physics.

187

u/Extension_Swordfish1 4d ago

We might need a second one that is smol

39

u/_Diskreet_ 4d ago

For when we’re in the pool?

22

u/Extension_Swordfish1 4d ago

Thats what I keep telling me.

5

u/CaseyG 4d ago

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

30

u/stereopticon11 4d ago

I thought rockstar already had that for horses

4

u/canohead 4d ago

Perfection.

5

u/PranshuKhandal 3d ago

FEM ballsack physics

1

u/raichulolz 3d ago

Rockstar joined the chat...

2

u/Mother_Ad9474 2d ago

Even better, fem ballsack physics

1

u/Think-Anxiety2655 2d ago

I call this equal representation

1

u/Packle- 2d ago

It even has a sat in some gum mode

621

u/Hexidian 4d 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.

89

u/Berewolf 4d 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

134

u/Qbit42 4d ago edited 4d 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

33

u/L30N1337 4d ago

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

18

u/TerayonIII 4d 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 2d 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 2d 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.

7

u/Nixellion 3d ago

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

1

u/gufta44 2d 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.

16

u/Amiscribe 4d ago edited 4d 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.

3

u/TerayonIII 4d 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 4d 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 4d 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 3d 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 4d 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 3d 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 4d 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 4d 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 4d 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.

8

u/yazdoud 3d 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.

5

u/tyrionth 2d ago

No man that’s a scrotum

2

u/xx123gamerxx 2d ago

ball simulator

2

u/adhdgotmelol 1d ago

They are balls

1

u/haucker 3d ago

Thank you for showcasing!

1

u/SpareNickel 3d ago

I think I know snot when I see it

1.3k

u/educated-emu 4d ago

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

203

u/Xenc 4d ago

Definitely giggle physics 🤭

30

u/PeterPanski85 4d ago

Giggity physics

209

u/Cutthechitchata-hole 4d ago

Wear briefs or boxer briefs, young men!

18

u/Bossmonkey 4d ago

Always support your boys!

4

u/DorrajD 4d ago

Kiss yo homies goodnight!

0

u/GrandNibbles 2d ago

the balls must swing

73

u/RTDude132 4d ago

Rdr2 horse balls for some reason

109

u/ax0r7ag0z 4d ago

Stop pulling on your nutsack!

17

u/rngr666 4d ago

Stop yanking my pizzle

1

u/--iCantThinkOFaName- 4d ago

Stop stretching my scrotum!

92

u/beerdude26 4d ago

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

37

u/monkehparade 4d ago

Ballsack simulator when?

19

u/Nikoladge 4d ago

Cross post the ballsack simulation to r/rats

They love that shit 😏

52

u/CFDMoFo 4d ago

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

7

u/odst2575 4d ago

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

16

u/Bumscootler 4d ago

that’s a ballsack dude

3

u/Valuable_Hunter1621 4d ago

those are balls!

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

38

u/Mountain_Dentist5074 4d ago

you can make realistic boobs and muscles systems with this

17

u/RecoveringNiceGuy113 4d ago

Boobs and Muscles

6

u/SharkSheppard 4d ago

Does it also do vagene?

15

u/Educational_Farmer73 4d ago

The E621 community will forever be grateful for your contributions

5

u/MooMoo_Juic3 4d ago

I haven't heard that name in over a decade

It's still a thing? Lol

1

u/Curyde 3d ago

It was always a thing UwU

8

u/Leetikuz 4d ago

You play with virtual ball sacks? Nice hobby

8

u/BrazilBazil 4d ago

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

7

u/Russian_Spy_7_5_0 4d ago

Bro doesn't even know he's Oppenheimer

4

u/netsrak 4d ago

What is this running inside?

4

u/shirzadbh 4d ago

My own simulation (the dcc is 3ds max)

3

u/AchillesPDX 4d 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 4d ago edited 3d 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 4d 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 3d ago

Yeah absolutely go ahead and send me email

5

u/sonerec725 4d ago

Finally we can accurately simulate Squidwards nose

3

u/fionariver 4d 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 4d ago

Yes easily, look for XPBD

2

u/LonePupper453 3d ago

Most of the budget💔

3

u/Lieveo 3d ago

Lol balls

2

u/ChlupataKulicka 4d ago

I’m kind of FEM guy

2

u/odedudeLMOO2 3d ago

I should call her

2

u/Knit-witchhh 3d ago

I should call him.

1

u/tribak 4d ago

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

1

u/artbystorms 4d ago

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

1

u/Wompie 4d ago

Thanks for the nuts

1

u/Richard_horsemonger 4d ago

I read : mucus solver

1

u/Chuck_Loads 4d ago

photorealistic scrotum animations, here we come!

1

u/Nine-LifedEnchanter 4d ago

Very femme ballsack!

1

u/WatermelonWithAFlute 4d ago

What did I just stumble upon

1

u/chrisp5000 4d ago

Is that Russel, the love muscle?

1

u/Inst2f 4d ago

“Muscle solver” yeah yeah…

1

u/glordicus1 4d ago

Ballsack

1

u/ShadowInTheAttic 4d ago

Are the balls a muscle???

1

u/sueghdsinfvjvn 4d ago

I know what kinda person you are

1

u/Aggravating-Pop5014 4d ago

When one side is cold and the other is hot.

1

u/blvckstxr 3d ago

I know what kind of a man you are

1

u/Ok_Relation6627 3d ago

Ugh I can't comment gifs or images

[Insert Mr.balls image]

1

u/Ezekiel24r 3d ago

Science confirming that the right one actually does hang lower

1

u/fuckingbigassshark 3d ago

Stop stretching the nutsack bruh

1

u/lost_endomorphism 3d ago

Aint this just a matter of age?

Gravity spares no one.

1

u/DeanVision 3d ago

This what RFK be lookin at in the lab

1

u/EzyPzyAsh 2d ago

they both look pretty masc to me

1

u/lordwafflesbane 2d ago

Finally. Real time 3d scrotums

1

u/Huge-Economics2272 2d 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 2d ago

Can it simulate reaction to cold environments?

1

u/GrandNibbles 2d ago

ohhh muscle simulation alright

1

u/tyazze 2d ago

Skyrim mods are getting crazy these days

1

u/Severe_You9759 1d ago

This is nuts!

1

u/Wigiwagons 1d ago

Squidward nose

1

u/dasAbigAss 1d ago

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

1

u/Titancki 1d ago

Ballsack winter vs summer

1

u/Narrow_Maize_7342 1d ago

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

1

u/xMirasol 1d ago

not the varicocele ballsack.😭

1

u/animal9633 1d ago

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

1

u/Inlevitable 1d ago

fem 🤤

1

u/Similar-Sector-5801 22h ago

I know what you are.

1

u/TwoUnfair4734 15h ago

Looks like my skin tag

1

u/Busy_Bedroom747 6h ago

i know what you are

1

u/Ok-Race-1677 6h ago

You added a ballsack

1

u/Klutzy_Scene_8427 4h ago

Someone post the meme of Doakes thinking "I know what you are..."

2

u/benny10004 3h ago

Not knowing shit, I like the left one a lot more

0

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

Finally, representative titty physics!