|
|
> 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
|
|