1// This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. 2// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a 3// letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. 4 5// Persistence Of Vision raytracer sample file. 6// Updated: Feb-2013 for 3.7 7// 8// -w320 -h240 9// -w800 -h600 +a0.3 10 11#version 3.7; 12global_settings { assumed_gamma 1.3 } 13 14#include "stdinc.inc" 15#include "arrays.inc" 16 17 18 19sky_sphere { 20 pigment {gradient y 21 color_map { 22 [0 color Blue*0.6] 23 [1 color White] 24 } 25 } 26} 27 28#default {finish {ambient 0}} 29#declare RS = seed(464786); 30//---------------------------------------- 31#declare CamLoc = < 5, 10,-10>; 32camera { 33 location CamLoc 34 right x*image_width/image_height // keep proportions with any aspect ratio 35 angle 45 36 look_at <0, 0, 0> 37} 38 39light_source {<-20, 30, -30>*3 color White*1.5} 40light_source {CamLoc color rgb 0.3} 41//---------------------------------------- 42 43#declare Ground = 44isosurface { 45 function {y - f_snoise3d(x/7, 0, z/2)*0.5} 46 threshold 0 47 max_gradient 1.1 48 contained_by {box {<-100,-3,-100>, < 100, 1, 100>}} 49 50/* texture { 51 pigment {color rgb < 1, 0.9, 0.65>} 52 normal {granite bump_size 0.1 scale 0.01} 53 }*/ 54 texture{ 55 pigment{ 56 color rgb <.518, .339, .138> 57 } 58 normal{ 59 bumps 5 60 scale 0.05 61 } 62 finish{ 63 specular .3 64 roughness .8 65 } 66 } 67 68 texture{ 69 pigment{ 70 wrinkles 71 scale 0.05 72 color_map{ 73 [0.0 color rgbt <1, .847, .644, 0>] 74 [0.2 color rgbt <.658, .456, .270, 1>] 75 [0.4 color rgbt <.270, .191, .067, .25>] 76 [0.6 color rgbt <.947, .723, .468, 0>] 77 [0.8 color rgbt <.356, .250, .047, 1>] 78 [1.0 color rgbt <.171, .136, .1, 1>] 79 } 80 } 81 82 } 83} 84object {Ground} 85 86#declare RockColors = array[5] 87{ 88 color rgb < 0.5, 0.4, 0.35>, 89 color rgb < 0.4, 0.5, 0.4>, 90 color rgb < 0.8, 0.75, 0.65>, 91 color rgb 0.8, 92 color rgb 0.5 93} 94 95#declare CtrlPtrn = function {pattern {bozo scale < 7, 1, 2>}} 96#declare L = 0; 97#while(L < 750) 98 #declare Pt = trace(Ground, < rand(RS)*25 - 15, 10, rand(RS)*25 - 10>, -y); 99 #if(rand(RS) > CtrlPtrn(Pt.x, Pt.y, Pt.z)) 100// sphere {o, 0.03 + pow(rand(RS), 2)*0.15 101 isosurface { 102 function {f_r(x, y, z) - 1 + f_noise3d(x, y, z)*0.5} 103 threshold 0 104 contained_by {sphere {o, 1}} 105 #if(rand(RS) < 0.5) scale VRand_In_Box(< 1, 0.9, 1>, < 2, 1, 3>, RS) #end 106 rotate y*rand(RS)*360 107 translate -y*0.35 108 scale 0.03 + pow(rand(RS),2)*0.35 109 texture { 110 pigment {Rand_Array_Item(RockColors, RS)*RRand(0.1, 1, RS)} 111 normal {granite bump_size 0.5 scale 0.01} 112 } 113 translate Pt 114 } 115 #declare L = L + 1; 116 #end 117#end 118 119#macro MakeSpineBunch(Pt, Dir, Jitter, Len, BaseRad, Num) 120 #local L = 0; 121 #while(L < Num) 122 #local NewDir = vnormalize(Dir + Jitter*(< rand(RS), rand(RS), rand(RS)>*2 - 1)); 123 cone {Pt, BaseRad, Pt + NewDir*Len, 0} 124 #local L = L + 1; 125 #end 126#end 127#macro MakeSpineRows(Body, Stretch, AltJitter, Ridges, Bunches, Spines, SpineJitter, SpineLen, SpineRad) 128 #declare J = 0; 129 #local AltDelta = 180/Bunches; 130 union { 131 #while(J < Ridges) 132 #declare K = 0; 133 #while(K < Bunches) 134 #declare Orig = vrotate(-y*50, x*(K + rand(RS)*AltJitter)*AltDelta); 135 #declare Orig = vrotate(Orig, y*(360*J/Ridges + 360/(Ridges*4)))*Stretch; 136 #declare PtNorm = y; 137 #declare Pt = trace(Body, Orig,-Orig, PtNorm); 138 MakeSpineBunch(Pt, PtNorm, SpineJitter, SpineLen, SpineRad, Spines) 139 #declare K = K + 1; 140 #end 141 #declare J = J + 1; 142 #end 143 } 144#end 145 146#declare sinw = function (x) {(sin(x) + 1)/2} 147 148#declare Ridges = 40; 149#declare RidgeDepth = 0.075; 150 151#declare cactus1Body = 152isosurface { 153 function {sqrt(x*x + pow(y - sqrt((x*x/4) + (z*z/4))*1.5, 2) + z*z) - 1 - 154 (sin(atan2(x, z)*Ridges)*0.5*RidgeDepth) 155 } 156 threshold 0 157 max_gradient 5 158 159 contained_by {sphere {< 0, 0, 0>, 3.1}} 160 texture { 161 pigment {radial 162 color_map { 163 [0.00 color rgb < 0.3, 0.65, 0.4>*0.8] 164 [0.65 color rgb < 0.3, 0.65, 0.4>*0.8] 165 [1.00 color rgb < 0.3, 0.65, 0.4>*0.2] 166 } 167 frequency Ridges sine_wave 168 } 169 normal {dents 0.1 poly_wave 2 scale < 1, 0.15, 1>} 170 } 171} 172#declare Cactus1 = 173union { 174 object {cactus1Body} 175 object {MakeSpineRows(cactus1Body, 1, 0.2, Ridges, 24, 3, 0.5, 1, 0.01) 176 texture {pigment {color rgb < 0.98, 0.98, 0.5>}} 177 } 178 scale < 1, 0.75, 1> 179 translate y*0.35 180} 181 182 183#declare Ridges = 32; 184#declare RidgeDepth = 0.1; 185#declare cactus2Body = 186 187isosurface { 188 function { 189 f_r(x, y*0.35, z) - 1 - sqrt(x*x + z*z)*0.2 190 - (sinw(atan2(x, z)*Ridges)*RidgeDepth) 191 } 192 threshold 0 193 max_gradient 5 194 contained_by {sphere {< 0, 0, 0>, 3.1}} 195 texture { 196 pigment {color rgb < 0.3, 0.65, 0.4>} 197 normal {bozo 0.1 scale < 1, 0.15, 1>} 198 } 199} 200 201#declare Cactus2 = 202union { 203 object {cactus2Body} 204 object {MakeSpineRows(cactus2Body, < 1, 3, 1>, 1, Ridges, 64, 3, 1, 0.5, 0.01) 205 texture {pigment {color rgb < 0.98, 0.98, 0.5>}} 206 } 207 translate y*2 208} 209 210 211 212#declare Ridges = 75; 213#declare RidgeDepth = 0.05; 214#declare cactus3Body = 215 216isosurface { 217 function { 218 sqrt(x*x + pow((y/1.5),2) + z*z) - 1 - sqrt(x*x + z*z)*0.2 219 - (sinw(atan2(x, z)*Ridges)*RidgeDepth) 220 } 221 threshold 0 222 max_gradient 5 223 contained_by {sphere {< 0, 0, 0>, 3.1}} 224 texture { 225 pigment {color rgb < 0.1, 0.5, 0.25>} 226 normal {bozo 0.1 scale 0.15} 227 } 228} 229#declare Cactus3 = 230union { 231 object {cactus3Body} 232 object {MakeSpineRows(cactus3Body, < 1, 1.5, 1>, 1, Ridges, 24, 5, 1, 0.35, 0.01) 233 texture {pigment {color rgb < 0.98, 0.98, 0.85>}} 234 } 235 translate y*1.25 236} 237 238object {Cactus1 translate < 3, 0,-3>} 239object {Cactus2} 240object {Cactus3 translate <-2, 0,-3.5>} 241 242//---------------------------------------- 243