// Zufaelliges Labyrinth
// (C) 2/2006 Christian Perle

#declare A = seed(31923);

#declare Night = 1;

camera {
  location <rand(A)*10-5, rand(A)*5+3, rand(A)*5-12>*3.2
  direction 2*z
  look_at 18*z
}

#if (Night)
light_source { <-100, 100, -150> color rgb<rand(A)*.3, rand(A)*.3, rand(A)*.3> }
light_source { <80, 100, -110> color rgb<rand(A)*.3, rand(A)*.3, rand(A)*.3> }
#else
light_source { <-100, 100, -150> color rgb<rand(A)*.5+.5, rand(A)*.5+.5, rand(A)*.5+.5> }
light_source { <80, 100, -110> color rgb<rand(A)*.5+.5, rand(A)*.5+.5, rand(A)*.5+.5> }
#end

plane {
  y, 0
  pigment {
    bozo turbulence .5
    scale .2
    color_map {
      [0 color rgb 0]
      [1 color rgb .4]
    }
  }
  finish { reflection .3 phong .7 }
}

#declare LabPart = union {
  box { <-sqrt(2)-.08, 0, -.08>, <sqrt(2)+.08, 1, .08> }
  pigment {
    bozo turbulence .5 scale <1, .1, 1>*.1
    color_map {
      [0 rgb .45]
      [1 rgb .55]
    }
  }
  normal { brick scale .1 }
  rotate 45*y
  rotate -90*x
}

#declare LabX=100;
#declare LabY=100;

#declare Y=0;
union {
#while (Y<LabY)
  #declare X=0;
  #while (X<LabX)
    object {
      LabPart
      rotate 90*int(rand(A)*2)*z
      translate <X, Y, 0>
    }
    #if (rand(A) < .15)
      sphere {
        0, .48 hollow
        pigment { rgbf<rand(A)*.8+.2, rand(A)*.8+.2, rand(A)*.8+.2, .7> }
        finish {
          phong .7 phong_size 18
          reflection .1 refraction 1 ior 1.33
        }
        normal { spiral2 10 .1 }
        translate <X+1, Y, -.5>
      }
      #if (Night)
      light_source { <X+1, Y, -.5> color rgb 1 }
      #end
    #end
    #declare X=X+2;
  #end
  #declare Y=Y+2;
#end
  translate <-LabX/2, -LabY/10, 0>
  rotate 90*x
}