// Create a bumpy surface by using procedural noise to generate a height ( // displacement in normal direction). // // Inputs: // is_moon whether we're looking at the moon or centre planet // s 3D position of seed for noise generation // Returns elevation adjust along normal (values between -0.1 and 0.1 are // reasonable. float bump_height( bool is_moon, vec3 s) { float b = +0.05*(0.5+0.5*smooth_heaviside(perlin_noise( 1.0*s),10)*2-1) +(0.5 + 0.44*float(!is_moon))*(0.5+0.5*smooth_heaviside(( +(0.6+0.14*float(is_moon))*perlin_noise( 2.0*s) +(0.2-0.04*float(is_moon))*perlin_noise( 4.0*s) +(0.2-0.1*float(is_moon))*perlin_noise( 8.0*s) -0.005*perlin_noise( 64.0*s) -0.001*perlin_noise( 128.0*s) ),8-float(is_moon)*-s.x*7)*2-1) +0.01*(0.5+0.5*smooth_heaviside(( +0.1*perlin_noise( 16.0*s) +0.8*perlin_noise( 32.0*s) +0.1*perlin_noise( 64.0*s) ),4)*2-1) -.5; return 0.06*b+0.07; }