#include "rad_def.inc"

/* Radiosity seems to get rid of photon effects in this scene, at least
if I only use natural lighting (from the skysphere, here) */

#declare Detailed = 1;
#declare Rad = 0;


#declare Sky1 = pigment {
   granite
   turbulence <0.1, 0.1, 0.1>
   omega 0.52
   
   color_map {
      [ 0 color rgb <0.670588, 0.794118, 0.780392>
      ]
      [ 0.5 color rgb <0.552941, 0.65098, 0.670588>
      ]
      [ 1 color rgb <0.670588, 0.694118, 0.780392>
      ]
   }
}

sky_sphere {
   pigment {
      Sky1
   }
}


global_settings {
   adc_bailout 0.0039216
   assumed_gamma 1.5
   noise_generator 2
   photons {
   #if(Detailed)
       count 50000
       gather 5, 50
   #else
       count 10000
   #end
   autostop 0
   jitter .4
   }
   #if(Rad)
       radiosity {
	  Rad_Settings(Radiosity_Default, off, off)
       }
   #end
}

#if (!Rad)
light_source {
   <-0.95792, 1.4554, 1.5166>, rgb <1, 1, 1>
   parallel
   #if (Detailed & !Rad)
      area_light <1, 0.4, 0.2>, <0.2, -0.4, 1>, 6, 6
      adaptive 2
      jitter
   #else
      area_light <1, 0.4, 0.2>, <0.2, -0.4, 1>, 2, 2
   #end
   photons {
      refraction on
      reflection on
   }
}
#end

camera {
   perspective
   location <0.684467, 1.20461, 0.444912>
   sky <0, 1, 0>
   direction <0, 0, 1>
   right <1.33333, 0, 0>
   up <0, 1, 0>
   look_at <-0.482067, -0.13609, 0.336985>
}

#declare glass2 = material {
   texture {
      //*PMRawBegin
       normal { bumps 0.05 scale 0.1 } 
      //*PMRawEnd
      
      finish {
         diffuse 0.3
         brilliance 0.3
         specular 0.4
         roughness 0.05
         conserve_energy
         
         reflection {
            rgb <0.14902, 0.211765, 0.215686>
         }
      }
      
      pigment {
         color rgbft <0.72941, 0.78431, 0.92941, 0.1, 0.8>
      }
   }
   
   interior {
      media {
         intervals 1
         samples 1,5
         emission rgb <0.870588, 0.45098, 0.513725>
      }
      ior 1.1
      caustics 1
   }
}

#declare glass1 = material {
   interior {
      ior 2
   }
   
   texture {
      pigment {
         color rgbft <0.23922, 0.3098, 0.74902, 0.8, 0.6>
      }
      
      finish {
         ambient rgb <0, 0.027451, 0.282353>
         diffuse 0.15
         specular 0.2
         
         reflection {
            rgb <0.282353, 0.282353, 0.376471>
         }
      }
   }
}

#declare matte_white = texture {
        normal { bumps 0.08 scale 0.05 }
	finish {
		diffuse 0.6
		specular 0.5
		roughness 0.005
		reflection { 0.1 0.6
				falloff 5
				}
	}
	pigment { rgb 0.85 }
}

#declare matte_grey = texture {
        normal { bumps 0.07 scale 0.05 }
	finish {
		diffuse 0.5
		specular 0.25
		roughness 0.005
		reflection { 0.2 0.7
				falloff 9
				}
	}
	pigment { rgb 0.35 }
}

#declare gloss_white = texture {
	finish {
		diffuse 0.6
		specular 0.25
		roughness 0.005
		reflection { 0.2 0.7
				falloff 9
				}
	}
	pigment {
		agate
		color_map {
			[ 0.0   rgb 0.95 ]
			[ 0.5	rgb 0.90 ]
			[ 0.55  rgb 0.55 ]
			[ 0.60  rgb 0.90 ]
			[ 1.00  rgb 0.95 ]
		}
	}
}

#declare white1 = texture {
	finish {
		diffuse 0.6
		specular 0.5
		roughness  0.005
		reflection 0.73
	}
	normal { bumps 0.02 scale 0.1 }
	pigment { rgb 0.85 }
}

#declare matte_tan = texture {
        normal { bumps 0.07 scale 0.05 }
	finish {
		diffuse 0.5
		specular 0.25
		roughness 0.005
		reflection { 0.2 0.7
				falloff 9
				}
	}
	pigment { rgb <0.76,0.67,0.44> }
}


#declare grey1 = texture {
	finish {
		diffuse 0.6
		specular 0.3
		roughness  0.005
		reflection 0.63
	}
	normal { bumps 0.02 scale 0.1 }
	pigment { rgb 0.70 }
}

#declare black1 = texture {
	finish {
		diffuse 0.6
		specular 0.2
		roughness  0.005
		reflection 0.13
	}
	normal { bumps 0.02 scale 0.1 }
	pigment { rgb 0.40 }
}

#declare Grey_amount = 0.1;
#declare Black_amount = 0.05;
#declare positive = texture {
	bumps
        scale 0.01
	texture_map {
	[ 0.0 white1 ]
	[ (Grey_amount) grey1 ]
	[ (2*Grey_amount) white1 ]
	[ 0.5 white1 ]
	[ (0.5 + Black_amount) black1 ]
	[ (0.5 + 2*Black_amount) white1 ]
	}
}

