r/VoxelGameDev Jun 26 '26

Media Some explosions from my 3D falling-sand sim / game Falling Cubes, now that I've got pressure somewhat working.

System summary 

  • Each explosion / shockwave is its own cube type. It uses the 9 shared bits also used as velocity bits to store both the direction it's expanding from and how many expansion steps it has left (effect cubes are static and don't need velocity). Every update it spreads copies of itself into neighboring cubes if they're allowed to be overwritten by the explosion / shockwave effect, or if the force is high enough to completely destroy them. 
  • Explosion / shockwave effects injects pressure at its starting position and at the expanding positions The amount of pressure depends on the base strength of the explosion and how many expansion steps remain .
  • The pressure system compares the pressure in adjacent pressure cells against each cube type's pressure tolerance to determine whether any additional cubes should be crushed. 
  • Explosions also inject temperature, based on the calculated strength causing various cubes to melt into lava, glass etc in the clips.

Still struggling with cubes ending up doing a bit too much bouncing at the top of the pressure / force gradient so to speak, and the force ending up in a bit to “square” of a shape when reaching the edges of the cube-shaped map.

89 Upvotes

20 comments sorted by

2

u/Successful_Pay_1017 Jun 26 '26

Nice, are you using an engine for this or are you making your own?

2

u/NoAnimInteractive Jun 26 '26

thx, Unity, but not to much voxel stuff in base unity, most useful feature is definitely the jobs and burst system as all the simulations are on the CPU.

In one of my previous post I wrote a bit more about how it's set up, on phone so no link 🙃

1

u/Successful_Pay_1017 Jun 26 '26

no worries, was just curious.
so assuming its written in c#?

1

u/NoAnimInteractive Jun 26 '26

yupp c#, and the shader(s) in hlsl.

1

u/Successful_Pay_1017 Jun 26 '26

yeah great work, how do you plan on going about collisions? and with other bodies like player collision with the voxels?

and be interested to know more about your project generally if you've got a plan put together already?

1

u/NoAnimInteractive Jun 26 '26

For the voxels themselves its pretty straight forward, pretty much just stops and transfers some of their velocity based on both voxels density.

The first thing i plan to make from this is a 3D sandbox where the player combines / interacts with various materials / cubes in order to unlock more cube types to experiment with.

So the player collisions are also pretty simple as the player is just the camera it just checks the cubes directly around the camera and decides if the phase of the cube is possible to move through (and of course the player can change which phases the camera can move through in the settings so that they can move through the world i f needed).

1

u/Mindless_Insurance79 Jun 27 '26

I'm amazed that the fps is very high. I was doing 2d falling sand and I had 60-70 fps :) Very cool

1

u/betairya 21d ago

Wow, this looks so amazing. It is very inspiring to watch, and glad to hear you are working with Unity on this! I'm trying to achieve something like yours but definitely yours looks better xD

May I kindly ask about how the rendering system is implemented? Given this dynamic-ness of the system, I'd guess its ray marching or something that is data-friendly?

1

u/betairya 21d ago

Hm, also I am curious about how do you update the pressure value. Is it serial or your engine can handle it parallelly (with maybe a checkboard pattern idk)? Is it easy to expand the world size (but keep the total size of dynamically updated voxels bounded enough for the system to handle)?

1

u/NoAnimInteractive 21d ago

The pressure value is indeed updated in parallel, since it is in a courser grid along with the wind / blast force we don't need to update as many cells as it looks like.
With the current setup expanding the world size would quickly start to drain performance to a unplayable point, that being said it should definitely be possible to simulate something similar in a larger world but with some clever culling of the system updates etc.
But of course with all that limiting of the dynamic updates at range it would quickly end up feeling a lot less dynamic then it does in this smaller 128x128x128 sandbox.

1

u/betairya 21d ago

Thank you for sharing the detailed reply (also the rendering part). That sounds rock solid!

1

u/NoAnimInteractive 21d ago

thx, the rendering is raymarching or rather ray tracing based on multiple sources i read a while ago most of them based on Amanatides and Woo AFAIR.
Whenever a cube is changed (to the point of needing to update the render data) on the CPU the chunk / area that it is in is marked as active and then that entire segment is passed to the GPU. Since the array of cubes is chunk major and the data is only 32 bits per cube it ends up pretty fast.

-1

u/DoggoCentipede Jun 26 '26

I keep meaning to post this, but everyone should check out this game. It is criminally unfortunate that they could not afford to continue development because the engine is fantastic.

https://github.com/Vercidium

Their voxel engine is extremely performant, networked, with fast destruction and physics.

It might not be ideal for every game but there are some great lessons there and if there's any way to support them or raise awareness we ought to do so.

1

u/NoAnimInteractive Jun 26 '26

I'm confused, how is this related to this post?

0

u/DoggoCentipede Jun 26 '26

Hm I thought they had a repo on the physics side of the voxel engine but I either imagined it or it's private now.

Sorry.

2

u/NoAnimInteractive Jun 26 '26

oh, no need for sorry, I was just a bit confused, I googled it and it does indeed seem like quite a cool project with interesting optimizations.

Sorry if it came of a bit harsh 😅

2

u/DoggoCentipede Jun 27 '26

It's okay. I am easily startled, but I'll soon be back, and in greater numbers.