The Buoyancy Problem in Video Games

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] buoyancy the mysterious force that decides whether or not something floats in real life Bowen sees the upward force that acts on an object in a fluid the more of an object is submerged in a liquid the more buoyant force is applied but what if we wanted to make objects floating a game engine just like they do in reality how do we know how much volume an object has and how much of it is submerged well this is a problem that game developers have been struggling with for years but fear not because in this video we're going to explore how to simulate buoyancy in a game engine using simple physics principles buoyancy in real life operates under a simple formula called Archimedes principle which states that the upward buoyant force on an object is equal to the fluid density multiplied by the acceleration due to gravity multiplied by the volume of the objects submerged so if we drop the ball into a glass of water the ball would fall into the water and have its full buoyant force applied since a hundred percent of its volume is submerged but as it reaches the surface and some of the ball's volume left the water the volume that is submerged would go down resulting in the Boeing Force decreasing until the ball reaches equilibrium with the force of gravity and thus settling it on the surface of water this seems very simple in concept but if we look at some games we can see that the buoyancy behaves in a very unrealistic way in Skyrim items either float to the surface or sink right to the bottom there is no in between and when they do float to the surface it is very unrealistic [Music] in Minecraft everything flows the same and in a game like sons of the forest they don't even bother why is that well the problem arises from the fact that all these games use physics engines which all operate with the same physics principles as reality which means that in order to make objects float naturally you need to use Archimedes principle but there is one major issue with that water in video games isn't simulating an actual fluid water in almost all video games is simply a plane with a Shader applied to it to make it seem like it's water but in reality it's all just smoke and mirrors there simply isn't enough processing power to simulate water as an actual fluid in order to illustrate ways to solve this issue we're going to be using Unreal Engine 5. Unreal Engine 5 has no built-in buoyancy so we have to create it ourselves from scratch here we have some items for testing and for the sake of Simplicity we're going to be assuming that this volume is water in an actual game there will be a plane on top of this volume to render the water's surface as described before so can't we just be lazy and remove volume submerged from Archimedes principle maybe that would work well this is what happens when you don't take volume submers into account as soon as the item enters the water the force is instantly applied because the water thinks the entire object is submerged when it's actually just barely entered this is obviously not going to work so we will need to actually figure out a way to calculate the volume of the item and how much of that volume is submerged in the liquid there are a few ways you can approximate the volume of a model in a game engine such as voxelization which is essentially filling a model's empty space with tiny cubes so that we can get an approximation of its volume or tetrahedralization which is the same thing but with pyramids but making every item into a voxel is extremely expensive so let's just generate a box around each object instead [Music] in order to generate an accurate bounding box around each item we need to understand how models work in video games in video games polygons and vertices are used to create 3D objects polygons are flat two-dimensional shapes that are used to build up 3D objects they are used in video game models to create the surfaces of objects that players can interact with vertices on the other hand are points in 3D space where edges of polygons meet they're used to define the shape and structure of 3D objects each vertex has a set of coordinates X Y and Z that Define its position in a 3D space we can access the vertices of a model through something called the vertex buffer which we can then use to find Each corner of a box around an object after we have our box we can then use the equation for the volume of a cuboid to get the approximate volume of our object so now that we have our volume we need a way to figure out how to calculate how much of the volume is submerged for this we can use something called the Monte Carlo method the Monte Carlo method is a mathematical technique used to solve many complex Problems by using random simulations a method involves using random numbers to simulate an experiment or process that is difficult to analyze mathematically for example if you wanted to know the probability of winning a game of chance you could simulate the game many times using random numbers and record the results [Music] we can use the Monte Carlo method to generate something called a point Cloud inside of our box a point cloud is a collection of points in a three-dimensional space where each point represents a specific location in that space we can then check how many of these points are in the water volume and how many points are out to get a ratio of volume submerged we then multiply the entire object's volume by the ratio of objects submerged to get the volume of the object submerged as you can see this works and this is actually very similar to how it works in Skyrim but this is still not very realistic this is because the buoyant force is always applied to the center of the object and in real life buoyancy forces only acting on the center of volume that is currently submerged not the entire object in order to fix this we need to get the average position of all points under the water and apply the force to that location instead now we are getting somewhere the object settles on the surface of the water naturally but they both still seem very bouncy and it doesn't look quite right we can fix this by telling Unreal Engine a little bit more about the density of each object which in turn will change both of their masses now our items have completely Dynamic buoyancy and we can add as many items as we want to this and the system will always work you could of course make this solution better by improving the accuracy of the point Cloud generation but this method is simple and it works now that you have this knowledge what are you going to do with it probably nothing but I hope you found it interesting regardless if you want to see more videos like this remember to like comment subscribe dislike it if you dislike it and I'll see you in the next one foreign [Music]
Info
Channel: Luke Elrod
Views: 736
Rating: undefined out of 5
Keywords: Informational, interesting, entertaining, technology, physics, video games, game engines, science
Id: nyjT873E23k
Channel Id: undefined
Length: 7min 33sec (453 seconds)
Published: Sun Apr 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.