// -----------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------- Grass texture
#declare Tan1 = rgb< 0.86,0.58,0.44>;
//#declare Green1=rgb<0.80,0.67,0.20>;
//#declare Green2=rgb<0.36,0.63,0.03>;
#declare Green1=rgb<0.4,0.7,0.2>*0.2;
#declare Green2=rgb<0.37,0.63,0.07>*0.8;
//----------------------------------
#declare P_Spotted =pigment {
spotted
    color_map {
        [0.0  color Tan1*0.1 ]
        [0.2  color Tan1*0.4 ]
        [0.3  color Green1*0.9 ]
        [1.01 color Green1*1.1 ]
    }
}//---------------------------------
#declare P_Earth =pigment {
    spotted
    color_map {
        [0 color Tan*0.3]
        [0.6 color Tan*0.3]
        [0.6 color Green1*0.4]
        [1   color Green1*0.6]
    }
}//---------------------------------
#declare P_Green=pigment{Green2*1.3}
//#declare P_Spotted=pigment{Red}
//#declare P_Earth=pigment{Blue}
#declare T_Grass=texture {                  
    pigment {
        gradient y
        turbulence 0.2
        pigment_map {                                
            [0.0 P_Earth]
            [0.2 P_Green]
            [0.8 P_Spotted]
            [1.00 P_Earth]
        }
    }
    finish{ specular 0.2 roughness 0.015}
    scale <0.001,1,0.001>
} //---------------------------------------------------------------------------- end Grass texture
// -----------------------------------------------------------------------------------------------


// -----------------------------------------------------------------------------------------------
#include "makegrass.inc"
// -----------------------------------------------------------------------------------------------
// Patch parameters  // ! Final number of triangles = nBlade * nBlade * segBlade * 2 (or 4 if dofold = true)
#declare lPatch=50;               // size of patch
#declare nBlade=15;                // number of blades per line (there will be nBlade * nBlade blades)
//#declare nBlade=4;                // number of blades per line (there will be nBlade * nBlade blades)
#declare ryBlade = 0;            // initial y rotation of blade
#declare segBlade= 10;            // number of blade segments
#declare lBlade = 10;             // length of blade
#declare wBlade = 0.8;            // width of blade at start
#declare wBladeEnd = 0.3;         // width of blade at the end
#declare doSmooth=false;          // true makes smooth triangles
#declare startBend = <0,1,0.3>;   // bending of blade at start (<0,1,0>=no bending)
#declare vBend = <0,1,0>;         // force bending the blade (<0,1,1> = 45°)
#declare pwBend = 4;              // bending power (how slowly the curve bends)
#declare rd = 459;                // seed
#declare stdposBlade = 1;         // standard deviation of blade position 0..1
#declare stdrotBlade = 360;       // standard deviation of rotation
#declare stdBlade = 1.2;           // standard deviation of blade scale
#declare stdBend = 3;            // standard deviation of blade bending
#declare dofold = 1;//false;/true; or 0;/1; // true creates a central fold in the blade (twice more triangles)
#declare dofile = 0;//false;/true; or 0;/1; // true creates a mesh file
#declare fname = "fgrass2.inc"     // name of the mesh file to create
// -----------------------------------------------------------------------------------------------
// Prairie parameters
#declare nxPrairie=12;             // number of patches for the first line
#declare addPatches=1.5;            // number of patches to add at each line
#declare nzPrairie=35;             // number of lines of patches
#declare rd=seed(779);            // random seed
#declare stdscale=1;              // stddev of scale
#declare stdrotate=1;             // stddev of rotation
#declare doTest=0;//false;/true; or 0;/1; // replaces the patch with a sphere
// -----------------------------------------------------------------------------------------------
// Create the patch 
#if (dofile=true) // if the patch is already created, turn off the next line
   MakeGrassPatch(lPatch,nBlade,ryBlade,segBlade,lBlade,wBlade,wBladeEnd,doSmooth,startBend,vBend,pwBend,rd,stdposBlade,stdrotBlade,stdBlade,stdBend,dofold,dofile,fname)
   #declare objectPatch=#include fname
#else        
   #declare objectPatch=object{MakeGrassPatch(lPatch,nBlade,ryBlade,segBlade,lBlade,wBlade,wBladeEnd,doSmooth,startBend,vBend,pwBend,rd,stdposBlade,stdrotBlade,stdBlade,stdBend,dofold,dofile,fname)}
#end        
// -----------------------------------------------------------------------------------------------
// Create the prairie
object{MakePrairie(lPatch,nxPrairie,addPatches,nzPrairie,objectPatch,rd,stdscale,stdrotate,doTest)
// or optional: show Single Patch  
// object{  ObjectPatch
    scale 1/40
    texture{T_Grass }
   /* size ~ 1.00 !!! */
 scale 1     // -> size ~  1 units high
 //scale 0.5 // -> size ~0.5 units high
 translate<0,0,-0.75>
}  
// -----------------------------------------------------------------------------------------------
//cylinder{0,y*0.01,5 texture{T_Grass scale 40}}


// Test pole 1 unit high ------------------------------------
cylinder { <0,0,0>,<0,1.00,0>, 0.05  
           pigment { color rgb<1,1,1> }
           scale <1,1,1> rotate<0,0,0> translate<0,0,0>
         } // end of cylinder -------------------------------
//-----------------------------------------------------------
