So lately I’ve been working on an editablemesh ocean, due to the per-vertex position, uv, normal, and color editing. Overall, editablemesh seems to have more potential for oceans and such than the more trendy (albeit easier to implement) skinned mesh thanks to said per-vertex editing.
Videos:
Regular ocean mesh with uv scrolling:
Underwater:
Regular ocean mesh with uv scrolling + depth-based coloring (this tanks performance by a nice 1-2ms):
The Ocean
I used about 6 gerstner waves to return a height value and applied it over time.
Not planning to use an FFT or any type of Navier-Stokes ocean (although there are a great many papers on them), as it would be too performance-heavy.
Used a PBR for water using high resolution, seamless normal (for wave detail) and albedo map (for surface foam).
Used uv scrolling to add a movement effect to the texture, thanks editablemesh!!!
Mesh stretches out really far into the horizon and used some fog and DoF effects to make it blend better. Downside of this is that mesh resolution is quite low so I can only resort to using bigger waves. I do plan on fixing this though, to provide high resolution mesh + extending to horizon, which I will expand on later below.
Haven’t tried any client-to-client replication yet, unfortunately. Not a top priority.
Performance:
Script is client-sided, usually takes ~2m or less on my laptop with no other applications open.
To gauge this, this was tested on the AMD Ryzen 5 7520U, which is a pretty low-end CPU considering it’s meant for battery-efficient laptops…
I added on option for vertex coloring which usually tanks the performance up to ~2-4ms, but it does provide some satisfying visuals.
Used a ton of optimization methods to do as little math as possible, such as frustum and distance culling, among others.
Future Improvements:
-
Parallelization: high priority, would increase performance significantly, especially if Roblox engineers release a bulk vertex position function
-
High-Res endless mesh: currently one huge mesh, but I plan to create a small one and efficiently duplicate it onto a grid without extra calculations thanks to Editable* becoming Objects -
Buoyancy: should be easy enough to create and replicate, just need to research the topic a bit more
-
Client-to-Client Replication: if I do end up completely releasing this, it’ll obviously need this as desynchronized waves don’t end up working right with server-handled buoys…
-
Modularization: I’ll probably end up releasing this if people want it or not, but making it customizable through variables will end up being quite difficult (won’t gatekeep, strictly against closed-sourced software).
Tell me what you guys think and thanks a lot if you did end up reading all this yap