|
![](/i/fill.gif) |
Hi Chris,
> You are probably using noise_generator 3, see:
well, I didn't actually change the global noise_generator setting, so it
should be type 2 (the default, at least according to both
documentations) in either case, shouldn't it?
> Apart from that i am not aware of any significant differences in
> patterns. If you post the code a more definite answer would be possible.
OK, here comes some sample code (instructions below):
---8<---
// Set this to 1 to recalculate pebble positions and
// to store pebble definitions in "pebbles_test.inc";
// set to 0 to re-use previously generated pebbles file.
#declare recalculatePebblePositions = 1;
#include "transforms.inc"
#include "strings.inc"
// agate-based height field object
#declare Terrain =
height_field {
function 200,200 {
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]
}
scale 0.5
turbulence 0.1
}
}
smooth
texture {
pigment { color rgb <0.2, 0.8, 0.0> }
}
translate <-0.5, 0, -0.5>
scale <10000, 1000, 10000>
translate <-500, 0, 0>
}
// This macro creates ellipsoids located randomly
// at the height-field's surface and stores their
// definitions in a file named "pebbles_test.inc"
#macro makePebbleFile()
#fopen F "pebbles_test.inc" write
#local randSeed = seed(1);
// make 3000 pebbles
#local i = 0;
#while (i < 3000)
// the height field's surface normal at the
// intersection point; simultaneously a flag
// for "intersection found" according to
// documentation of trace function
#declare intersectionNormal = <0, 0, 0>;
// a parameter combining the height field's height
// and slope at the intersection point
#declare heightSlope = -1;
// randomly create the pebble's x- and z-coordinate
#local pebbleX = (rand(randSeed) - 0.5)*10000;
#local pebbleZ = (rand(randSeed) - 0.5)*10000;
// calculate intersection of a ray originating at the pebble's
// x- and z-coordinates and propagating into y direction with
// the height field
#declare intersectionPoint = trace(Terrain, <pebbleX, 0, pebbleZ>,
y, intersectionNormal);
// if an intersection was found, intersectionNormal should
// contain the height field's surface normal at the intersection point
#if (vlength(intersectionNormal) !=0)
// calculate "degree of horizontalness"; s is
// 0 at a horizontal plateau,
// 1 at a vertical wall,
// 2 at a horizontal overhang
#local s = 0.5*(vdot(-intersectionNormal, y)+1);
// relative height of intersection point
#local h = intersectionPoint.y/800;
// combination of horizontalness and height;
// is low if both horizontalness and height are low.
#declare heightSlope = s + 0.8*h;
#end
// if not too high and not too steep...
#if ((heightSlope >= 0) & (heightSlope < 0.25))
// set size to random values
#local pebbleSizeX = rand(randSeed)+0.2;
#local pebbleSizeZ = rand(randSeed)+0.2;
// ensure the pebble is not higher than wide
#local pebbleSizeY = rand(randSeed)*(min(pebbleSizeX,pebbleSizeZ));
// combine individual size values into scaling vector
#local pebbleSize = <pebbleSizeX, pebbleSizeY, pebbleSizeZ>;
// now write to file the definition for a sphere scaled to size
vector...
#write (F, "sphere { 0 20 texture {pigment { color rgb <1.0, 0.8,
0.5>} } scale ",VStr(pebbleSize))
// ...rotated around y axis for a random angle...
#write (F, " rotate y*",str(rand(randSeed)*360,0,0))
// ...ensure it lies flat on a sloped surface...
#write (F, " Point_At_Trans(",VStr(intersectionNormal))
// ...and translate to determined intersection point
#write (F, ") translate ",VStr(intersectionPoint)," +
y*",Str(pebbleSizeY),"/2 }\n")
// another pebble has been placed
#local i = i + 1;
#end
#end
#fclose F
#end
// introduce height field into scene
object {Terrain}
// if requested, re-calculate pebble positions
#if (recalculatePebblePositions)
makePebbleFile()
#end
// include previously calculated pebble positions
#include "pebbles_test.inc"
// blue sky
sky_sphere {
pigment {
gradient y
color_map {
[0.5 color rgb <0.8, 0.9, 1.0>]
[1.0 color rgb <0.5, 0.8, 1.0>]
}
scale 2
translate -y
}
}
// we are standing somewhere in the landscape,
// looking south-south-east
camera {
location <-2000, 200, 0>
up y
right x*4/3
look_at <-1000, 0, -2000>
angle 80
}
// main light
light_source { <100000, 100000, -100000>
color rgb 1
}
// additional ambient light
light_source { <-100000, 100000, 100000>
color rgb 0.5
shadowless
}
---8<---
To reproduce the "hovering pebbles" effect, do the following:
1. Set recalculatePebblePositions to 1 (line 4)
2. Run the script using PovWin 3.5
3. Change recalculatePebblePositions to 0
4. Re-run the script using PovWin 3.6
See what I mean? ;-)
Regards --
Torsten
Post a reply to this message
|
![](/i/fill.gif) |