Tuesday, April 2, 2013

Fluid-Based game progress

Well, I've been working on the idea of a Minecraft-like game (infinite procedurally generated world, with resource gathering and building) but instead of semi-fixed Voxel-based, I want to use fixed-size particles in full Smoothed Particle Hydrodynamics simulation, including heat transmission.  The idea is to create a world where you can shatter a chunk of the rock off with a tool to pick up, or create a heat source large enough to melt the rock, and gather the liquid.

This is obviously a very difficult proposition for many reasons, but mostly speed, as well as the problem of getting a good simulation of melting/freezing, the papers I've found that mention it don't go into detail enough to implement. I've toyed with three versions of a simulator so far, but none of them are fast enough to do a full world with. And only one would support what I want to do right now, the slowest.

These are two screenshots of the original full simulation:

These shows two fluids, the pinker is denser and also more viscus and elastic. This simulation works nicely but is quite slow <250 particles runs at 4FPS as shown. It uses springs for the boundary conditions.

The next two are another version of the same simulation.  It does not use full SPH and simply uses springs to prevent penetration:

This one has the same parameters except the boundary conditions are different, they are still springs, but there seems to be a bug in my implementation where there is a new boundary that keeps forcing the particles down. This however is much faster with nearly 500 particles running at 5FPS, about double the original, but it would require more work and code to get melting/freezing/solids and thus would slow down the code probably to the same as the original.

All those above used LWJGL for rendering.

This last one is done with JME3 to render and it's built in JBullet library to do the physics, this has many drawbacks, density won't cause a fluid to float on another, and melting/freezing and solids built of particles become problematic.
Because it uses JME3 the particles->FPS isn't quite as obvious because it is showing 'objects' which is not the same thing.

This is one of the slowest projects I'm working on, because I keep putting it on the back-burner for other things that are more likely to be possible.  I'm thinking I should do it in C++ for speed, but I really prefer java.  I'll probably keep working with the original, or second one, just to get a tech demo, albeit slow, that works.


No comments:

Post a Comment