Friday, May 12, 2017

Simple 3d Noise

Pseudo random number seeded by a point, 0-1.

Usage:


my_noise=  Coldnoise([x,y,z]);


function  Coldnoise(v) =
 let (
   xseed = round(rnd(1e8, -1e8, round(v.x * 1e6))),
   yseed = round(rnd(1e8, -1e8, xseed + round(v.y * 1e6))),
   zseed = round(rnd(1e8, -1e8, yseed + round(v.z * 1e6))),
   noise  =  (rnd(0, 1e8, zseed))%1)
 noise;

 function rnd(a = 1, b = 0, s = []) = 
  s == [] ? 
   (rands(min(a, b), max(   a, b), 1)[0]) 
  : 
   (rands(min(a, b), max(a, b), 1, s)[0])
  ; 




No comments:

Post a Comment