Water Physics and Buoyancy

A Deep Look at ROBLOX’s Buoyancy and Water Physics

Water Physics and BuoyancyBoats. Waterfalls and geysers. Swimming and diving. Flowing rivers and deep pools. With version 1.0 of ROBLOX’s buoyancy and water physics, carefully crafted and researched by our Physics Team, these things are not only possible, but also realistic. We’re featuring ROBLOX Physics Engineers Kevin He and Tyler Mullen today, as they explain the latest iteration of buoyancy (see the original here) and its implementation in ROBLOX.

Water is more than a texture in ROBLOX. It has its own unique properties and behaviors, all of which integrate into ROBLOX’s existing physics engine. Objects float on water surfaces, bob up and down with pressure changes and sink if they’re too dense. Water flows, pushing objects along its path, with user-defined directions and velocity. Players dive underwater and swim the depths or wade on the surface.

The physics of water are rooted in buoyancy – the tendency of a body to float or to rise when submerged in a fluid, according to the Merriam-Webster dictionary.

[do action=”youtube-iframe” videoid=”aK79zNvNSts”/] Water physics in action: A working water wheel in ROBLOX.

1Buoyancy is a simple concept, but challenging to simulate in a virtual world. We approached the challenge with a few goals in mind. At a high level, we focused on clean architecture so the behavior of objects and characters in water looks and feels like a natural extension of ROBLOX’s existing physics. This included integrating buoyancy into our standard contact pipeline. We actually consider a body of water a special physics object and apply buoyancy to floating objects via the contact (or collision) between them and the water. This way, the collision between water and floater, floater and floater, and floater and sunken objects are all simulated in a unified engine.

Our architecture also unifies all the forces – buoyancy, water viscosity (drag) force, water-flow force, gravity, contact forces and other external forces. The movement of a floating object is a net result of all these forces on a rigid body following Newtonian laws. That’s why you’ll see an underwater collision happening in the same, natural way it does on land.

[do action=”youtube-iframe” videoid=”_SeB7pDUwqw”/] This video demos player control in and out of water, under water and on floating objects.

2We also strived to implement buoyancy and water physics with a high level of detail and accuracy. We came up with a couple solutions based on the type of object we’re simulating.

Cubes and wedges in water

Think about dropping a cube into water. After gravity has submerged it in water, it’s likely going to tumble and re-orient itself as the water’s buoyancy forces it back to the surface. In ROBLOX, we efficiently and elegantly simulate that re-orientation by dividing the voxel cube into eight segments, each of which has its own positional data. By dividing up the force of buoyancy, voxel objects (cubes, wedges and corner wedges) orient themselves properly and respond to changes in force – a character standing on one corner, for example – with realism. We also apply water viscosity force against both linear and rotational velocity to dampen the motion and achieve a good, float-y feel.

Cubes oriented based on density

Spheres and cylinders in water

Now, think about dropping a ball (or sphere) into water. Because the smallest point of the ball enters the water first, it gradually decelerates until the buoyancy force shoots it back up. We don’t need to worry about how the ball re-orients itself, but we do need to know how much of the sphere is below water.

If x is the percentage of the sphere’s height that is under water, then the percentage of the sphere’s volume that is submerged is:

Equation of percentage of sphere's volume submerged

And the buoyancy is weight of object × percentage of volume submerged ÷ SPECIFIC GRAVITY.

Cylinders are the trickiest of all. When cylinders are floating straight up and down, they should act like cubes. When cylinders are floating completely horizontally, they should act more like spheres. The trick, for cylinders, is to blend the two approaches.

If x is the percentage of the horizontal cylinder that is underwater, then the percentage of the cylinder’s volume that is submerged is:

Equation of percentage of cylinder's volume submerged

Again, the buoyancy is weight of object × percentage of volume submerged ÷ SPECIFIC GRAVITY.

This blend of the two approaches allows cylinders to behave realistically in water.

3Our final goal was to allow a wide variety of practical applications through water and buoyancy. You’ve already seen how objects behave in water, but we’ve also developed swimming and diving states that let players jump in and out of water, and swim downward to explore the depths.  Users will be able to construct realistic boats for their games and set up water-based platforming courses. With flowing water, your landscapes and architecture will benefit from waterfalls, geysers, whirlpools and streams.

There’s a lot of new ground – or, should I say, water – to explore.

[do action=”youtube-iframe” videoid=”yiwSIS-mmLg”/] Buoyancy in action: Boating in ROBLOX.

