Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use perlin.getValue() to generate 3D heightmaps in Libnoise?
    primarykey
    data
    text
    <p>I have been using the dotnet port of Libnoise to generate some heighmaps in XNA using the following code:</p> <pre><code>ImprovedPerlin perlin = new ImprovedPerlin(seed, NoiseQuality.Standard); FilterModule module = new SumFractal(); module.Frequency = 0.2f; module.OctaveCount = 6; module.Lacunarity = 2; module.Gain = 2; module.Offset = 1; module.SpectralExponent = 0.9f; module.Primitive3D = perlin; float bound = 10f; NoiseMapBuilderPlane builder = new NoiseMapBuilderPlane( 6.0f + mapX, 10.0f + mapX, 1.0f + mapZ, 5.0f + mapZ, true); //bound + mapx, (bound + mapX) * 2, bound, bound * 2, true); NoiseMap noiseMap = new NoiseMap(128, 128); builder.SetSize(128, 128); builder.SourceModule = module; builder.NoiseMap = noiseMap; builder.Build(); Graphics.Tools.Noise.Renderer.GradientColor gradient = Graphics.Tools.Noise.Renderer.GradientColor.GRAYSCALE; Color[] colorData = new Color[128 * 128]; texture = new Texture2D(AssetManager.graphicsDeviceManager.GraphicsDevice, 128, 128); for (int y = 0; y &lt; 128; ++y) { for (int x = 0; x &lt; 128; ++x) { byte color = gradient.GetColor(noiseMap.GetValue(x, y)).Green; } } texture.SetData&lt;Color&gt;(colorData); </code></pre> <p>This all works fine, even if I get different results in the provided libnoise sample that doesn't use XNA (I neeed to lower the frequancy to get the same result in XNA for some reason).</p> <p>Sadly there is no NoiseBuilder[3D] to generate a 3D variant of noise, so I have to build it myself using the perlin function. But even trying to generate 2D noise using perlin.getValue() seems to end up wrong;</p> <pre><code>float px = 0; float py = 0; for (int y = 0; y &lt; 128; ++y) { py += 0.1f; for (int x = 0; x &lt; 128; ++x) { px += 0.1f; int color = (int)((perlin.GetValue(px, py, 0) + 1) * 177.5f); } } texture.SetData &lt; Color &gt; (colorData); </code></pre> <p><img src="https://i.stack.imgur.com/nu3RY.png" alt="left = perlin.getValue(), right = mage 2 = NoiseMapBuilderPlane"></p> <p>I have no idea how to incorporate the SumFractal aswell, but that's a worry for later I guess.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload