#version 3.8; global_settings {assumed_gamma 1} #include "functions.inc" camera { location <0, 0, -10> look_at 0 right x*image_width/image_height } sky_sphere {pigment {rgb 1}} light_source {<5, 15, -30> color rgb 1} // start and end of smoothstep function // set both to same value (0-1) to get cells pattern // Start = 0, End = 1 gives as close as this can get to f_noise3d() #declare Start = 0.1; #declare End = 0.9; #declare Turbulence = 0.325; #declare Scale = 0.25; // smoothstep function #declare K = function (t1, t2, T) {max (0, min(1, (T-t1)/(t2-t1) ) )} #declare Smoothstep = function (t1, t2, T) {pow (K(t1, t2, T), 2) * (3-2*K(t1, t2, T))} // mod function that plays nice when crossing 0 #declare Mod = function (T) {select (T, 1-mod (abs(T), 1), mod (abs(T), 1) )} // smooth step function //#declare N = function (NN) {floor (NN-0.5) + Smoothstep (Start, End, abs(Mod(NN-0.5)-0.5) )} #declare N = function (NN) {floor (NN) + Smoothstep (Start, End, Mod(NN) )} #declare Noise = pigment { function {f_noise3d(x, y, z)} turbulence Turbulence } #declare StepNoise = pigment { function {f_noise3d (N(x), N(y), N(z))} turbulence Turbulence } #declare Cells = pigment { function {f_noise3d (floor(x), floor(y), floor(z))} turbulence Turbulence } // graph functions #declare Line = 0.02; #for (X, -5, 5) cylinder {, Line pigment {rgb x/2}} #end cylinder {<0, -5, 0>, <0, 5, 0> Line+0.001 pigment {rgb x}} cylinder {<-10, 0, 0>, <10, 0, 0> Line pigment {rgb z}} #for (X, -5, 5, 0.005) // regular noise #local Y = f_noise3d (X, 0, 0)*2; sphere { Line pigment {rgb 1}} // cells #local Y = f_noise3d (floor(X), 0, 0)*2; sphere { Line pigment {rgb (x+y)/2}} // step noise #local Y = N(X); sphere { Line+0.001 pigment {rgb <0, 1, 0>}} #local Y = f_noise3d(N(X), 0, 0)*2; sphere { Line pigment {rgb <1, 0, 1>}} #end box {<-6, -5, 0> <-2, 5, 0.1> texture {pigment {Noise} scale Scale} } sphere {<-4, -3, 0> 1.5 texture {Noise scale Scale}} box {<-2, -5, 0> <2, 5, 0.1> texture {pigment {StepNoise} scale Scale} } sphere {<0, -3, 0> 1.5 texture {StepNoise scale Scale}} box {<2, -5, 0> <6, 5, 0.1> texture {pigment {Cells} scale Scale} } sphere {<4, -3, 0> 1.5 texture {pigment {Cells} scale Scale}}