About Kevin He

Technical Director of Physics and Distributed Simulation at ROBLOX. @GongfuTiger on Twitter.

485 thoughts on “A Deep Look at ROBLOX’s Buoyancy and Water Physics

  1. Paladinslayer

    I can’t wait for this feature. I hope it becomes available soon!

    Although it would be better if we were able to make a regular brick non-collide, then have the option to add buoyancy properties to it, so that it would act like a liquid. (…rather than making water like one of those terrain textures; it just wouldn’t go well with the good ‘ol regular bricks…)

  2. PieGirl

    This thing is barely decent, in my opinion. I still think the flow of the water is cool, but why does the person bounce? And the texture, don’t get me started on it. Remember: MY OPINION!!!

  3. Paul13379001

    A few questions;
    1. Will ROBLOXians be able to change the color/texture of the water? Like clear water, and then waters with decals?
    2.When will this come out?
    3.Will scripting be needed for the water currents? @Wave with the boats, &spinning currents, and waterfalls?
    4.Is this just a preview? Or is it just a test, and you guys are going to add in more things like splashing?

  4. crazymetro

    I think that this new water feature needs to have more like air bubbles! Like minecraft but not too like it so you dont offically copy it! You should be able to stay under water accorind to your age like if your 13 minutes or old like 20 seconds and if you have safe chat like 12 and under i think you should be able to stay under like 15 seconds! I think that will make the whole new water feature perfect and better!

  5. SuperSkateboy

    I’ve been hoping for this amazing update to come out for months, I absoloutly love it.

    1. FunkyFireMonkey73

      I think pirate games would be awesome with this!! But, can the water just be still? And it really needs to be transparent, 0.2 water, with a 0.2 texture

  6. beligerence

    what now?change the the game name to block craft?
    seriously guys.roblox is great the way it is.

  7. Codygreen3

    Now all you need is for the water to flow and have physics at the same time! That would be cool.

    1. Villi

      Then you could be able to add Texture Packs and Mods! Then change the games name to ROcraft! No, seriously, this is getting out of hand. ROBLOX was fine in 08. Bring us back there with easey C-framing and scripting. Not this new stuff that I’m never gonna have a use for.

  8. Electricpretzel0

    I Love it. But It needs a better Splashing Effect and should be Transparent instead of a wave decal.

  9. Roblot231

    This will change everything :D YAY! UPDATE! We can create realistic lava that is bursting out of a volcano and so much more :d

  10. Fablizer

    Very good job. We have needed this for so long. This will make games A LOT better, and even create more games. I would like to change the colour of the water though. And what about rain? I think that would be really cool too.

  11. undeadCobra139

    I think it would be really cool if you could adjust the viscosity, murkiness, texture, and color. With this we could create detailed oceans, lakes, and best of all, wee could create lava and volcanoes! >:D

    1. supersprayer

      i agree to but u should make the lava like water but accept it buruns and melts some bricks

  12. linklink999

    I had to agree to most of these. 1 of them I truly agree. Is that the water shouldn’t be one texture. The water should be like a transparent brick. So like if you wanted a hot spring which is clear. and if you want a murky lake yeah sure! and the water should also change colors/colours too! Like for the lake it would be green! Let us hope you include that and it won’t cause lag!

    1. colbyblox10

      If you want a diff color:
      1.take the texture and copy ONLY the code
      2.go to any hat and paste ONLY THE CODE on the hats id
      3.save the image as
      4.open it in some drawin program (i prefer GIMP2)
      5.edit it
      6.you have your own water now

  13. Sasuto10

    let us change the texture thin like we can when with normal blocks now. also the transperencey and color should be able to be changed.

    1. Evilpower321

      No, The roblox crew won’t not make this if it would lag.. By the way its just like the terrain

  14. asphaltdevil7

    Looks Awesome! you should maybe make some sort of way for your robloxian to swim! :)

  15. Syredan

    Wow, you guys are so rude! You asked for water months ago, and ROBLOX has been working on it for months now! Appreciate the fact that they are at least making some type of water, even if it isn’t perfect.
    Btw ROBLOX, I think this water addition would greatly improve roblox and give us more inspiration.

  16. Catinthebat

    Finally, a good update. I think it would be better if it was slightly transparent blue under water, like real water.

  17. Z007

    I agree with most people, that the physics are really cool, however, the texture is not. I suggest making properties for the texture, allowing slight transparency, etc.

    1. Silverstripe1

      I aggree with ZOO7.The water should be slightly tranparent to allow players to see under the water.

  18. GTMATN2

    Very true indeed i greatly look foward to this and agree with you KrazLorvikk i like this update here

  19. MrPhelps

    I can’t wait for this to come out. It looks so cool. I am gonna make a boating game with this feature when it comes out.

  20. TheWisest

    Great, all you need to do is add dynamic lighting, and roblox will be my new favorite sandbox game! :D

  21. BlueStatic

    This is awesome!!!!!!!! You should add a sailboat to the vehicles too! I can’t wait for the water to be realeased!

  22. Soultaker656

    I honestly don’t like this to much. Water should not be added if you ask me. It will mostlikly lag games if players use to much, and it should with agreement, have different textures. I know I alone can’t change your views. Just think of who you are doing this for. Six year olds. Older teens such as I don’t really anticipate somthing of such a dramatic change to Roblox. When you get down to the physics of it. It just won’t work.

  23. Pumerinade

    Different textures and the look, make it a “Part” [instead of Terrain tool (because they’re too big.)].

  24. Tigtogsss

    Make it submarine friendly…

    Like realistic ? Make it so it doesnt do thru submarines?

  25. Manny Rios

    I love it, boat rafting looks so fun! However, I agree with the portion of people who have their opinion on the texture. The water should be custom-texturable, and maybe the possibility of it being a classic resizable brick as well as terrain?

  26. Lord Bruce98553

    The water texture needs to improve and it should not be a terrain. It needs to be a seperate block. It’s roBLOX not roTERROX.

  27. 67high

    I like it but obviously it is isnt perfect but thats alright. And i dont like the look of it with the terrain but that can always be changed.

  28. KrazLorvikk

    I personally think this is a great feature and anxiously await its arrival. I do think, however, that there should be a variety of different water textures to use. For instance, a murky color if someone wants to make a swamp, or a transparent pale blue for a mountain spring, etc.

    1. Theclock1

      I agree. Now people can make better beaches,canyons(like the Grand Canyon,anyone?),and create real-life scenarios! We thank Roblox!

  29. flamethrower4567

    I think that the working sailboats would make “survive rafting to get to VIP!” games a lot more fun.

  30. Trent99

    You should make it so that for boats when water flows onto them it starts to slowly drag the boat down underwater

  31. Snazzell

    This is really unique and interesting, I am not fond of the texture, but it acts like real water!

  32. Wielded

    Well, I love the physics, but I do not like the look of it. Meaning which, change how it looks like, because it doesn’t look like water. Put it in a stamper tool, and make make it spread out if it doesn’t so ( I just watched the videos ). I love the concept of it, and it will be perfect for the a ROBLOXian to build a moat for their castle. This is just my opinion, but I strongly believe you should put this in ROBLOX.

  33. Gripie123

    Water? In ROBLOX? Yes; simply… Yes. But making it a terrain block will limit us greatly. Please understand that hardly any of us have been using the stamper stuff anywho, because it limits us.

  34. Darrellray

    cant wait for this be out with horrible boats i made for my ame and out with oldwater in with new be s fun to do this

  35. Dart219

    I honestly do not like the idea of making it a terrain type look. If it was a particle or individual part, it could be used more diversely and wouldnt have to have that texture. Otherwise, I do like the concept.

  36. bricks90

    I love this new feature in roblox.When you put boats in roblox it will finally sail smoolthly and such.So I wanted to know when does this feature come out?

  37. Don Mann

    id suggest the ability to have the water texture user defined, excpet it will probably work like all terrain, pre-defined textures set by roblox. what would be cool is properties in the terrain object that set all those textures. Also, are you still planning on particle based water?

    1. 6flyguy6

      Except putting an Invisble force of “air” or as what you are supposed to be referring to is WIND is not very possible due to you can’t see it. Though of there was a space-planet update so we’re not using a baseplate with a ball mesh with your air concept only used for breathing could be added would blow my mind with an advanced Gravity like that. Also a special Zero Gee Buoyancy in space would befuddle me.

  38. helloq

    This looks really cool! can’t wait to check it out! I can tell ROBLOX is trying to be a lot more like minecraft with the blocks even though I don’t play it.

  39. heyyouoverthere

    This is a wonderful idea, but I have one question, In the swimming,Jumping,Diving and Waterflow it looks as if the robloxian person is like a hollow log, at 0:17 the Robloxian bounces on water, is this a bug because this should be fixed

Comments are closed.