3D Olsen Noise

3D Olsen Noise


Java Source Code: http://godsnotwheregodsnot.blogspot.com/2015/02/olsen-noise-2d-java-code-updated.html


So I made a newer noise algorithm beyond fractal diamond squared noise. I previously removed the limitations on size and the memory issues, allowing proper paging.

Now I got rid of the diamond squared bit, and the artifacts it produces. As well as allowed the algorithm to be quickly expanded into multiple dimensions.

http://www.gfycat.com/SecondhandDimpledGull

Basically rather than double the size, apply the diamond elements, apply the square elements.

You upsample increasing the size of each pixel to 2x in each dimension. Add noise to every pixel reducing it depending on the iteration iteration (my current reduction is Noise / (iteration + 1)). Apply a box blur (though any blur would work).  And its all done in my infinite field scoping scheme, wherein the base case is pure randomness, and each later case is recursively scoped.

Update 9/22: The Java Source Code and Demo have Noise reduction of +bit@iteration. So Iteration 7 flags the 7th bit, so +128 or +0. 6th bit, +64, +0. -- Doing this allows it to skip normalization as the end result will *always* fall between 255 & 0.

No more artifacts, and the algorithm would quickly implement on GPU hardware, doesnt change at N-dimensions.

Update: While the algorithm was actually made with GPU hardware in mind, and would very quickly implement exactly as diamond squared would not. -- It does change at N-dimensions. In that more of the roughness flows into the additional dimensions. Rather than average over 9 somewhat random pixels at a given level it will be the average of 27. Each level meaning it will be much closer to the mean. You might still get desired effects by reducing the number of iterations. 

Ive also confirmed that a 2d slice of 3d noise is the same as a 2d bit of noise. Since its fractal this should be expected. I dont think you can, do things like turbulence bump-mapping like with simplex noise, because the absolute value of Olsen Noise, is pretty much again just fractal noise. Fractals are fun like that.

Update: Its this fact about Olsen Noise that initially lead to my false confirmation of the noise. If you normalize it, regardless whether its excessively smooth or not. It will look like identical noise. If you want to go that route, then the noise wont change at 2d to 3d. Because the narrower ranged 3d noise will be zoomed in on, and give the same appearance of roughness.

And since the noise is scoping, you can map it out in N-dimensions. So not only could you make it go around corners without hard edges, like this paper is so happy with itself for doing. You simply go from wanting a 1x500x500 slice at 0,0 to wanting a 500x1x500 slice at 0,500. It would by definition be seamless.



And unlike other noise algorithms its fast and *simple*. In fact, its a number of simplifications of diamond-squared noise all rolled up in an infinite package (which is itself a simplified bit).


One can reduce the iterations with distance, far enough away from you, you have 4 block sections, which are the same as the close bits but dropping an iteration.

Update: Reducing the iteration in the demo can be seen as sampling at 2x2 the value. Its basically the same cost. You dont need to do the full size and reduce, you can just request the area scaled down by 2x2 at 1 fewer iterations.

Sampled at 1:5
http://www.gfycat.com/ImpressionableShinyFlounder

Sampled at 1:20
http://www.gfycat.com/KnobbyBlissfulFairyfly


Wrapping:

If it were mission critical to have the noise wrap like old diamond squared noise, this could be done if the deterministic hash of the x,y,z...,iteration was taken as the x MOD wrap, y MOD wrap, z MOD wrap with regard to iteration  you would likely need to scope the wrapping. So if you wanted it to wrap with iterations equal to 7 (all my given examples here are iterations of 7), and wrap at 100. Your deterministic random hash function to give you random offsets modded at 100. Then at the call for iteration 6 have your deterministic random hash function give you random offsets looped at 51. And this would be independent of your requested set of pixels. It would do the recursive scope to make sure the the random variables given sync up. But, you could do awesome things like wrap at a specific (and different, x, y, and z). So you could make noise that wraps horizontally at 1000 but vertically at 50. In theory. I havent managed to get it to work and there could be some kind of desyncing that happens when one iteration is looping at 16 and the next at 31. It might require a multiple of 2 for the wrapping. Or even a 2^(max iteration) wrapping or nothing at all.

Wrapping is left to later. Ill settle for better than everything else.

Smoothness:
Smoothness is mostly a product of the number of iterations along with the drop off rate of the randomness.

http://www.gfycat.com/LateRevolvingBlackmamba

Update: Algorithm Outline.
It occurs to me that I should have provided some pseudocode.


getTerrain(x0,y0,x1,y1,iterations) {
    if (iterations == 0) return maxtrixOf(random numbers);
    map = getTerrain(floor(x0/2) - 1, floor(y0/2) - 1, ceiling(x1/2), ceiling(y1/2), iterations-1);
    make a newmap twice as large.
    upsample map into newmap
    apply blur to newmap.
    add deterministic random offset to all values in newmap (decreasing each iterator)
    return requested area from within newmap. (This is typically newmap from [1,(n-1)] [1,(n-1])
}

Update: Actual Java Source Code.
http://godsnotwheregodsnot.blogspot.com/2014/09/olsen-noise-source-code-in-java.html


Update: Demo.
http://tatarize.nfshost.com/OlsenNoise.htm

Update: 3D Noise Source Code, With Commenting.
http://pastebin.com/WJVyDxDR

Comments

Popular posts from this blog

Dr Folder 2 3 0 1 Key ✅ Latest✅ Download⬇

3 Ways to install VirtualBox in Ubuntu

3 Ways to remove PPAs on Ubuntu