Modifiable Isosurface with Materials

This is an extension of the Isosurface Demo @pspeed wrote a few years back. This demo allows you to edit the terrain directly using brushes of various shapes, save the chunks and change the materials.

It is currently a WIP. I intend to use this in a game I am developing, and will commit any changes/fixes necessary in order to make it a “fully working” demo.

You may do with it as you wish. I care not.

TODO List

  • When using brushes to add terrain, negative sides of the shape are displaying the incorrect material.
  • When using brushes to remove terrain, positive sides are showing the material selected.
  • Provide a better way of saving chunks than just serializing the density array to persist the materials.
  • Add collision support.

MAPPED KEYS:

  • TAB - Enable / Disable Cursor (to use the GUI)
  • WASD - Move Camera
  • Q / Z - Elevate / Lower Camera
  • LMB - Place Terrain
  • RMB - Remove Terrain

To enable chunk saving, change the following boolean in Main.class

public static boolean SAVE_CHUNKS = false;

If you want to reduce the render distance, edit the corresponding field in:

com.jayfella.terrain.config.VideoConfig
// ...
this.renderDistance = 10;

If you change the seed in Main.class and have chunk saving on - don’t forget to delete the savegames directory.

5 Likes

Hmmmm…Am I supposed to be seeing this:

Hah. Certainly not. I put a video in the OP of what it should look like. I’ve never run it on another PC before. Ill commit some changes over the weekend.

@jayfella, does this support generating from heightmap?

No. It’s based on a 3D noise generator that is pretty nifty in how it deals with 3D noise to represent a world. The one used is taken from GPU Gems.

You could treat the noise however you like. So you could treat the Y as a value of 2D noise and multiply it by a height. Traditional 2D heightmap style. But you don’t get overhangs or caves. You could perturb (smudge) the noise to simulate overhangs, and add caves as a second noise mask.

It’s entirely up to you how you deal with the noise, really, but it’s 3D.

1 Like

Any tips on updating collision meshes?
And maybe dynamically updated collision meshes? :stuck_out_tongue_winking_eye:

This is available on the JME store now.

For collision - you can sample the density field and use the normals and noise weight to determine how much to “push back” and in which direction. That’s probably a very light weight way to go about it.

For me, though, I’d rather use a physics engine. Creating the meshes using a smaller grid system works fine. Then just pass them to bullet. Just rebuild the meshes when they change. It’s far quicker than figuring out how to collapse it. And it will be a new mesh anyway. You can’t update a buffer if its size changes. Building a new mesh pretty much does the same thing in the end, with the benefit of simplicity.

I made a lighting system that uses cellular automata, too. The same way mine craft does it.

3 Likes