Latest / CyberSecurity Summary / Foundations of Physically Based Modeling and Animation
Transcript
- 0:00Speaker 1: So, picture of virtual glass, right, being knocked off a
- 0:03Speaker 1: table in your favorite video game.
- 0:06Speaker 2: Yeah, we've all seen it.
- 0:07Speaker 1: Right. It hits the floor and it just shatters perfectly.
- 0:10Speaker 1: The water splashes everywhere, the little shards they scatter and
- 0:14Speaker 1: skid to a halt, and it feels like it has weight,
- 0:17Speaker 1: like it has a real physical presence. But what you
- 0:20Speaker 1: don't actually see is the frantic, microscopic war of mathematical
- 0:26Speaker 1: equations firing.
- 0:27Speaker 2: Off thousands of times a second.
- 0:29Speaker 1: Exactly thousands of times, just to tell that glass it
- 0:31Speaker 1: hit the floor instead of falling endlessly into the void.
- 0:35Speaker 1: Welcome to the deep dive everyone, thanks for having me.
- 0:37Speaker 2: And yeah, it really is the ultimate illusion. I mean,
- 0:40Speaker 2: when you think about.
- 0:40Speaker 1: It, it really is. Today we are pulling apart the
- 0:43Speaker 1: physics engines that build those illusions. We're getting into the
- 0:46Speaker 1: actual mechanics, the mathematical cheat codes, and the literal computer
- 0:51Speaker 1: science battles.
- 0:52Speaker 2: Oh, it's absolutely a battle.
- 0:54Speaker 1: Right, the battles that translate these raw equations into that
- 0:57Speaker 1: feeling of weight and reality on your Yeah. Because we
- 1:01Speaker 1: expect things to behave in a very specific way, don't we.
- 1:04Speaker 2: We do. We are so deeply conditioned by reality. You
- 1:07Speaker 2: know when a virtual object mimics that behavior even closely enough,
- 1:12Speaker 2: our brains just they don't question it.
- 1:15Speaker 1: We just accept the reality of the scene exactly.
- 1:17Speaker 2: We just accept it and move on. Though calling it
- 1:19Speaker 2: reality might actually be a bit of a stretch.
- 1:22Speaker 1: What do you mean by that?
- 1:23Speaker 2: Well, simulating physics isn't really about perfectly mapping the actual
- 1:27Speaker 2: universe into a computer. I mean it's mostly smoke, mirrors
- 1:31Speaker 2: and bending the laws.
- 1:32Speaker 1: Of physics just to trick the human eye.
- 1:34Speaker 2: Yeah, to trick the eye, and crucially, to save computational power.
- 1:38Speaker 1: Okay, I love that. So before we get into the
- 1:41Speaker 1: heavy math, we probably need to draw a line between
- 1:45Speaker 1: what the human artists do and what the computer does.
- 1:47Speaker 2: Right, Yeah, that's a good place to start. We are
- 1:50Speaker 2: specifically looking at what's called secondary animation here.
- 1:53Speaker 1: Not the core character acting.
- 1:55Speaker 2: Right right. Primary animation that's the performance. It's the highly
- 1:59Speaker 2: skilled artistic work, the emotion, the subtle facial expressions.
- 2:03Speaker 1: The deliberate pacing of how a character walks exactly.
- 2:06Speaker 2: But secondary animation is the physical fallout of those actions.
- 2:09Speaker 1: Okay, So like hair blowing in the wind, yeah, or.
- 2:12Speaker 2: A cape reacting when a hero jumps, or explosion debris
- 2:16Speaker 2: settling on the ground. It's the environment reacting organically.
- 2:19Speaker 1: Gotcha. It makes me think of like a movie set.
- 2:23Speaker 1: The primary animation is the lead actor pouring their heart
- 2:26Speaker 1: out on screen, right, and the secondary animation is like
- 2:30Speaker 1: the wind machine and the rain tower in the background,
- 2:33Speaker 1: making the scene actually believable.
- 2:35Speaker 2: That is a perfect analogy. And to generate all that
- 2:38Speaker 2: wind and rain, you know, animators don't painstakingly draw every
- 2:42Speaker 2: single piece of debris frame by frame anymore. That would
- 2:44Speaker 2: take forever, it would, so they rely on dynamic simulation.
- 2:48Speaker 1: Which the textbook notes is distinct from discrete event simulation. Right, Yeah,
- 2:53Speaker 1: because if I'm simulating, say a factory assembly line, or
- 2:56Speaker 1: I don't know, an elevator schedule, I really just care
- 2:59Speaker 1: about things arrive, right. The schedule is just a series
- 3:02Speaker 1: of discrete events. Yes, But with this, with dynamic simulation,
- 3:06Speaker 1: we're tracking the continuous evolving momentum of an object in
- 3:10Speaker 1: three D space. But wait, hold on, if it's a
- 3:13Speaker 1: dynamic simulation, how strictly do we actually have to follow
- 3:18Speaker 1: the real rules of physics in these virtual worlds?
- 3:22Speaker 2: Yeah?
- 3:22Speaker 1: Like do I have to obey Newton flawlessly?
- 3:25Speaker 2: Well, what's fascinating here is not if it ruins the shot. Really, yeah,
- 3:29Speaker 2: I mean the physics engine is ultimately subservient to the
- 3:32Speaker 2: art direction. Animators reinvent physical laws all the time.
- 3:35Speaker 1: Oh that makes sense.
- 3:36Speaker 2: Think of the classic wildly Cuyote gag from the old cartoons.
- 3:40Speaker 1: Oh yeah, Or he runs off a cliff, right.
- 3:42Speaker 2: He runs off the cliff, hovers in the air for
- 3:44Speaker 2: like three full seconds to look at the camera and panic.
- 3:47Speaker 1: And then he plummets. So the physics engine just what
- 3:50Speaker 1: takes a coffee break pretty much.
- 3:52Speaker 2: But consider what happens when he actually does fall. An
- 3:55Speaker 2: animator might program his mass or the gravity acting on
- 3:59Speaker 2: him to be completely different from reality.
- 4:01Speaker 1: Oh so he accelerates twice as fast just to catch
- 4:04Speaker 1: up on the comedic timing exactly.
- 4:06Speaker 2: Pure accurate physics would completely ruin the joke there. So
- 4:09Speaker 2: the physics engine is just a tool to serve the art.
- 4:11Speaker 2: The physical laws are entirely malleable.
- 4:14Speaker 1: Okay, that's wild. But let's say we do want that continuous,
- 4:18Speaker 1: highly realistic movement like a bouncing ball. Sure we have
- 4:22Speaker 1: to use Newton's second law, right, f equals ma force
- 4:26Speaker 1: equals mass times acceleration.
- 4:28Speaker 2: Yep. That's the engine of the simulation. You calculate the
- 4:31Speaker 2: forces to find acceleration, integrate that to get velocity, and
- 4:35Speaker 2: integrate velocity to get the position.
- 4:37Speaker 1: But here's the thing. Computers can't actually process continuous time.
- 4:41Speaker 1: I mean they process discrete binary data. Right.
- 4:44Speaker 2: That is the fundamental bottleneck of all simulation. They have
- 4:46Speaker 2: to calculate in chunks.
- 4:48Speaker 1: Right.
- 4:48Speaker 2: We call it the timestep. We essentially tell the processor
- 4:51Speaker 2: to freeze time, assess all the forces acting on the ball,
- 4:55Speaker 2: calculate its current velocity, jump forward by a specific.
- 4:58Speaker 1: Chunk of time one full second.
- 5:01Speaker 2: Yeah, exactly one second, and then place the ball in
- 5:03Speaker 2: its new position.
- 5:04Speaker 1: Yeah.
- 5:05Speaker 2: This method is called oiler integration.
- 5:07Speaker 1: Wait, hold on it. If we just freeze time, assume
- 5:09Speaker 1: the velocity stays constant, and jump forward a full second,
- 5:12Speaker 1: isn't the ball gonna end up in the wrong place?
- 5:14Speaker 1: Because if it's falling, gravity's pulling it the entire second.
- 5:18Speaker 1: It's speeding up that whole time, not just at the
- 5:20Speaker 1: end of the jump.
- 5:21Speaker 2: You've just identified the fatal flaw of basic oiler integration.
- 5:25Speaker 2: No I did, Yeah, because the computer only updates the
- 5:28Speaker 2: velocity at the end of that timestep. Your virtual ball
- 5:31Speaker 2: will perpetually lag behind where a real world ball would be.
- 5:35Speaker 1: Oh wow.
- 5:36Speaker 2: It assumes a constant velocity during the whole duration of
- 5:40Speaker 2: the jump, so it constantly undershoots the correct position.
- 5:43Speaker 1: Mate. It's like, okay, it's like driving down a highway,
- 5:47Speaker 1: but you're only allowed to open your eyes once every
- 5:49Speaker 1: ten second.
- 5:50Speaker 2: That's exactly what it's like.
- 5:51Speaker 1: You have to guess where you are down the road
- 5:54Speaker 1: based on the exact speed you are going the moment
- 5:56Speaker 1: you close your eyes, and you're completely ignoring the fact
- 5:59Speaker 1: that your foot was pressing the gas pedal the whole time.
- 6:02Speaker 1: You're blind.
- 6:02Speaker 2: A perfect analogy. So how do you think we fix
- 6:06Speaker 2: the undershoot?
- 6:07Speaker 1: Well? Do I just open my eyes more often? Like
- 6:09Speaker 1: shrink the timestep down to a tenth of a second
- 6:12Speaker 1: or I don't know, one hundredth of a second.
- 6:14Speaker 2: You can. Shrinking the timestep dramatically reduces the error, but
- 6:19Speaker 2: there is a brutal trade off.
- 6:21Speaker 1: The computer has to work harder, much harder.
- 6:23Speaker 2: Every time you cut the time step in half, you
- 6:25Speaker 2: essentially double the computational load on the machine.
- 6:28Speaker 1: Yikes.
- 6:28Speaker 2: Yeah, shrink it too much and your fast paced video
- 6:32Speaker 2: game slows to like one frame a minute, the processor
- 6:35Speaker 2: will literally choke on the math.
- 6:37Speaker 1: Okay, so we can't just brute force it with smaller
- 6:40Speaker 1: chunks of time. What do we do?
- 6:42Speaker 2: We have to use better math. Instead of just taking
- 6:45Speaker 2: the velocity at the start of the time step, we
- 6:46Speaker 2: can use algorithms that calculate the average velocity over the
- 6:50Speaker 2: duration of the step. Oh I see for scenarios with
- 6:52Speaker 2: constant acceleration. This completely eliminates the lag without increasing the
- 6:57Speaker 2: processor load at all. How you do the math is
- 7:00Speaker 2: just as important as the math itself.
- 7:01Speaker 1: It's super clever, it is, but.
- 7:03Speaker 2: You also have to be meticulous that your math is
- 7:05Speaker 2: speaking the same language.
- 7:07Speaker 1: Wait, are you talking about keeping the unit straight like
- 7:10Speaker 1: the Mars orbiter.
- 7:11Speaker 2: I am. Indeed, you can have the most elegant integration
- 7:14Speaker 2: algorithm in the world, but if your variables are misaligned,
- 7:17Speaker 2: disaster strikes.
- 7:19Speaker 1: Yeah. For anyone who doesn't know the Mars Climate orbiter.
- 7:21Speaker 1: In nineteen ninety nine, it literally burned up in the
- 7:24Speaker 1: Martian atmosphere, a total tragedy, and it was because one
- 7:27Speaker 1: engineering team programmed their physics simulation using metric newtons of
- 7:31Speaker 1: force and another team used English pounds.
- 7:34Speaker 2: Yep, the math itself worked flawlessly, but the mismatched units
- 7:40Speaker 2: destroyed a multi million dollar spacecraft.
- 7:43Speaker 1: Just a spectacular, incredibly expensive reminder to always check your
- 7:47Speaker 1: variables exactly. Okay, so let's assume our math is airtight. Right,
- 7:50Speaker 1: we have a gravity engine running smoothly. Sounds good, but
- 7:53Speaker 1: I'm realizing a massive problem here. If we're just calculating
- 7:56Speaker 1: raw gravity, my virtual bowling ball and a virtual feather
- 8:02Speaker 1: are going to hit the ground at the exact same time.
- 8:04Speaker 2: Right, because pure gravity is independent of mass.
- 8:07Speaker 1: Yeah, Visually, that's going to look completely ridiculous to a player.
- 8:11Speaker 2: It breaks the illusion immediately. To make a pure gravity
- 8:14Speaker 2: simulation look real to you, the viewer, we have to
- 8:17Speaker 2: add what isn't actually there air?
- 8:20Speaker 1: Oh, drag. We have to simulate the atmosphere pushing back
- 8:24Speaker 1: against the object as it falls.
- 8:26Speaker 2: Exactly. Air resistance acts in the direct opposite direction of
- 8:29Speaker 2: the object's motion, and importantly, the magnitude of that resistance
- 8:34Speaker 2: increases the faster the object goes.
- 8:36Speaker 1: Okay, makes sense.
- 8:37Speaker 2: Animators use a user tunable drag constant. We'll call it
- 8:40Speaker 2: df PO define how aerodynamic an object is.
- 8:43Speaker 1: So a low D means the object is sleek and
- 8:45Speaker 1: slices through the air.
- 8:47Speaker 2: You got it, And a high D means it's bulky
- 8:49Speaker 2: or rough and really catches the wind.
- 8:52Speaker 1: So as the virtual ball drops and accelerates, the upward
- 8:56Speaker 1: push of the air, resistance just gets stronger and stronger.
- 8:59Speaker 2: Until you have the c artical balancing point, which is
- 9:01Speaker 2: terminal velocity.
- 9:02Speaker 1: Right, This is the.
- 9:03Speaker 2: Exact mathematical moment where the upward force of drag perfectly
- 9:07Speaker 2: balances out the downward pull of gravity. The net acceleration.
- 9:11Speaker 1: Drops to zero, so the object stops speeding up exactly.
- 9:14Speaker 2: It just continues to fall at a constant, steady rate
- 9:16Speaker 2: instead of continuously accelerating.
- 9:19Speaker 1: Okay, that totally fixes the falling aspect. But what about wind?
- 9:22Speaker 1: Do we have to build an entirely separate physics system
- 9:25Speaker 1: to simulate wind blowing things around?
- 9:27Speaker 2: Not at all? And this is actually one of the
- 9:29Speaker 2: most elegant shortcuts in all of simulation. Oh really, Yeah,
- 9:34Speaker 2: wind is calculated using the exact same drag equation we
- 9:37Speaker 2: just talked about. How the only difference is that instead
- 9:41Speaker 2: of using the object's absolute velocity through the world, the
- 9:45Speaker 2: engine uses the relative velocity of the object compared to
- 9:48Speaker 2: the velocity of the wind.
- 9:50Speaker 1: Wait, wait, wait, here's where it gets really interesting. So mathematically,
- 9:54Speaker 1: a stationary leaf getting blasted by a fifty mile per
- 9:56Speaker 1: hour windstorm that's treated identic to a leaf being fired
- 10:01Speaker 1: at fifty miles per hour through completely dead, still air.
- 10:06Speaker 1: The math doesn't care who is doing the moving.
- 10:09Speaker 2: The math only sees the difference in speed. It does
- 10:11Speaker 2: not care at all. And if we connect this to
- 10:13Speaker 2: the bigger picture. From a creative standpoint, this gives animators
- 10:16Speaker 2: an immense amount.
- 10:17Speaker 1: Of control because they can use wind to direct a
- 10:19Speaker 1: scene precisely.
- 10:20Speaker 2: They don't have to just let gravity do all the
- 10:22Speaker 2: dull work pulling particles straight down. They can inject invisible
- 10:26Speaker 2: wind forces to physically push sparks or snow or debrithe
- 10:30Speaker 2: exactly where they want them for the best visual impact.
- 10:32Speaker 1: That is so cool. Okay, so we're falling, we've got drag,
- 10:35Speaker 1: we're being blown by the wind. But eventually this virtual
- 10:38Speaker 1: ball is going to hit the virtual ground.
- 10:39Speaker 2: It has to land sometime.
- 10:41Speaker 1: Right, So how does the computer actually know when a
- 10:44Speaker 1: hit happens without breaking the illusion? Because in reality, collisions
- 10:49Speaker 1: take time, materials compress, energy transfers.
- 10:53Speaker 2: Yeah, real collisions are continuous, dynamic events. Like think of
- 10:57Speaker 2: a high speed camera capturing a golf physically compressing against
- 11:01Speaker 2: a clubhead.
- 11:02Speaker 1: Right, it flattens out.
- 11:04Speaker 2: It does, But in an animation simulation, calculating that atomic
- 11:08Speaker 2: level deformation of materials is impossibly expensive computationally, So we
- 11:13Speaker 2: cheat again. We cheat. We treat collisions as instantaneous events
- 11:17Speaker 2: to save time, and we divide them into three distinct
- 11:20Speaker 2: algorithmic phases detection, determination, and response.
- 11:24Speaker 1: Okay, so detection is did it hit? Determination is exactly
- 11:28Speaker 1: when and where did it hit? And response is what
- 11:31Speaker 1: happens next exactly.
- 11:32Speaker 2: Let's look at detection first. The engine constantly calculates something
- 11:35Speaker 2: called the plane.
- 11:36Speaker 1: Equation, which is what exactly.
- 11:38Speaker 2: It tracks the mathematical distance from the center of our
- 11:41Speaker 2: falling ball to the surface of the floor. As long
- 11:44Speaker 2: as the result is a positive number, the ball is
- 11:46Speaker 2: safely up in the air.
- 11:48Speaker 1: Boait. Because we're moving in discrete chunks of time, those
- 11:51Speaker 1: timesteps we were just talking about, the ball doesn't smoothly
- 11:55Speaker 1: approach zero.
- 11:55Speaker 2: Distance, right, Ah, you're ahead of me.
- 11:57Speaker 1: Well, it might be like five units above the floor
- 12:00Speaker 1: at timestep one, and then after jumping forward it's negative
- 12:04Speaker 1: two units below the floor at timestep two, It literally
- 12:07Speaker 1: passed through the floor between frames.
- 12:09Speaker 2: And that negative distance is exactly what triggers the collision detection.
- 12:13Speaker 2: The engine goes aha, an impact occurred during that last timestep.
- 12:18Speaker 1: But it can't just leave the ball underground, right.
- 12:20Speaker 2: And it can't just push it back up to the
- 12:22Speaker 2: surface either. It needs determination the headache of fractional timesteps, because.
- 12:28Speaker 1: If it just bums it up, the bounce will look completely.
- 12:30Speaker 2: Wrong exactly, so the engine actually has to hit the
- 12:33Speaker 2: rewind button. The algorithm calculates the exact fraction of the
- 12:37Speaker 2: timestep where the ball's distance to the floor was perfectly zero.
- 12:40Speaker 2: It moves the ball to that specific point in space
- 12:43Speaker 2: and time stops. The simulation calculates the new trajectory, and
- 12:47Speaker 2: then restarts the clock.
- 12:48Speaker 1: Okay, this explains so much. You know those classic video
- 12:51Speaker 1: game glitches where a character occasionally just walks straight through
- 12:55Speaker 1: a solid wall.
- 12:55Speaker 2: Oh, yes, I know them.
- 12:57Speaker 1: Well, is this because their speed was so high and
- 13:00Speaker 1: the timestep was so big that they were in front
- 13:03Speaker 1: of the wall in frame one and completely behind it
- 13:06Speaker 1: in frame two. Like the engine didn't check the math
- 13:09Speaker 1: fast enough, so they just teleported.
- 13:10Speaker 2: You nailed it. That is a phenomenon officially called tunneling.
- 13:15Speaker 2: If the timestep is too large and the object is
- 13:17Speaker 2: moving fast enough, the simulation entirely misses the event.
- 13:20Speaker 1: Man. That sounds like a nightmare to code around.
- 13:22Speaker 2: Oh, it gets so much worse. Imagine a ball ricocheting
- 13:25Speaker 2: inside a small box in a single large timestep. That
- 13:29Speaker 2: really fast moving ball might mathematically pass through multiple different
- 13:34Speaker 2: walls at once.
- 13:35Speaker 1: Oh jeez.
- 13:36Speaker 2: Yeah, the engine can't just trigger a response for the
- 13:39Speaker 2: first collision it happens to process in its list. It
- 13:42Speaker 2: has to test every potential collision, figure out which one
- 13:45Speaker 2: happened first in time, execute that one, and throw out
- 13:48Speaker 2: the rest because.
- 13:49Speaker 1: That first impact changes the ball's direction entirely, so the
- 13:53Speaker 1: other wall calculations become completely irrelevant. Exactly the amount of
- 13:57Speaker 1: background math happening before I even see the name next
- 14:00Speaker 1: frame of a game is staggering.
- 14:03Speaker 2: It really is.
- 14:03Speaker 1: Okay, So the engine successfully rewinds time, it finds the
- 14:07Speaker 1: exact microsecuative impact. We're on the floor. Now we need
- 14:10Speaker 1: the response phase. How do we mathematically distinguish a bouncing
- 14:15Speaker 1: basketball from like a sliding block of wood?
- 14:18Speaker 2: We decompose the collision response into two orthogonal components. You
- 14:22Speaker 2: have the normal direction, which is perpendicular to the floor.
- 14:25Speaker 2: That's the bounce. Okay, and you have the tangential direction,
- 14:28Speaker 2: which is parallel to the floor.
- 14:29Speaker 1: That's the slide.
- 14:30Speaker 2: Let's look at the bounce first. This is governed by
- 14:33Speaker 2: a material's elasticity, technically called the coefficient of restitution.
- 14:37Speaker 1: I love this part. This dictates the energy returned in
- 14:40Speaker 1: the bounce. All right.
- 14:41Speaker 2: Yes, a value of one means a perfect, completely elastic bounce.
- 14:47Speaker 2: The ball bounce is back up to the exact height
- 14:49Speaker 2: it dropped from. A value near zero means it's heavily inelastic,
- 14:53Speaker 2: resulting in a heavy thud.
- 14:55Speaker 1: Right. The textbook mentioned some real world numbers here, like
- 14:58Speaker 1: a tennis ball has a rest of two of aboutzer
- 15:00Speaker 1: point seventy five. Sounds about right, But what if we
- 15:03Speaker 1: set it above one point zero? The textbook actually reference
- 15:06Speaker 1: that nineteen sixty one movie The Absentminded Professor.
- 15:09Speaker 2: Oh.
- 15:09Speaker 1: Right, setting the math above one point zero is literally
- 15:12Speaker 1: how you create flubber. You're gaining energy out of nowhere
- 15:16Speaker 1: with every bounce.
- 15:16Speaker 2: It completely violates the laws of thermodynamics. Yes, but this
- 15:20Speaker 2: raises an important question It's crucial to remember that these
- 15:23Speaker 2: coefficients aren't just baked into the ball itself.
- 15:26Speaker 1: What do you mean?
- 15:27Speaker 2: They are a function of both colliding materials. It's not
- 15:29Speaker 2: just the ball, it's the floor. The engine has to
- 15:31Speaker 2: account for a rubber ball bouncing on concrete versus a
- 15:35Speaker 2: rubber ball bouncing on soft mud.
- 15:36Speaker 1: Oh right, that makes sense.
- 15:38Speaker 2: And that same principle applies to the tangential response friction.
- 15:43Speaker 2: This dictates the loss of speed as an object slides
- 15:46Speaker 2: across the floor. Now, you could use a simple friction
- 15:49Speaker 2: model that just cuts sliding speed by a flat percentage,
- 15:52Speaker 2: but it severely lacks realism because.
- 15:54Speaker 1: A flat percentage ignores weight. Right. If I try to
- 15:57Speaker 1: slide an empty cardboard box across a floor, it's easy,
- 16:00Speaker 1: but if I fill it with books, it's a.
- 16:02Speaker 2: Lot harder, Which is why robust physics engines use the
- 16:05Speaker 2: Kulam model of friction. This model introduces the normal force.
- 16:10Speaker 2: It accounts for the weight of the object pressing into
- 16:12Speaker 2: the floor. A heavier object mathematically creates more friction.
- 16:16Speaker 1: Okay, that makes perfect sense, And.
- 16:17Speaker 2: The material pairings here can be wild. If you rub
- 16:20Speaker 2: clean silver against clean silver, the friction coefficient can exceed
- 16:24Speaker 2: one point zero.
- 16:25Speaker 1: Wait, really silver on silver? Yeah.
- 16:27Speaker 2: At a microscopic level, the metals are essentially trying to
- 16:30Speaker 2: cold weld to each other. The engine has to account
- 16:33Speaker 2: for all of these realities.
- 16:34Speaker 1: Okay, so the simulation is running perfectly. We have Newton's laws,
- 16:38Speaker 1: air drag, flawless fractional collisions, realistic coolan friction. We drop
- 16:42Speaker 1: the ball, it bounces, the energy chips away, It gets
- 16:46Speaker 1: lower and lower. But when I actually look at this screen,
- 16:50Speaker 1: the ball does never perfectly stop. It just vibrates infinitely
- 16:53Speaker 1: on the floor. Why does the physics engine fail us
- 16:56Speaker 1: right at the finish line?
- 16:58Speaker 2: Ah, the ghost in the machine stop fighting physics and
- 17:01Speaker 2: started fighting computer architecture with go on. The infinite bounce
- 17:04Speaker 2: is a byproduct of numerical precision and round off errors.
- 17:08Speaker 2: Computers use binary floating point formats, right, but they physically
- 17:12Speaker 2: cannot represent all real numbers.
- 17:14Speaker 1: Perfectly because they have limited memory.
- 17:16Speaker 2: Exactly, so they have to round complex fractions. If a
- 17:19Speaker 2: ball loses twenty percent of its energy with every bounce,
- 17:23Speaker 2: you are continuously multiplying its velocity by point eight. Mathematically,
- 17:27Speaker 2: that number gets incredibly small, but it never actually reaches zero,
- 17:30Speaker 2: so it.
- 17:30Speaker 1: Just keeps calculating microscopic bounces, eating up processing power and
- 17:33Speaker 1: vibrating on screen.
- 17:34Speaker 2: Yes, so we introduce tolerances. We create a tiny mathematical
- 17:39Speaker 2: buffer zone. We tell the engine if the velocity drops
- 17:42Speaker 2: below point zero zero one.
- 17:43Speaker 1: Just call it zero to force it to sleep right.
- 17:46Speaker 2: But tolerances introduce a terrifying trap called incidence in transitivity.
- 17:50Speaker 1: Ooh boy, what is that?
- 17:52Speaker 2: Let me give you the textbook example. Imagine we have
- 17:55Speaker 2: three values. A is one point five, B is one
- 17:58Speaker 2: point seven, and C is two point oh and let's
- 18:01Speaker 2: say our tolerance buffer is point four. If two numbers
- 18:04Speaker 2: are within point four of each other, the engine considers
- 18:07Speaker 2: them perfectly equal.
- 18:08Speaker 1: Okay, let me walk through this. If I compare A
- 18:11Speaker 1: and B one point five and one point seven, they
- 18:13Speaker 1: are only point two apart, so they're inside the point
- 18:15Speaker 1: four buffer. The computer says A equals B.
- 18:18Speaker 2: Now compare B and C.
- 18:20Speaker 1: One point seven and two point zero. They're point three apart,
- 18:23Speaker 1: still inside the buffer, so B equal C.
- 18:25Speaker 2: But what happens when the engine compares A and C.
- 18:27Speaker 1: C Wait one point five and two point zero. That's
- 18:30Speaker 1: point five apart. That's outside the tolerance buffer. So the
- 18:32Speaker 1: computer says A does not equal.
- 18:34Speaker 2: C, even though it just mathematically proved that A equals
- 18:36Speaker 2: B and B equal c.
- 18:37Speaker 1: Oh Man, That breaks basic logic. It's exactly like a
- 18:41Speaker 1: game of telephone. Yes, small acceptable errors pass from person
- 18:44Speaker 1: to person, but by the end of the line, the
- 18:46Speaker 1: final message makes no sense and breaks the entire simulation.
- 18:49Speaker 2: This is where simulation stops being pure physics and becomes
- 18:52Speaker 2: computer science. You are constantly battling the physical limitations of
- 18:55Speaker 2: the machine itself.
- 18:56Speaker 1: So how do you actually put the ball to sleep?
- 18:58Speaker 2: You need a strict resting. The velocity must be near zero,
- 19:03Speaker 2: it must be touching a plane, and the forces must
- 19:06Speaker 2: be pushing into the plane unable to overcome static friction.
- 19:10Speaker 2: Only then can it finally rest.
- 19:12Speaker 1: This is a staggering amount of invisible architecture. We've gone
- 19:15Speaker 1: from high level animation concepts to slicing time into chunks
- 19:20Speaker 1: with Newton, to adding air resistance, detecting precise fractional collisions,
- 19:25Speaker 1: faking friction.
- 19:27Speaker 2: And finally wrestling the computer's own memory limits just to
- 19:30Speaker 2: force a virtual ball to go to sleep.
- 19:33Speaker 1: So to all of you listening, the next time you
- 19:35Speaker 1: see an animated character knock a glass off a table,
- 19:37Speaker 1: you'll know that behind that simple visual is a frantic,
- 19:40Speaker 1: microscopic war of plane equations, floating point round offs, and
- 19:43Speaker 1: relative velocities.
- 19:45Speaker 2: And consider this one final thought from the textbook. Yeah,
- 19:47Speaker 2: we know these virtual models are heavily simplified, ignoring atomic
- 19:51Speaker 2: level details to save computation.
- 19:53Speaker 1: Right.
- 19:54Speaker 2: Well, if our virtual worlds are just broad phase simulations,
- 19:57Speaker 2: filtering out the underlying chaos because it's too much to calculate,
- 20:01Speaker 2: it makes you wonder if our own physical universe has
- 20:03Speaker 2: an ultimate tolerance buffer at the quantum scale, rounding off
- 20:07Speaker 2: the math where things get too small to matter.
- 20:09Speaker 1: Oh wow, okay, that is a thought that will keep
- 20:12Speaker 1: me staring at the ceiling tonight. Are we just running
- 20:15Speaker 1: in a universe with a very small timestep? Thank you
- 20:18Speaker 1: so much for taking this deep dive with us. To
- 20:20Speaker 1: everyone listening, keep questioning those invisible rules, whether they govern
- 20:24Speaker 1: your screens or the world right outside your window.