POV-Ray : Newsgroups : povray.binaries.images : Isosurface grass : Re: Isosurface grass Server Time
30 Jul 2024 14:19:00 EDT (-0400)
  Re: Isosurface grass  
From: Christian Froeschlin
Date: 19 Jul 2011 18:30:32
Message: <4e260588$1@news.povray.org>
> Cool, alien grass for Port Whatmough! May I use the isosurface code?

Sure, I cleaned it up a little bit:


//
// WIDTH and DEPTH limit the size of the isosurface / grass field
//
// SPACING, THICKNESS and HEIGHT determine grass blade geometry
//
// Sample call: GRASS(5,5,0.004,0.0015,0.08)
//
// Note:  max gradient and required accuracy of isosurface depend
// on spacing and thickness and may need to be tuned manually
#macro GRASS(WIDTH,DEPTH,SPACING,THICKNESS,HEIGHT)

#local NSA = 5*SPACING;     // Spacing noise amplitude
#local NSF = 1/(5*SPACING); // Spacing noise frequency
#local NHA = HEIGHT;        // Height noise amplitude
#local NHF = 1/HEIGHT;      // Height noise frequency

#local f_blade  = function(x,y,z)
{
   f_sphere(x/THICKNESS,y/HEIGHT,z/THICKNESS,1)
}

#local f_blades = function(x,y,z)
{
   f_blade(sin(x/SPACING)*SPACING,y,sin(z/SPACING)*SPACING)
}

#local f_grass  = function(x,y,z)
{
   f_blades(x + NSA * (f_bozo(x*NSF,       0, z*NSF)-0.5)
              + NHA * (f_bozo(x*NSF,   y*NHF, z*NSF)-0.5),
            y + NHA *  f_bozo(x*NSF, 0,z*NSF),
            z + NSA * (f_bozo(x*NSF,10,z*NSF)-0.5)
              + NHA * (f_bozo(x*NSF,10+y*NHF, z*NSF)-0.5)
           )
}

isosurface
{
   function { f_grass(x,y,z) }
   contained_by { box {<0,0,0>,<WIDTH,NHA+HEIGHT,DEPTH>} }
   accuracy 0.00005
   max_gradient 3000
}

#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.