Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using Unity, although this question is not really specific to that engine.

Im also using an asset from the store called Coherent Noise. It has some neat noise functionality built it.

I am using those functions to produce some noise values. I am getting a value between 0 and 1 (floats).

I have an array of blocks (for minecraft like voxel terrain) and I am confused on how to use this float value for terrain?

Do I do something like <= 0 == Solid block etc?

I am confused on how to use the floating values that the noise functions produce to use for height values of an array of say a height of 16.

share|improve this question
    
Are you generating 2d or 3d noise? –  Raven Dreamer Nov 18 '12 at 6:20
    
I am trying ti implement 3D. –  therealjohn Nov 18 '12 at 13:35
add comment

1 Answer 1

up vote 3 down vote accepted

If you're using the noise for height values (2D noise), then you multiply the float value by the maximum height of your world. This will give you a height value somewhere between 0 and the maximum height of your world.

If you're using the noise to determine if a voxel is solid or not (3D noise), you can do as you suggest and pick a threshold value that defines when the breaking point is between solid/air. Since your values are from 0 to 1 you'd want to pick some small value that's greater than zero, otherwise you won't be getting any empty voxels.

The second option is going to be harder to get right. You'll need to implement the noise generation in a controlled manner. i.e. you'll want to have voxels more likely to be solid at small y values and more likely to be air at large y vaules. If it's completely random you'll have land and ground so mixed up the landscape won't resemble landscape at all. See my answer here to learn more about implementing terrain using noise as a density function.

share|improve this answer
    
Awesome, thanks for explaining. I will check out the link to your other answer. I am seeing exactly what you are describing that my values are not quite right and my landscape is not resembling anything like landscape; its so mixed up (too random). –  therealjohn Nov 18 '12 at 13:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.