Index: branches/water/src/lib/graphics/importer/material.cc
===================================================================
--- branches/water/src/lib/graphics/importer/material.cc	(revision 7981)
+++ branches/water/src/lib/graphics/importer/material.cc	(revision 7982)
@@ -107,4 +107,14 @@
   if (unlikely(this == Material::selectedMaterial))
       return true;
+  else if (likely(Material::selectedMaterial != NULL))
+  {
+  Material::unselect();
+//     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
+//     {
+//         glActiveTexture(Material::glTextureArbs[i]);
+//         glBindTexture(GL_TEXTURE_2D, 0);
+//         glDisable(GL_TEXTURE_2D);
+//     }
+  }
 
 
@@ -137,14 +147,4 @@
   else if (this->illumModel >= 2)
     glShadeModel(GL_SMOOTH);
-
-  if (likely(Material::selectedMaterial != NULL))
-  {
-    for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
-    {
-        glActiveTexture(Material::glTextureArbs[i]);
-        glBindTexture(GL_TEXTURE_2D, 0);
-        glDisable(GL_TEXTURE_2D);
-    }
-  }
 
   for(unsigned int i = 0; i < this->textures.size(); ++i)
@@ -172,4 +172,15 @@
 }
 
+void Material::unselect()
+{
+  Material::selectedMaterial = NULL;
+    for(unsigned int i = 0; i < 8; ++i)
+    {
+        glActiveTexture(Material::glTextureArbs[i]);
+        glBindTexture(GL_TEXTURE_2D, 0);
+        glDisable(GL_TEXTURE_2D);
+    }
+}
+
 /**
  *  Sets the Material Illumination Model.
Index: branches/water/src/lib/graphics/importer/material.h
===================================================================
--- branches/water/src/lib/graphics/importer/material.h	(revision 7981)
+++ branches/water/src/lib/graphics/importer/material.h	(revision 7982)
@@ -32,4 +32,5 @@
 
     bool select () const;
+    static void unselect();
 
     void setIllum (int illum);
Index: branches/water/src/lib/graphics/shader.h
===================================================================
--- branches/water/src/lib/graphics/shader.h	(revision 7981)
+++ branches/water/src/lib/graphics/shader.h	(revision 7982)
@@ -23,7 +23,7 @@
   {
   public:
-    Uniform(const Shader* shader, const std::string& location) { glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
-    Uniform(const Shader& shader, const std::string& location) { glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
-    Uniform(GLhandleARB shaderProgram, const std::string& location) { glGetUniformLocation(shaderProgram, location.c_str()) ; };
+    Uniform(const Shader* shader, const std::string& location) { this->uniform = glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
+    Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
+    Uniform(GLhandleARB shaderProgram, const std::string& location) { this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
 
     void set(float v0) const { glUniform1f(this->uniform, v0); }
Index: branches/water/src/world_entities/environments/mapped_water.cc
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.cc	(revision 7981)
+++ branches/water/src/world_entities/environments/mapped_water.cc	(revision 7982)
@@ -39,5 +39,5 @@
   mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0);
   // load refraction texture
-  mat.setDiffuseMap("pictures/sky-replace.jpg", 1);
+ // mat.setDiffuseMap("pictures/sky-replace.jpg", 1);
   // load normal map
   mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
@@ -123,10 +123,9 @@
   // HACK
 
-  glDisable(GL_BLEND);
   //glActiveTexture(GL_TEXTURE0);
   //glBindTexture(GL_TEXTURE_2D, this->texture);
-
+  mat.unselect();
   mat.select();
-  glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
+  //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
 
 
@@ -134,24 +133,35 @@
   this->shader->activateShader();
   GLint uniform;
+  Shader::Uniform* uni;
 
   // Set the variable "reflection" to correspond to the first texture unit
-  uniform = glGetUniformLocationARB(shader->getProgram(), "reflection");
-  glUniform1iARB(uniform, 0); //second paramter is the texture unit
+  uni = new Shader::Uniform (shader, "reflection");
+  uni->set(0);
+  //uniform = glGetUniformLocationARB(shader->getProgram(), "reflection");
+  //glUniform1iARB(uniform, 0); //second paramter is the texture unit
 
   // Set the variable "refraction" to correspond to the second texture unit
-  uniform = glGetUniformLocationARB(shader->getProgram(), "refraction");
-  glUniform1iARB(uniform, 1);
+ // uni = new Shader::Uniform (shader, "refraction");
+ // uni->set(1);
+  //uniform = glGetUniformLocationARB(shader->getProgram(), "refraction");
+  //glUniform1iARB(uniform, 1);
 
   // Set the variable "normalMap" to correspond to the third texture unit
-  uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap");
-  glUniform1iARB(uniform, 2);
+  uni = new Shader::Uniform (shader, "normalMap");
+  uni->set(2);
+  //uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap");
+  //glUniform1iARB(uniform, 2);
 
   // Set the variable "dudvMap" to correspond to the fourth texture unit
-  uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap");
-  glUniform1iARB(uniform, 3);
+  uni = new Shader::Uniform (shader, "dudvMap");
+  uni->set(3);
+  //uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap");
+  //glUniform1iARB(uniform, 3);
 
   // Set the variable "depthMap" to correspond to the fifth texture unit
-  uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap");
-  glUniform1iARB(uniform, 4);
+ // uni = new Shader::Uniform (shader, "depthMap");
+ // uni->set(4);
+  //uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap");
+  //glUniform1iARB(uniform, 4);
   // FIXME we dont have a depthMap yet :-(
 
@@ -177,7 +187,5 @@
 
 
-  float move2 = this->move * this->kNormalMapScale;
-  float refrUV = this->g_WaterUV;
-  float normalUV = this->g_WaterUV * this->kNormalMapScale;
+
 
 
@@ -219,4 +227,6 @@
 
 
+  Material::unselect();
+
   glPopMatrix();
 }
@@ -225,4 +235,7 @@
 {
   this->move += this->g_WaterFlow = 0.004;
+  this->move2 = this->move * this->kNormalMapScale;
+  this->refrUV = this->g_WaterUV;
+  this->normalUV = this->g_WaterUV * this->kNormalMapScale;
 }
 
Index: branches/water/src/world_entities/environments/mapped_water.h
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.h	(revision 7981)
+++ branches/water/src/world_entities/environments/mapped_water.h	(revision 7982)
@@ -40,4 +40,7 @@
     float           kNormalMapScale;
     float           g_WaterFlow;
+    float           move2;
+    float           refrUV;
+    float           normalUV;
 
     int             textureSize;                //!< size of the texture
