File: landscape.pov

package info (click to toggle)
povray 1%3A3.7.0.10-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 147,232 kB
  • sloc: cpp: 845,011; ansic: 122,118; sh: 34,204; pascal: 6,420; asm: 3,355; ada: 1,681; makefile: 1,389; cs: 879; awk: 590; perl: 245; xml: 95
file content (404 lines) | stat: -rw-r--r-- 9,572 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
// This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a
// letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

// Persistence Of Vision Ray Tracer Scene Description File
// File: landscape.pov
// Desc: Use of 'trace' for placing objects on isosurfaces/heightfields
//       Furthermore showing the following techniques:
//          - use of piment functions for creatig isosurface terrain
//          - use function image type for heightfields
//          - slope pattern
//          - random variation of objects using rand() and macros
//          - nested #while loops for placing objects in a grid
//          - creation of simple trees using partly transparent textures
//
// Date: June 2001
// Auth: Christoph Hormann
//  Updated: 2013/02/15 for 3.7
//
// -w320 -h240
// -w512 -h384 +a0.3
// ------------------------------------------

#version 3.7;
global_settings { assumed_gamma 1.0 } 

#declare Test_Render=false;   // use simplified trees if true
#declare use_iso=false;       // use an isosurface object (HF with function image type otherwise)
#declare Viewpoint=1;

global_settings {
  assumed_gamma 1.0
  max_trace_level 25
  noise_generator 2  
}
//-------------------------------------------------------------------------
// This scene uses a non-standard camera set-up. 
// (See CAMERA in the included documentation for details.) 
// If you are new to POV-Ray, you might want to try a different demo scene.
//-------------------------------------------------------------------------
                
               
#if (Viewpoint=1)
  camera {
    //location    <3.7, -0.55, 0.3>    
    location    <3.0, 2.3, 0.3>
    direction   y
    sky         z
    up          z
    right       x*image_width/image_height // keep propotions with any aspect ratio
    look_at     <0.0, 0.0, 0.1>
    angle       32
  }
#else
  camera {
    location    <7, 14, 7>
    direction   y
    sky         z
    up          z
    right       x*image_width/image_height // keep propotions with any aspect ratio
    look_at     <0.0, 0.0, 0.0>
    angle       32
  }
#end

light_source {               
  <1.0, 4.0, 1.3>*100000
  color rgb <1.5, 1.4, 1.1>
}

// -------- Sky -------------
sphere {
  0,1
  texture {
    pigment {
      gradient z
      color_map {
        [0.03 color rgb <0.55, 0.65, 1.0> ]
        [0.12 color rgb <0.30, 0.40, 1.0> ]
      }
    }
    finish { ambient 1 diffuse 0 }
  }
  scale 1000
  no_shadow
  hollow on
}

// -------- random seeds for the Trees -------------
#declare Seed=seed(2);
#declare Seed2=seed(1);


// -------- Tree textures -------------
#if (Test_Render)
  // simple textures for test renders
  #declare T_Wood=
  texture {
    pigment { color rgb <1, 0, 0> }
  }

  #declare T_Tree=
  texture {
    pigment { color rgb <1, 0, 0> }
  }

#else
  #declare T_Wood=
  texture {
    pigment { color rgb <0.4, 0.2, 0.05> }
    finish {
      specular 0.3
      diffuse 0.5
    }
    normal {
      bozo 0.6
      scale <0.1, 0.1, 0.5>
    }
  }

  #declare T_Tree=
  texture {
    pigment {
      agate
      color_map {
        [0.77 color rgbt 1]
        [0.77 color rgb <0.2, 0.5, 0.10> ]
        [0.85 color rgb <0.4, 0.6, 0.15> ]
        [0.97 color rgb <0.4, 0.6, 0.15> ]
        [0.99 color rgb <0.4, 0.2, 0.05> ]
      }
      scale 0.5
      warp { turbulence 0.4 }
    }
    finish {
      diffuse 0.5
      brilliance 1.5
      ambient 0.07
    }
    normal {
      wrinkles 0.6
      scale 0.5
    }
  }
#end

// -------- Tree macro -------------
#macro TreeA (Size)
  union {
    cylinder { 0, Size*z, Size*0.04 }       // Trunk
    union {                                 // Roots
      cylinder { 0, -Size*0.30*z, Size*0.025 rotate (40+rand(Seed)*20)*x rotate rand(Seed2)*360*z }
      cylinder { 0, -Size*0.25*z, Size*0.020 rotate (40+rand(Seed)*20)*x rotate rand(Seed2)*360*z }
      cylinder { 0, -Size*0.27*z, Size*0.022 rotate (40+rand(Seed)*20)*x rotate rand(Seed2)*360*z }
    }

    union {                                 // Branches
      cylinder {
        0, Size*0.35*z, Size*0.025
        rotate (40+rand(Seed)*35)*x
        rotate rand(Seed2)*360*z
        translate Size*(0.7+0.3*rand(Seed))*z
      }
      cylinder {
        0, Size*0.40*z, Size*0.026
        rotate (40+rand(Seed)*35)*x
        rotate rand(Seed2)*360*z
        translate Size*(0.7+0.3*rand(Seed))*z
      }
      cylinder {
        0, Size*0.27*z, Size*0.022
        rotate (40+rand(Seed)*35)*x
        rotate rand(Seed2)*360*z
        translate Size*(0.7+0.3*rand(Seed))*z
      }
    }

    #if (Test_Render)                       // Foliage
      sphere {
        Size*z, Size*(0.4+rand(Seed)*0.15)
        scale <rand(Seed)*0.5+0.5, rand(Seed)*0.5+0.5, 1>
        texture { T_Tree scale Size translate rand(Seed)*6 }
      }
    #else
      union {
        sphere {
          Size*z, Size*(0.4+rand(Seed)*0.15)
          scale <rand(Seed)*0.5+0.5, rand(Seed)*0.5+0.5, 1>
          texture { T_Tree scale Size translate rand(Seed)*6 }
        }
        sphere {
          Size*z, Size*(0.3+rand(Seed)*0.15)
          scale <rand(Seed)*0.5+0.5, rand(Seed)*0.5+0.5, 1>
          texture { T_Tree scale Size translate rand(Seed)*6 }
        }
        sphere {
          Size*z, Size*(0.2+rand(Seed)*0.15)
          scale <rand(Seed)*0.5+0.5, rand(Seed)*0.5+0.5, 1>
          texture { T_Tree scale Size translate rand(Seed)*6 }
        }
        sphere {
          Size*z, Size*(0.3+rand(Seed)*0.15)
          scale <rand(Seed)*0.5+0.5, rand(Seed)*0.5+0.5, 1>
          texture { T_Tree scale Size translate rand(Seed)*6 }
        }
        sphere {
          Size*z, Size*(0.2+rand(Seed)*0.15)
          scale <rand(Seed)*0.5+0.5, rand(Seed)*0.5+0.5, 1>
          texture { T_Tree scale Size translate rand(Seed)*6 }
        }
        sphere {
          Size*z, Size*(0.3+rand(Seed)*0.15)
          scale <rand(Seed)*0.5+0.5, rand(Seed)*0.5+0.5, 1>
          texture { T_Tree scale Size translate rand(Seed)*6 }
        }
      }
    #end

    texture { T_Wood scale Size }
  }