#declare negative = texture {
	bumps
        scale 0.01
	texture_map {
	[ 0.0 grey1 ]
	[ (Grey_amount) black1 ]
	[ (2*Grey_amount) grey1 ]
	[ 0.5 grey1 ]
	[ (0.5 + Black_amount) black1 ]
	[ (0.5 + 2*Black_amount) grey1 ]
	}
}

#declare rock1 = texture {
	finish {
		diffuse 0.6
		ambient 0.05
		phong 0.25
		phong_size 100
	}
	normal { dents 0.5 scale 0.01 }
	pigment {
		granite
		pigment_map {
		[ 0.0  rgb <0.646,0.557,0.482> ]
		[ 0.3  rgb <0.473,0.420,0.361> ]
		[ 0.6  rgb <0.697,0.623,0.537> ]
		[ 0.7 rgb <0.148,0.118,0.118> ]
		[ 0.8 rgb <0.473,0.420,0.361> ]
		[ 1.0  rgb <0.646,0.557,0.482> ]
		}
		scale 0.25
	}
}

#declare rock2 = texture {
	finish {
		diffuse 0.7
		ambient 0.06
		phong 0.2
		phong_size 75
	}
	normal { dents 0.6 scale 0.007 }
	pigment {
		granite
		pigment_map {
		[ 0.0  rgb <0.696,0.607,0.532> ]
		[ 0.3  rgb <0.573,0.470,0.381> ]
		[ 0.6  rgb <0.797,0.673,0.557> ]
		[ 0.7 rgb <0.448,0.368,0.338> ]
		[ 0.8 rgb <0.573,0.470,0.381> ]
		[ 1.0  rgb <0.696,0.607,0.532> ]
		}
		scale 0.25
	}
}

#declare tile_pattern = texture {
	material_map {
		png "/home/hodapp/pov/map1.png"
		texture { matte_tan }
		texture { matte_white }
	}
	rotate x*90
	rotate y*70
	scale 0.5
}

#declare mortar1 = texture {
        normal { bumps 0.08 scale 0.05 }
	finish {
		diffuse 0.8
		reflection 0
	}
	pigment {
		granite
		color_map {
		[0.0 rgb 0.85]
		[0.5 rgb 0.35]
		[1.0 rgb 0.85]
		}
		scale 0.1
	}
}

#declare hex = texture {
	hexagon
	texture { matte_white },
	texture { matte_grey },
	texture { matte_tan }
	scale 0.25
}

#declare minx = -3;
#declare minz = -2;
#declare maxx = 2;
#declare maxz = 3;
#declare dx = 0.5;
#declare dz = 0.5;
#declare sx = 0.05;
#declare sz = 0.05;
#declare y1 = 0;
#declare y2 = -0.1;
#declare sy = 0.02;

#declare cx = minx;
union {
	#while(cx < maxx)
		#declare cz = minz;
		#while(cz < maxz)
			box { <cx, y1, cz>, <cx+dx, y2, cz+dz> }
			#declare cz = cz + dz + sz;
		#end
		#declare cx = cx + dx + sz;
	#end
	photons { collect on }
	texture { gloss_white }
}

box { <minx, y1 - sy, minz>, <maxx, y2 + sy, maxz> 
	photons {collect on}
	texture { mortar1 }
}
/*   
box {
   <-3, 0, 3>, <2, -0.1, -2>
   scale 1
   rotate <0, 0, 0>
   translate <0, 0, 0>
   photons { collect on }
   texture {
     gloss_white
   }
}*/

#declare Teardrop = lathe {
   cubic_spline
   10,
   <-0.069618, 1.9881>, <0, 1.4609>, <0.084975, 1.057>, <0.19148, 0.83258>, <0.28808, 0.66645>, <0.39872, 0.48367>, <0.44644, 0.267513>, <0.308297, 0.0832133>, <0, 0.0375>, <0, 0.0375>
   scale 1
   rotate x*(-90)
   translate <0, 0, 0>
   
   material {
      glass1
   }
   //*PMRawBegin
   #if (Detailed)
     sturm
   #end
   photons{
     target
     collect off
     reflection on
     refraction on
   }
   //*PMRawEnd
}

merge {
   object {
      Teardrop
      scale 1
      rotate <0, 0, 0>
      translate <0, 0, 0>
   }
   
   object {
      Teardrop
      scale 1
      rotate x*(-72)
      translate <-9.98173e-16, 1.3905, -1.0079>
   }
   
   object {
      Teardrop
      scale 1
      rotate x*(-144)
      translate <-9.98173e-16, 0.85872, -2.6427>
   }
   
   object {
      Teardrop
      scale 1
      rotate x*(-216)
      translate <-9.98173e-16, -0.862947, -2.65281>
   }
   
   object {
      Teardrop
      scale 1
      rotate x*(-288)
      translate <-9.98173e-16, -1.389, -1.008>
   }
   rotate z*90
   scale 0.5
   translate <-0.472669, 0.25145, 1.06121>
}