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.
5 // Persistence Of Vision raytracer sample file.
6 // Updated: Feb-2013 for 3.7
12 global_settings { assumed_gamma 1.3 }
28 #
default {finish {ambient 0}}
29 #
declare RS
= seed(464786);
30 //----------------------------------------
31 #
declare CamLoc
= < 5, 10,-10>;
34 right x*image_width
/image_height
// keep proportions with any aspect ratio
39 light_source {<-20, 30, -30>*3 color White
*1.5}
40 light_source {CamLoc
color rgb 0.3}
41 //----------------------------------------
45 function
{y - f_snoise3d
(x/7, 0, z/2)*0.5}
48 contained_by
{box {<-100,-3,-100>, < 100, 1, 100>}}
51 pigment {color rgb < 1, 0.9, 0.65>}
52 normal {granite bump_size 0.1 scale 0.01}
56 color rgb <.518, .339, .138>
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>]
86 #
declare RockColors
= array
[5]
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>,
95 #
declare CtrlPtrn
= function
{pattern
{bozo scale < 7, 1, 2>}}
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
102 function
{f_r
(x, y, z) - 1 + f_noise3d
(x, y, z)*0.5}
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
108 scale 0.03 + pow(rand(RS
),2)*0.35
110 pigment {Rand_Array_Item
(RockColors
, RS
)*RRand
(0.1, 1, RS
)}
111 normal {granite bump_size 0.5 scale 0.01}
119 #macro MakeSpineBunch
(Pt
, Dir
, Jitter
, Len
, BaseRad
, Num
)
122 #local NewDir
= vnormalize(Dir
+ Jitter
*(< rand(RS
), rand(RS
), rand(RS
)>*2 - 1));
123 cone {Pt
, BaseRad
, Pt
+ NewDir
*Len
, 0}
127 #macro MakeSpineRows
(Body
, Stretch
, AltJitter
, Ridges
, Bunches
, Spines
, SpineJitter
, SpineLen
, SpineRad
)
129 #local AltDelta
= 180/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
;
137 #
declare Pt
= trace
(Body
, Orig
,-Orig
, PtNorm
);
138 MakeSpineBunch
(Pt
, PtNorm
, SpineJitter
, SpineLen
, SpineRad
, Spines
)
146 #
declare sinw
= function
(x) {(sin(x) + 1)/2}
148 #
declare Ridges
= 40;
149 #
declare RidgeDepth
= 0.075;
151 #
declare cactus1Body
=
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
)
159 contained_by
{sphere {< 0, 0, 0>, 3.1}}
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]
167 frequency Ridges
sine_wave
169 normal {dents 0.1 poly_wave
2 scale < 1, 0.15, 1>}
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>}}
183 #
declare Ridges
= 32;
184 #
declare RidgeDepth
= 0.1;
185 #
declare cactus2Body
=
189 f_r
(x, y*0.35, z) - 1 - sqrt(x*x + z*z)*0.2
190 - (sinw
(atan2(x, z)*Ridges
)*RidgeDepth
)
194 contained_by
{sphere {< 0, 0, 0>, 3.1}}
196 pigment {color rgb < 0.3, 0.65, 0.4>}
197 normal {bozo 0.1 scale < 1, 0.15, 1>}
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>}}
212 #
declare Ridges
= 75;
213 #
declare RidgeDepth
= 0.05;
214 #
declare cactus3Body
=
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
)
223 contained_by
{sphere {< 0, 0, 0>, 3.1}}
225 pigment {color rgb < 0.1, 0.5, 0.25>}
226 normal {bozo 0.1 scale 0.15}
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>}}
238 object {Cactus1
translate < 3, 0,-3>}
240 object {Cactus3
translate <-2, 0,-3.5>}
242 //----------------------------------------