David Williams wrote:
Firstly, you are converting a heightmap to a volume by writing only 0 or 255, and then smoothing the result. But are you smoothing the whole volume? Remember, you only actually need to smooth the parts of the volume which are near to the surface because you won't see the effect of smoothing the other parts. What's more, for groups of 27 voxels which are distant from the surface they are probably all 0 or all 255, so the averaging will not be changing the values anyway.
I already "only" go through all voxels that are in the valid y range (I save the highest and lowest y value while applying the heightmap). That makes sense as I do not apply the heightmap over the complete height of the terrain. I need some non-affected ground to be able to carve out caves and the likes in a next step. But you are right, there are of course more ways to improve this.
I'd rather do the smoothing while applying the height map, though, if that turns out to be faster and/or better applicable.
David Williams wrote:
Secondly I'd look into better ways of writing the correct data into the volume in the first place, to avoid the need for smoothing. I don't have an exact idea here, but rather than initially writing 0 or 255 you could instead check how far you are from the value in the heightmap and write values based on that. So if your current voxel is a long way below the heightmap value then write a large positive value, if it's a small distance above then write a small negative value, etc. Then run the extractor with the threshold set to zero. [...+Compression]
That would work? Well, I gotta try that one out.
Sounds pretty nice, actually.
David Williams wrote:
Also, is the use of heightmaps your final solution or just temporary thing? Because once you have converted it to a volume and done the blurring you can just save the volume to disk and give it to your users. No need to do the conversion each time (depending on your application...). Or if you are actually planning to use 3D Perlin noise then that is smooth anyway.
Nothing is a final solution here, I'm trying out various things to see which one turns out to be best for my project idea. I'm mostly looking out for flexibility and performance. The resulting look is not
that important at this point, as the final project will have much more in its graphics pipeline than just terrain.
I am definitely going for more deformed terrain with overhangs and caves.
Basically, there are 2 ways to achieve this:
1. Apply a heightmap, then deform the terrain. Probably with a lower resolution (like a 100x100x100 field for 400x400x400 terrain) 3D vector field that contains directions to move the voxels along.
Take a look at
this paper. I must say I don't fully understand what they are doing (as usual with scientific papers), but that is where I got the inspiration from.
2. Create the terrain directly from 3D noise. This would work, of course, but IMO would also be the most time consuming approach. If I can somehow achieve a good result with 1., I'd prefer that. I will probably try this out anyway.
In any case, I will apply things caves, lakes, etc. in steps that come after creating the "base terrain". Which is another reason why I'd prefer to take route 1.
Also, in a final solution, I will use Simplex Noise instead of Perlin noise, as the results are the same (improved, actually), but the algorithm is simply faster.
Thanks for your support, btw. It makes things much easier for me