// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 // Copyright 2003 by Tor Olav Kristensen // Email: t o r . o l a v . k [_A_T_] g m a i l . c o m // http://subcube.com // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #version 3.5; #include "functions.inc" // For f_noise3d() global_settings { ambient_light color rgb <1, 1, 1> } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #macro RotateXYZ_Function(Fn, RotXAngleFn, RotYAngleFn, RotZAngleFn) #local RotZFn = function(x, y, z, CosZ, SinZ) { Fn( x*CosZ -y*SinZ, x*SinZ +y*CosZ, z ) } #local RotYFn = function(x, y, z, CosY, SinY, AngleZ) { RotZFn( x*CosY +z*SinY, y, -x*SinY +z*CosY, cos(AngleZ), sin(AngleZ) ) } #local RotXFn = function(x, y, z, CosX, SinX, AngleY, AngleZ) { RotYFn( x, y*CosX -z*SinX, y*SinX +z*CosX, cos(AngleY), sin(AngleY), AngleZ ) } #local TempFn = function(x, y, z, AngleX, AngleY, AngleZ) { RotXFn( x, y, z, cos(AngleX), sin(AngleX), AngleY, AngleZ ) } function { TempFn( x, y, z, RotXAngleFn(x, y, z), RotYAngleFn(x, y, z), RotZAngleFn(x, y, z) ) } #end // macro RotateXYZ_Function // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare SquashFn = function(Fn, S) { select(S, -1, 1)*(1/(1 + exp(-abs(S)*Fn)) - 1) } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare Xspc = 4; #declare Yspc = 4; #declare Zspc = 4; #declare HalfXspc = Xspc/2; #declare HalfYspc = Yspc/2; #declare HalfZspc = Zspc/2; #declare XFn = function(x) { mod(x, Xspc) - select(x, -HalfXspc, 0, HalfXspc) } #declare YFn = function(y) { mod(y, Yspc) - select(y, -HalfYspc, 0, HalfYspc) } #declare ZFn = function(z) { mod(z, Zspc) - select(z, -HalfZspc, 0, HalfZspc) } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare E = 6; #declare AA = 0.2; #declare F = 10; #declare BB = 0.6; #declare XbarsFn = function { pow( pow(YFn(y), E) + pow(ZFn(z), E), 1/E) - AA } #declare YbarsFn = function { pow(pow(XFn(x), E) + pow(ZFn(z), E), 1/E) - AA } #declare ZbarsFn = function { pow(pow(XFn(x), E) + pow(YFn(y), E) , 1/E) - AA } #declare CubesFn = function { pow(pow(XFn(x), F) + pow(YFn(y), F) + pow(ZFn(z), F), 1/F) - BB } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare BlobStrength = 16; #declare GridFn = function { SquashFn(XbarsFn(x ,y ,z), BlobStrength) +SquashFn(YbarsFn(x ,y ,z), BlobStrength) +SquashFn(ZbarsFn(x ,y ,z), BlobStrength) +SquashFn(CubesFn(x ,y ,z), BlobStrength) } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare NoiseFn = function { 0.5 - f_noise3d(x, y, z) } #declare AgateFn = function { pattern { agate turbulence 0.4 omega 0.9 octaves 2 scale <1, 1, 1>/4 } } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare C = 0.2; // Frequency of rotation #declare D = pi/6; // Amount of rotation #declare XAngleFn = function { D*NoiseFn(C*(x + 50), C*y, C*z) } #declare YAngleFn = function { D*NoiseFn(C*x, C*(y + 50), C*z) } #declare ZAngleFn = function { D*NoiseFn(C*x, C*y, C*(z + 50)) } #declare TurbulatedGridFn = RotateXYZ_Function(GridFn, XAngleFn, YAngleFn, ZAngleFn) // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 #declare Xnr = 40; #declare Ynr = 40; #declare Znr = 40; #declare pCameraLocation = *<-1.0, 0.9, -1.3>*1.02; #declare pCameraLookAt = *<0.2, 1.2, -0.5>; #declare pMin = -*; #declare pMax = *; // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 isosurface { function { TurbulatedGridFn(x, y, z) + 0.025*AgateFn(x, y, z) } threshold -0.5 max_gradient 5 contained_by { box { pMin, pMax } } texture { pigment { function { AgateFn(x, y, z) } color_map { [ 0 rgb <0.40, 0.40, 0.41>*2.0 ] [ 1 rgb <0.47, 0.50, 0.43>*1.2 ] } } finish { ambient 0.1 diffuse 0.6 } } } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10 light_source { 10*<-3, 2, 2> color rgb <1.0, 1.0, 1.0>*1.7 fade_distance 40 fade_power 10 shadowless } #declare RR = seed(314); #declare Cnt = 0; #while (Cnt < 20) light_source { 25*(<1, 1, 1>/2 - ) + <8, 4, 8> color red 1 fade_distance 3 fade_power 5 } #declare Cnt = Cnt + 1; #end // while camera { location pCameraLocation look_at pCameraLookAt angle 90 } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 ======= 10