#end


// -------- Terrain textures -------------
#declare T_Sand=
texture {
  pigment { color rgb <1.1, 0.7, 0.3> }
  finish { 
    specular 0.06 
    ambient <0.8, 0.9, 1.4>*0.1
  }
  normal {
    granite 0.3
    scale 0.1
  }
}

#declare T_Grass=
texture {
  pigment { color rgb <0.5, 1.15, 0.3> }
  finish {
    specular 0.1
    diffuse 0.3
    brilliance 1.6
    ambient <0.8, 0.9, 1.4>*0.03
  }
  normal {
    granite 0.5
    accuracy 0.01
    scale 0.12
  }
}

#declare T_Rock=
texture {
  pigment {
    agate
    color_map {
      [0.2 color rgb <0.55, 0.50, 0.50> ]
      [0.6 color rgb <0.75, 0.50, 0.60> ]
      [1.0 color rgb <0.70, 0.60, 0.60> ]
    }
    scale 0.2
    warp { turbulence 0.5 }
  }
  finish {
    specular 0.2
    diffuse 0.4
    ambient <0.8, 0.9, 1.4>*0.06
  }
  normal {
    granite 0.6
    scale 0.1
  }
}

#declare T_Terrain=
texture {
  slope { -z*0.8 altitude z }
  texture_map {
    [0.05 T_Grass ]
    [0.09 T_Sand  ]
    [0.19 T_Sand  ]
    [0.23 T_Rock  ]
  }
  translate -0.05*z
}

#if (use_iso)
  // -------- Use an isosurface for the terrain -------------

  #declare fnPig=   // Terrain shape function
  function{
    pigment {
      agate
      color_map {
        [0.0 color rgb 0.0]
        [0.3 color rgb 0.2]
        [0.7 color rgb 0.8]
        [1.0 color rgb 1.0]
      }
      warp { turbulence 0.01 }
      scale 5 
      translate <1.8, -6.7, 0>
    }
  }

  #declare Terrain_Obj=
  isosurface {

    function { z-fnPig(x, -y, 0).gray*0.4 }

    max_gradient 2.8
    //evaluate 1, 10, 0.99    // for evaluating max_gradient
    accuracy 0.02

    contained_by { box { <-3, -3, -0.1>, <3, 3, 0.41> } }

  }

#else
  // -------- Use a heightfield for the terrain -------------

  #declare Terrain_Obj=
  height_field {
    function 500,500 {
      pigment {
        agate
        color_map {
          [0.0 color rgb 0.0]
          [0.3 color rgb 0.2]
          [0.7 color rgb 0.8]
          [1.0 color rgb 1.0]
        }
        warp { turbulence 0.01 }
        scale 5 
        translate <1.8, -6.7, 0>
     
        translate <3, 3, 0>
        scale 1/6
        
        translate -0.5*y    
        scale <1, -1, 1>
        translate 0.5*y
      } 
    }

    rotate -90*x
    scale <6, 6, -0.4>
    translate <-3, -3, 0>
  }

#end

object {
  Terrain_Obj
  texture { T_Terrain }
}


// -------- Placing the trees -------------

#declare Spacing=0.24;
#declare Cnt=0;


#declare PosX=-3;

#while (PosX < 3)

  #declare PosY=-3;

  #while (PosY < 3)

    // trace function
    #declare Norm = <0, 0, 0>;
    #declare Start = <PosX+(rand(Seed)-0.5)*Spacing, PosY+(rand(Seed)-0.5)*Spacing, 1.0>;
    #declare Pos = trace (
                  Terrain_Obj,     // object to test
                  Start,           // starting point
                  -z,              // direction
                  Norm );          // normal


    #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)   // if intersection is found, normal differs from 0
      #if ((vdot(Norm, z)>0.85) & (Pos.z < 0.25))
      // criteria for placing trees: not too steep and not too high
        object {
          TreeA (0.05+rand(Seed)*0.02)
          translate Pos
        }
        #declare Cnt=Cnt+1;
      #end
    #end

    #declare PosY=PosY+Spacing;

  #end

  #declare PosX=PosX+Spacing;
#end

#debug concat("Placed ", str(Cnt,0,0), " Trees\n")