#include "colors.inc"
#include "textures.inc"
#include "stones.inc"
#include "arrays.inc" 
#include "stdinc.inc" 

global_settings {
  assumed_gamma 1.0
  max_trace_level 15
}

#declare Camera =  camera {
    location <0.2, 0.3, -1.4>
    look_at  <0, 0., 0>
    //angle 90
  }
camera {Camera}


// create a regular point light source
light_source {
  0*x                  // light's position (translated below)
  color rgb <1,1,1>    // light's color
  translate <2, 4,-3>
}
light_source {
  0*x                  // light's position (translated below)
  color rgb <1,1,1>    // light's color
  translate <4, 5, -4>
}
light_source {
  0*x                  // light's position (translated below)
  color rgb <1,1,1>    // light's color
  translate <0, 0.2, -1>
}

#macro KUGEL(mitte)
        sphere { mitte, C_RADIUS                        
	texture {
	    pigment { color rgb<0.7, 0.7, 0.01> } //Yellow is pre-defined in COLORS.INC
//	    pigment { image_map { png "Demo4.png" map_type 0 }}
//      pigment {
 //       DMFWood4       // pre-defined in textures.inc
  //      scale 1        // scale by the same amount in all
                       // directions
   //   }
      //finish { Shiny } // pre-defined in finish.inc
       finish {
      //ambient 0.6
      //diffuse 0.6
    }

	//    finish { phong 1 }
	}
	}
#end

#declare chance1 = seed (8);
#declare chancex = seed (18);
#declare chancey = seed (38);
#declare C_RADIUS =0.45;
#declare sigma1 = 3.5;
#declare sigma2 = 5;
#declare sigma3 = 7;
#declare sigma4 = 8;
#declare gauss = function(xx, zz) {
        20 * exp (-((xx+25) * (xx+25) +(zz-20) * (zz-20) )/2 /sigma2 / sigma2) + 
        17 * exp (-((xx-25) * (xx-25) +(zz-20) * (zz-20) )/2 /sigma1 / sigma1) +   
	10 * exp (-((xx-18) * (xx-18) +(zz) * (zz) )/2 /sigma2 / sigma2)  +
	8 * exp (-((xx) * (xx) +(zz+19) * (zz+19) )/2 /sigma3 / sigma3)  +
	5 * exp (-((xx+30) * (xx+30) +(zz+29) * (zz+29) )/2 /sigma4 / sigma4)  
}
/*
#declare x0    =  -40;
#while(x0 <= 40)
  #declare z0    =  -40;
      #while(z0 <= 40)
                #local xx = x0 + 0.0039* rand(chancex);
                #local yy = gauss(x0, z0) + 0.0079* rand(chance1);
                #local zz = z0 + 0.0039* rand(chancey);
		#declare yi = yy;
		#while(yi > 0)
		KUGEL(<xx, yi, zz>)
		#declare yi = yi - 1.8;
		#end
                #declare z0 = z0 + 1;
        #end // theta
        #declare x0 = x0 + 1;
#end // phi
*/
/*  height_field {
    png "image.png"
    //smooth
    pigment { Green }
    scale <70, 20,70>
    translate <-30, 15, -30>
  }*/

//   plane {
//     y, 10
//     texture {
//     pigment { image_map { 
// 	  png "image.png"  
// 	  map_type 1 
// 	  }
// 	  scale <0.2,2,0.2>
// 	  }
// 	 // finish{phong 1}
//   }
//   }

// box {
//     <0, 0, 0>,  // Near lower left corner
//     < 1, 1, 0>   // Far upper right corner
//     texture {
//     pigment { image_map { 
// 	  png "oneobject.png"  
// 	  map_type 0
// 	  //interpolate 2
// 	  once
// 	  }
// 	 // translate<0.,0,0.5>
// 	  //scale <1,1,1>
// 	  //rotate<0,0,0>
//  	  }
//     }
//          finish {
//        diffuse 0.1
//        ambient 0.5
//        //phong 0.1
//       // phong_size 100
//        //reflection 0.9
//      }
// 
//     rotate <90,0,0>
//     translate<-0.5,0.1,-0.5>
//   }


#declare HF_Res_X = 1024; // number of points in x
#declare HF_Res_Z = 1024; // number of points in z
//#declare HF_Function  = function{0.9*exp(-((x-0.5) * (x-0.5) +(z-0.5) * (z-0.5) )/2 /0.0015) + 
//      0.3*exp(-((x-0.65) * (x-0.65) +(z-0.45) * (z-0.45) )/2 /0.005)+ 
//      0.4*exp(-((x-0.35) * (x-0.35) +(z-0.55) * (z-0.55) )/2 /0.005) + 0.01+0.01*sin(x*30)+1+  f_snoise3d(x*10,z*1,y*1)*0.03 }
#declare HF_Function  =function(x,y,z) {0.1+0.4*exp(-((x-0.5) * (x-0.5) +(z-0.5) * (z-0.5) )/2 /0.01)}
#declare HF_Amplitude = 5;

height_field{
  function  HF_Res_X, HF_Res_Z {HF_Function(x,0,y)}
  //smooth
  //water_level 0
  texture {pigment{ color rgb<0.,0.6,0.1>}
            finish { //phong 2 phong_size 400
		      reflection{0.02 metallic}
	    }
          } // end of texture
  translate<-0.5,0,-0.5>
  scale <1,1,1>
}//------------------------------------------------ 

sphere { <0,-.051,-0.2>, 0.02                        
	texture {
	    pigment { color rgb<0.7, 0.9, 0.9> } //Yellow is pre-defined in COLORS.INC
//	    pigment { image_map { png "Demo4.png" map_type 0 }}
//      pigment {
 //       DMFWood4       // pre-defined in textures.inc
  //      scale 1        // scale by the same amount in all
                       // directions
   //   }
//      finish { Shiny } // pre-defined in finish.inc
       finish {
      //ambient 0.6
      //diffuse 0.6
 reflection{0.9 metallic}
  
  }
//    finish { phong 1 }
	}
	}
box {
    <0, 0, 0.2>,  // Near lower left corner
    < 1, 1, 0.23>   // Far upper right corner
    texture {
pigment { color rgb<0., 0.2, 0.6> }
	 // translate<0.,0,0.5>
	  //scale <1,1,1>
	  //rotate<0,0,0>
    }
         finish {
       diffuse 0.1
       ambient 0.6
       //phong 0.1
       //phong_size 100
       //reflection 0.9
     }

    rotate <90,0,0>
    translate<-0.5,0.1,-0.5>
  }
// plane {
//   y, -0.61
//    texture {
//      pigment {
//        //checker
//        //color rgb<0.5, 0, 0>
//        //color rgb<0, 0., 0.>
//      }
//      finish {
//        diffuse 0.1
//        ambient 0.8
//        phong 0.01
//        phong_size 100
//        reflection 0.0003
//      }
//    }
//  }
