|
![](/i/fill.gif) |
"Nekar" <ger### [at] rpmmag co za> wrote:
> How did you do that?
>
> Could you please post the code?
>
>
Hi Raytracers,
well first I couldn't find that grass macro. I know there must be one
somewhere, but anyway,
I wanted to have a look at the trace() command of POVray.
So I made a blade of grass with Wings3d and exported it to POVray.
The "foot" of the blade of grass is in the zero XY-plane.
I used Wings because I was too lazy to make a grass with POVray. But it
could be done with a prism shape I think.
Then I made ~32 thousand grasses randomly oriented and aranged them with the
trace command on the surface of a standard blob.
Code: Only the .pov file
The grass is in a zip file (omly two kilobytes),
please download at:
http://www.ginko.de/user/burki/halm.zip
// 3'17'' rendering time
// Persistence of Vision Ray Tracer Scene Description File
// File: ?.pov
// Vers: 3.6
// Desc: Checkered Floor Example
// Date: mm/dd/yy
// Auth: ?
//
#version 3.6;
#include "colors.inc"
#include "halm.inc" // halm=blade of grass, in the zip file
global_settings {
assumed_gamma 1.0
max_trace_level 3
}
// ----------------------------------------
camera {
location <0.0, 0.5, -4.0>
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
}
sky_sphere {
pigment {
gradient y
color_map {
[0.0 rgb <0.6,0.7,1.0>]
[0.7 rgb <0.0,0.1,0.8>]
}
}
}
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30, 30, -30>
}
// ----------------------------------------
plane { // granite floor
y, -1
texture
{
pigment {
granite
color_map {
[0.0 rgb <0.6,0.7,1.0>]
[0.7 rgb <0.6,0.3,1.0>]
}
scale 12
}
finish{
diffuse 0.8
ambient 0.1
}
}
}
// The blob (standard blob from menu)
#declare RadiusVal = 1.0; // (0 < RadiusVal) outer sphere of influence on
other components
#declare StrengthVal = 1.0; // (+ or -) strength of component's radiating
density
#declare blobby=
blob {
// threshold (0.0 < threshold <= StrengthVal) surface falloff threshold #
threshold 0.6
sphere { < 0.75, 0, 0>, RadiusVal, StrengthVal }
sphere { <-0.375, 0.65, 0>, RadiusVal, StrengthVal }
sphere { <-0.375, -0.65, 0>, RadiusVal, StrengthVal }
cylinder { -z, +z, RadiusVal, StrengthVal }
// [sturm]
scale 0.7
rotate 137
}
// Grass
#declare r1=seed(0); // seed. well, that fits with grass
#declare r2=seed(2134);
#declare r3=seed(1532135);
#declare misplaced = 0;
#declare i=0;
#declare num = 32479; // yes, a prime number
#while (i < num)
#local normale=<0,0,0>;
#local pos = (<rand(r1), rand(r2), rand(r3)>-0.5) *16 ;
//////////////////////////////////////////////////////////////////////////////////////
#local foot = trace(blobby, pos, -pos, normale); // The trace command,
powerfull ! //
//////////////////////////////////////////////////////////////////////////////////////
#if (vlength(normale) > 0)
object {
halm // blade of grass from include file (see below)
scale 0.1
//rotate 60*y
finish {ambient 0.25}
// -------------- polar Coordinates from normale vector
// phi, to be -z rotated
#declare nor_phi = degrees (acos(normale.y) );
#declare nor_phi_text = concat("nor_phi: ", str(nor_phi,0,1),
" degs");
// nor_phi_text not used here
// theta, to be -y-rotated
#declare nor_theta = degrees ( atan2 (normale.z, normale.x)
);
#declare nor_theta_text = concat("nor_theta: ",
str(nor_theta,0,1), " degs");
// nor_theta_text not used here
// arrange the grass along the blob
rotate -z * nor_phi
rotate -y * nor_theta
translate foot
}
#else
#local misplaced = misplaced + 1; // used for debugging
#end // if
#declare i = i + 1; // i=counter
#end
text {
ttf
"crystal.ttf",
concat("#=", str (num,0,0)) ,
0,
0
translate <-20,10,50>
}
// blobby itself is not displayed
#debug concat ("misplaced: ", str(misplaced,0,0) )
Maybe the following is a bit too late for
this year's St. Patricks Day.
Yours,
Bu.
Post a reply to this message
Attachments:
Download 'shamrock2.jpg' (70 KB)
Preview of image 'shamrock2.jpg'
![shamrock2.jpg](/povray.binaries.images/attachment/%3Cweb.4600215570d890167beb2560%40news.povray.org%3E/shamrock2.jpg?ttop=443866&toff=3950&preview=1)
|
![](/i/fill.gif) |