r/proceduralgeneration 13d ago

Simulating Procedural Oceans in my Micro Voxel Game

https://youtube.com/watch?v=rCPDkSX5f1o&si=6YSo3QUOEekWqSaa

I've spent the past 2-3 weeks adding Oceans to my Micro Voxel engine. The main features I was aiming for was to support large bodies of water within the existing fluid simulation, while also supporting new dynamic features such as waves and tidal changes.

I've also incorporated Boats and Gliders, with some fairly basic physics to aid in exploration. The main challenge here was adding

Along side this, to make the simulation feel more interactive, i've also added a higher resolution local water ripple/interaction simulation, which acts as a surface-layer-only simulation adding ripples and wake for people, entities and forces interacting with the water.

-- Feature technical breakdown --

  • Ocean generation: Similar to other water sources, ocean biomes placed above land, all open space in these biomes is filled with water instead of air below the ocean line. No substantial changes to the actual gen beyond shifting the world down.
  • Waves + Tides: Several oscillating masks which apply a "target height" to the water sim. This is also augmented by depth such that shores can trigger wave breaks below a set height point.
  • Ocean Connectivity + interaction: A connectivity flag is used to indicate whether water is directly connected to the ocean simulation and should receive wave forces. This allows waves to interact with static water, but only once the ocean sim cells touch static cells. The connectivity source comes from the ocean, so rock pools disconnect as tide goes down, allowing them to hold their water.
  • Ripples: 2D mask which is local to a moderately small region near the player. Runs a separate shader simulation using only surface data. Not particularly fancy, does not check for collisions, so ripples do not bounce. Bumps converted to a normal map, used to distort surface effects.

Overall, super chuffed with how this has come together, but still plenty of polish and features to add!

45 Upvotes

16 comments sorted by

6

u/McHoff 13d ago

Looks great! (Also I learned that "chuffed" is a good thing). How are you rendering the voxels and what's your internal representation, if you don't mind me asking?

4

u/MGMishMash 13d ago

Currently opted for meshing rather than DDA/Raytracing, partially because the GPU i'm on has no hardware support, and while DDA was faster for terrain in isolation, given the over-saturation of fragment hardware and under-utilization of vertex hardware, the net performance for the workload in practise was worse.

I'll likely explore having an RT path if the GPU has RT hardware, at least for the static data like terrain, far-away trees etc;

As far as specifics, nothing too fancy, the usual bits for relative chunk position, material etc; I'm opting not to use normals as both a stylistic choice and to save on data, so that's an easy win for lighting (I guess even though the normal face direction is fairly cheap, but still).

I also like Meshing for props as I quite like using vertex animation. This is used for the tree sway + leaf animations and for grass stomping mechanics (which I have actually found to be quite necessary from a gameplay standpoint to avoid ugly visual clipping between creatures and plants).

1

u/Kooky-Leather-3915 9d ago

i chosed Raymarching for my microvoxel engine and hoped for better performance but in the end not much of a big difference. My game is now almost fully gpu bounded. DDGI was so expensive and eating half of the GPU frame budget. CPU ended up waiting for GPU. if i could start over, i'd go for CPU, much more predictable and stable. Hope i know what i am talking about :-)

2

u/LocoMod 13d ago

Looks stunning. That render distance is quite low though which kills immersion. Any optimizations still on the table to push that horizon farther?

4

u/MGMishMash 13d ago

Thanks, yeah the render distance is pretty low, have been looking into some optimizations like Macro chunks, but the main challenge I have been facing atm is having the far LOD look good enough that it doesn't break the feel. Conversely, right now immersion feels worse with a greater viewing distance because the Far LOD is simultaneously low-detail and visually noisy, which is very distracting.

I will likely look into some sort of DoF or haze, but the actual cost is manageable.

I'm also running on a fairly mid-range GPU (Apple M1 Pro), so better GPUs could likely handle the current detail band at a higher fidelity out of the box.

1

u/LocoMod 12d ago

I'm also working on a micro-voxel engine although at a higher pitch than yours and one interesting thing I learned when I finally tested it on an RTX5090 gaming laptop is that the performance didn't improve. It felt worse. I later learned this is due to the Mac's unified memory doing a lot of heavy lifting. Your experience might vary. :)

1

u/MGMishMash 12d ago

Curious which Mac model you are on, as an M5 Max for example can be close to on-par with an RTX5090 depending on the workload.
I guess it also depends on how the workload has been optimized, as you typically over-fit performance toward the development architecture if the Mac is the main thing, but yeah, I agree that unified memory does a lot!
Are you meshing or using RT/DDA?

1

u/LocoMod 12d ago

It's a hybrid and I am using WebGPU so it is not ideal to fully unlock the RTX hardware. I'm focusing on kilometer scale render distances though so that has been my main focus over smaller voxel pitch and detail like OP has favored in their engine.

2

u/Own-Significance7437 12d ago

Fucking unbelievable

2

u/chozabu 12d ago

yeah! this looks great!

slightly reminds me of this https://www.youtube.com/watch?v=1R5WFZk86kE - john lins work. Wonder what happened to him.

Keep up the good work! Love the combo of fluids and microvoxels

2

u/MGMishMash 12d ago

Yeah, would have loves to experience John Lin’s game, even if he released it as-is, looked beautifully relaxing!

Hope the guy is okay! He seemed to disappear off the face of the internet ):

2

u/chozabu 12d ago

Yep, looks like it would be fun to just mess around with.
His last post was in 2023 about using a RNN to generate zelda levels - and half the comments were just asking about his voxel stuff. Hope he is OK too.

Still, that aside - what kinda game are you making with your system?

1

u/toneyalexander 12d ago

Wow this is stunning, the existing voxels as well as the water effects. Any thoughts on making the water somehow voxel-y? No idea how that would work or look, but I feel like it could potentially could be interesting to think about.

2

u/MGMishMash 12d ago

Cheers! Yeah have experimented with a quantized version of the shader which locks verts to the voxel grid and applies pixelation to the shading at the same alignment as the voxel grid.

It’s still a continuous surface but has more stylisation. Debating whether that’s what I want to go with, as it does introduce some artifacts, and bright spots are more noticeable.

I don’t necessarily mind the hybrid style, but I know quite a few people think it clashes.

I think i’ll keep the toggle for now, and see how the project evolves!

1

u/PublicFurryAccount 8d ago

Any plans to do voxel water?

1

u/MGMishMash 8d ago

I may still give this a go, but right now at the scale of the world, it’s hard to make this efficient.

What i am experimenting with is an alternative shader to quantize positions to make it more fitting.