This is a continuation of my project on ocean simulation made with the Unreal game engine to implement buoyancy physics in order to get objects floating on an oceans surface.
The method for buoyancy simulation that I decided to use is also based on the method used for the Assassins Creed games. The method uses buoyancy spheres in order to create a representation of an object that the ocean can interact with.
In terms of my calculation for buoyancy I factor in the following variables. Ocean density, gravity, surface area, height of immersion, water drag, and the volume of the object. In terms of better understanding the forces that are being applied I created a debug for the buoyancy that shows the 3 primary forces of gravity, buoyancy, and water drag. I also created a box object and attached a buoyancy sphere to each one of its corners for use in testing. Below is an image of one of these boxes and the debug lines of force in perfect equilibrium.
In order to determine if a buoyancy sphere is in contact with the ocean I perform the same Gerstner wave calculation used to create the ocean in order determine the height of the ocean at a specific point. Once I have this height I can compare it to the position and radius of the buoyancy sphere to determine if it is submerged and the amount of it that is submerged.
The end result is very effective, with a method for calculating buoyancy that can provide a good approximation of its collision with the ocean and calculate the physics at a low cost. Below is a video of the final result, with a series of boxes floating on the ocean surface as i change the form of the ocean with the ocean manager.