Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Smooth terrain using 2D noise
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=23&t=683
Page 1 of 1

Author:  elkiwy [ Thu Oct 13, 2016 9:09 am ]
Post subject:  Smooth terrain using 2D noise

Hello,
It's me again :roll:

I was trying to generate volumes through code, and I made it through creating a colored cubes island like this:

Image

But now I would like to try convert it to a terrain so it could be smooth and nice.
The problem is that I can't wrap my head around the concept of the MaterialSet weight and I only find in the imported packages examples that uses 3D simplex noise to make it smooth... As soon as I try to convert that 3D noise generation to a 2D one I get something like this (ignore all the warning, those are for another thing :oops: ) :

Image

What should I do to smooth it nicely like the 3D noise ones?

Thanks for the support <3

EDIT: To clarify further, now the "smoothing" is basically drawing 45° planes between cubes... I was aiming to get different smooth curves like the ones in the examples with 3D noise

Author:  David Williams [ Thu Oct 13, 2016 7:42 pm ]
Post subject:  Re: Smooth terrain using 2D noise

As part of Cubiquity's ProcessVDB tool I actually wrote a heightmap converter, and was amazed at just how difficult it was. Converting a heightmap to a smooth volume seemed trivial but I spent a long time thinking about it.

Firstly, forget about different materials for now and just use one. That way you only have to think in terms of a single density per voxel. Now the problem is that you have height at each point and a voxel is either above or below it - this is a binary decision which means you end up setting each voxel to be either solid or empty.

As I recall, I tried instead setting the density of the voxel relative to the distance between the voxel and the top of the column. I then scaled it by some factor(s) which I found by trial-and-error. You can see the code here:

https://bitbucket.org/volumesoffun/cubi ... ap.cpp-135

I think you can ignore this part of the code (it's just stuff for materials?):

Code:
if (materialSet.data > 135)
{
   materialSet.data <<= 8;
}


though I'm a little hazy to be honest. Most usefully, I found it was helpful to scale the image down from a higher-resolution version of the heightmap. You might be able to avoid this, because your procedural data is effectively infinite resolution anyway. Also I had to start with ints, where as you will be starting with floats which should be easier.

To be honest, this was one of the problems which made me realise just how difficult and unintuitive density fields were, and why I decided to just focus on tiny cubes for Cubiquity 2!

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/