Index: simgear/scene/material/Effect.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/material/Effect.cxx,v
retrieving revision 1.12
diff -u -p -r1.12 Effect.cxx
--- simgear/scene/material/Effect.cxx	26 Jul 2009 18:53:53 -0000	1.12
+++ simgear/scene/material/Effect.cxx	30 Jul 2009 19:44:46 -0000
@@ -21,6 +21,7 @@
 #include "Effect.hxx"
 #include "Technique.hxx"
 #include "Pass.hxx"
+#include "Noise.hxx"
 
 #include <algorithm>
 #include <functional>
@@ -44,7 +45,9 @@
 #include <osg/ShadeModel>
 #include <osg/StateSet>
 #include <osg/TexEnv>
+#include <osg/Texture1D>
 #include <osg/Texture2D>
+#include <osg/Texture3D>
 #include <osg/Uniform>
 #include <osg/Vec4d>
 #include <osgUtil/CullVisitor>
@@ -495,6 +498,20 @@ EffectNameValue<TexEnv::Mode> texEnvMode
     {"replace", TexEnv::REPLACE}
 };
 
+/*
+could be used in conjuction with cloneType(), but is that beautiful?
+EffectNameValue<osg::Texture*> texTypes[] =
+{
+    {"1d", new Texture1D},
+    {"2d", new Texture2D},
+//    {"2darray", new Texture2DArray},
+    {"3d", new Texture3D},
+//    {"cubemap", new TextureCubeMap},
+//    {"rectangle", new TextureRectangle},
+//    {"glyph", new GlyphTexture},
+};
+*/
+
 TexEnv* buildTexEnv(Effect* effect, const SGPropertyNode* prop)
 {
     const SGPropertyNode* modeProp = getEffectPropertyChild(effect, prop,
@@ -518,7 +535,7 @@ typedef boost::tuple<string, Texture::Fi
                      Texture::WrapMode, Texture::WrapMode,
                      Texture::WrapMode> TexTuple;
 
-typedef map<TexTuple, ref_ptr<Texture2D> > TexMap;
+typedef map<TexTuple, ref_ptr<Texture> > TexMap;
 
 TexMap texMap;
 
@@ -526,6 +543,10 @@ struct TextureUnitBuilder : PassAttribut
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
                         const osgDB::ReaderWriter::Options* options);
+
+    osg::Image* make3DNoiseImage(int texSize);
+
+    osg::Texture3D* make3DNoiseTexture(int texSize);
 };
 
 void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
@@ -533,58 +554,73 @@ void TextureUnitBuilder::buildAttribute(
                                         const osgDB::ReaderWriter::Options* options)
 {
     // First, all the texture properties
-    const SGPropertyNode* pTexture2d = prop->getChild("texture2d");
-    if (!pTexture2d)
-        return;
-    const SGPropertyNode* pImage
-        = getEffectPropertyChild(effect, pTexture2d, "image");
-    if (!pImage)
-        return;
-    const char* imageName = pImage->getStringValue();
+    const SGPropertyNode* pType
+        = getEffectPropertyChild(effect, prop, "type");
+    string typeName = "2d";
+    if(pType)
+        typeName = pType->getStringValue();
+
     Texture::FilterMode minFilter = Texture::LINEAR_MIPMAP_LINEAR;
-    findAttr(filterModes, getEffectPropertyChild(effect, pTexture2d, "filter"),
+    findAttr(filterModes, getEffectPropertyChild(effect, prop, "filter"),
              minFilter);
     Texture::FilterMode magFilter = Texture::LINEAR;
-    findAttr(filterModes, getEffectPropertyChild(effect, pTexture2d,
+    findAttr(filterModes, getEffectPropertyChild(effect, prop,
                                                  "mag-filter"),
              magFilter);
     const SGPropertyNode* pWrapS
-        = getEffectPropertyChild(effect, pTexture2d, "wrap-s");
+        = getEffectPropertyChild(effect, prop, "wrap-s");
     Texture::WrapMode sWrap = Texture::CLAMP;
     findAttr(wrapModes, pWrapS, sWrap);
     const SGPropertyNode* pWrapT
-        = getEffectPropertyChild(effect, pTexture2d, "wrap-t");
+        = getEffectPropertyChild(effect, prop, "wrap-t");
     Texture::WrapMode tWrap = Texture::CLAMP;
     findAttr(wrapModes, pWrapT, tWrap);
     const SGPropertyNode* pWrapR
-        = getEffectPropertyChild(effect, pTexture2d, "wrap-r");
+        = getEffectPropertyChild(effect, prop, "wrap-r");
     Texture::WrapMode rWrap = Texture::CLAMP;
     findAttr(wrapModes, pWrapR, rWrap);
+    const SGPropertyNode* pImage
+        = getEffectPropertyChild(effect, prop, "image");
+    if (!pImage) {
+        SG_LOG(SG_INPUT, SG_ALERT,
+               "no image for texture");
+        return;
+    }
+    string imageName = pImage->getStringValue();
     TexTuple tuple(imageName, minFilter, magFilter, sWrap, tWrap, rWrap);
     TexMap::iterator texIter = texMap.find(tuple);
-    Texture2D* texture = 0;
+    Texture* texture = 0;
     if (texIter != texMap.end()) {
         texture = texIter->second.get();
     } else {
-        texture = new Texture2D;
-        osgDB::ReaderWriter::ReadResult result
-            = osgDB::Registry::instance()->readImage(imageName, options);
-        if (result.success()) {
-            osg::Image* image = result.getImage();
-            texture->setImage(image);
-            int s = image->s();
-            int t = image->t();
-
-            if (s <= t && 32 <= s) {
-                SGSceneFeatures::instance()->setTextureCompression(texture);
-            } else if (t < s && 32 <= t) {
-                SGSceneFeatures::instance()->setTextureCompression(texture);
-            }
-            texture->setMaxAnisotropy(SGSceneFeatures::instance()
-                                      ->getTextureFilter());
+        if (imageName == "fg:noise3d") {
+            texture = make3DNoiseTexture(64);
         } else {
-            SG_LOG(SG_INPUT, SG_ALERT, "failed to load effect texture file "
-                   << imageName);
+                if(typeName == "2d")
+                    texture = new Texture2D;
+                else if (typeName == "1d")
+                    texture = new Texture1D;
+                else if (typeName == "3d")
+                    texture = new Texture3D;
+
+                osgDB::ReaderWriter::ReadResult result
+                    = osgDB::Registry::instance()->readImage(imageName, options);
+                if (result.success()) {
+                    osg::Image* image = result.getImage();
+                    texture->setImage(GL_FRONT_AND_BACK, image);
+                    int s = image->s();
+                    int t = image->t();
+                    if (s <= t && 32 <= s) {
+                        SGSceneFeatures::instance()->setTextureCompression(texture);
+                    } else if (t < s && 32 <= t) {
+                        SGSceneFeatures::instance()->setTextureCompression(texture);
+                    }
+                    texture->setMaxAnisotropy(SGSceneFeatures::instance()
+                                              ->getTextureFilter());
+                } else {
+                    SG_LOG(SG_INPUT, SG_ALERT, "failed to load effect texture file "
+                           << imageName);
+                }
         }
         // texture->setDataVariance(osg::Object::STATIC);
         texture->setFilter(Texture::MIN_FILTER, minFilter);
@@ -618,6 +654,64 @@ void TextureUnitBuilder::buildAttribute(
     }
 }
 
+osg::Texture3D* TextureUnitBuilder::make3DNoiseTexture(int texSize)
+{
+    Texture3D* noiseTexture = new osg::Texture3D;
+    noiseTexture->setFilter(osg::Texture3D::MIN_FILTER, osg::Texture3D::LINEAR);
+    noiseTexture->setFilter(osg::Texture3D::MAG_FILTER, osg::Texture3D::LINEAR);
+    noiseTexture->setWrap(osg::Texture3D::WRAP_S, osg::Texture3D::REPEAT);
+    noiseTexture->setWrap(osg::Texture3D::WRAP_T, osg::Texture3D::REPEAT);
+    noiseTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture3D::REPEAT);
+    noiseTexture->setImage( make3DNoiseImage(texSize) );
+    return noiseTexture;
+}
+
+osg::Image* TextureUnitBuilder::make3DNoiseImage(int texSize)
+{
+    osg::Image* image = new osg::Image;
+    image->setImage(texSize, texSize, texSize,
+            4, GL_RGBA, GL_UNSIGNED_BYTE,
+            new unsigned char[4 * texSize * texSize * texSize],
+            osg::Image::USE_NEW_DELETE);
+
+    const int startFrequency = 4;
+    const int numOctaves = 4;
+
+    int f, i, j, k, inc;
+    double ni[3];
+    double inci, incj, inck;
+    int frequency = startFrequency;
+    GLubyte *ptr;
+    double amp = 0.5;
+
+    osg::notify(osg::WARN) << "creating 3D noise texture... ";
+
+    for (f = 0, inc = 0; f < numOctaves; ++f, frequency *= 2, ++inc, amp *= 0.5)
+    {
+        SetNoiseFrequency(frequency);
+        ptr = image->data();
+        ni[0] = ni[1] = ni[2] = 0;
+
+        inci = 1.0 / (texSize / frequency);
+        for (i = 0; i < texSize; ++i, ni[0] += inci)
+        {
+            incj = 1.0 / (texSize / frequency);
+            for (j = 0; j < texSize; ++j, ni[1] += incj)
+            {
+                inck = 1.0 / (texSize / frequency);
+                for (k = 0; k < texSize; ++k, ni[2] += inck, ptr += 4)
+                {
+                    *(ptr+inc) = (GLubyte) (((noise3(ni) + 1.0) * amp) * 128.0);
+                }
+            }
+        }
+    }
+
+    osg::notify(osg::WARN) << "DONE" << std::endl;
+    return image;
+}
+
+
 InstallAttributeBuilder<TextureUnitBuilder> textureUnitBuilder("texture-unit");
 
 typedef map<string, ref_ptr<Program> > ProgramMap;
@@ -626,6 +720,18 @@ ProgramMap programMap;
 typedef map<string, ref_ptr<Shader> > ShaderMap;
 ShaderMap shaderMap;
 
+void reload_shaders()
+{
+    for(ShaderMap::iterator sitr = shaderMap.begin(); sitr != shaderMap.end(); ++sitr)
+    {
+	Shader *shader = sitr->second.get();
+        string fileName = osgDB::findDataFile(sitr->first);
+        if (!fileName.empty()) {
+	    shader->loadShaderSourceFromFile(fileName);
+        }
+    }
+}
+
 struct ShaderProgramBuilder : PassAttributeBuilder
 {
     void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
@@ -662,6 +768,7 @@ void ShaderProgramBuilder::buildAttribut
         program = pitr->second.get();
     } else {
         program = new Program;
+        program->setName(programKey);
         // Add vertex shaders, then fragment shaders
         PropertyList& pvec = pVertShaders;
         Shader::Type stype = Shader::VERTEX;
@@ -678,8 +785,8 @@ void ShaderProgramBuilder::buildAttribut
                     if (!fileName.empty()) {
                         ref_ptr<Shader> shader = new Shader(stype);
                         if (shader->loadShaderSourceFromFile(fileName)) {
-                            shaderMap.insert(make_pair(shaderName, shader));
                             program->addShader(shader.get());
+                            shaderMap.insert(make_pair(shaderName, shader));
                         }
                     }
                 }
Index: simgear/scene/material/Makefile.am
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/material/Makefile.am,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.am
--- simgear/scene/material/Makefile.am	15 Jul 2009 23:11:15 -0000	1.7
+++ simgear/scene/material/Makefile.am	30 Jul 2009 19:44:46 -0000
@@ -25,6 +25,7 @@ libsgmaterial_a_SOURCES = \
 	makeEffect.cxx \
 	mat.cxx \
 	matlib.cxx \
-	matmodel.cxx
+	matmodel.cxx \
+	Noise.cpp
 
 INCLUDES = -I$(top_srcdir)
Index: simgear/scene/material/Noise.cpp
===================================================================
RCS file: simgear/scene/material/Noise.cpp
diff -N simgear/scene/material/Noise.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ simgear/scene/material/Noise.cpp	30 Jul 2009 19:44:46 -0000
@@ -0,0 +1,287 @@
+/* OpenSceneGraph example, osgshaders.
+*
+*  Permission is hereby granted, free of charge, to any person obtaining a copy
+*  of this software and associated documentation files (the "Software"), to deal
+*  in the Software without restriction, including without limitation the rights
+*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*  copies of the Software, and to permit persons to whom the Software is
+*  furnished to do so, subject to the following conditions:
+*
+*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+*  THE SOFTWARE.
+*/
+
+/************************************************************************
+ *                                                                      *
+ *                   Copyright (C) 2002  3Dlabs Inc. Ltd.               *
+ *                                                                      *
+ ************************************************************************/
+
+#include <math.h>
+#include <stdlib.h>
+
+/* Coherent noise function over 1, 2 or 3 dimensions */
+/* (copyright Ken Perlin) */
+
+#define MAXB 0x100
+#define N 0x1000
+#define NP 12   /* 2^N */
+#define NM 0xfff
+
+#define s_curve(t) ( t * t * (3. - 2. * t) )
+#define lerp(t, a, b) ( a + t * (b - a) )
+#define setup(i,b0,b1,r0,r1)\
+        t = vec[i] + N;\
+        b0 = ((int)t) & BM;\
+        b1 = (b0+1) & BM;\
+        r0 = t - (int)t;\
+        r1 = r0 - 1.;
+#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
+#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
+
+static void initNoise(void);
+
+static int p[MAXB + MAXB + 2];
+static double g3[MAXB + MAXB + 2][3];
+static double g2[MAXB + MAXB + 2][2];
+static double g1[MAXB + MAXB + 2];
+
+int start;
+int B;
+int BM;
+
+
+void SetNoiseFrequency(int frequency)
+{
+        start = 1;
+        B = frequency;
+        BM = B-1;
+}
+
+double noise1(double arg)
+{
+   int bx0, bx1;
+   double rx0, rx1, sx, t, u, v, vec[1];
+
+   vec[0] = arg;
+   if (start) {
+      start = 0;
+      initNoise();
+   }
+
+   setup(0,bx0,bx1,rx0,rx1);
+
+   sx = s_curve(rx0);
+   u = rx0 * g1[ p[ bx0 ] ];
+   v = rx1 * g1[ p[ bx1 ] ];
+
+   return(lerp(sx, u, v));
+}
+
+double noise2(double vec[2])
+{
+   int bx0, bx1, by0, by1, b00, b10, b01, b11;
+   double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
+   int i, j;
+
+   if (start) {
+      start = 0;
+      initNoise();
+   }
+
+   setup(0, bx0,bx1, rx0,rx1);
+   setup(1, by0,by1, ry0,ry1);
+
+   i = p[ bx0 ];
+   j = p[ bx1 ];
+
+   b00 = p[ i + by0 ];
+   b10 = p[ j + by0 ];
+   b01 = p[ i + by1 ];
+   b11 = p[ j + by1 ];
+
+   sx = s_curve(rx0);
+   sy = s_curve(ry0);
+
+   q = g2[ b00 ] ; u = at2(rx0,ry0);
+   q = g2[ b10 ] ; v = at2(rx1,ry0);
+   a = lerp(sx, u, v);
+
+   q = g2[ b01 ] ; u = at2(rx0,ry1);
+   q = g2[ b11 ] ; v = at2(rx1,ry1);
+   b = lerp(sx, u, v);
+
+   return lerp(sy, a, b);
+}
+
+double noise3(double vec[3])
+{
+   int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
+   double rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v;
+   int i, j;
+
+   if (start) {
+      start = 0;
+      initNoise();
+   }
+
+   setup(0, bx0,bx1, rx0,rx1);
+   setup(1, by0,by1, ry0,ry1);
+   setup(2, bz0,bz1, rz0,rz1);
+
+   i = p[ bx0 ];
+   j = p[ bx1 ];
+
+   b00 = p[ i + by0 ];
+   b10 = p[ j + by0 ];
+   b01 = p[ i + by1 ];
+   b11 = p[ j + by1 ];
+
+   t  = s_curve(rx0);
+   sy = s_curve(ry0);
+   sz = s_curve(rz0);
+
+   q = g3[ b00 + bz0 ] ; u = at3(rx0,ry0,rz0);
+   q = g3[ b10 + bz0 ] ; v = at3(rx1,ry0,rz0);
+   a = lerp(t, u, v);
+
+   q = g3[ b01 + bz0 ] ; u = at3(rx0,ry1,rz0);
+   q = g3[ b11 + bz0 ] ; v = at3(rx1,ry1,rz0);
+   b = lerp(t, u, v);
+
+   c = lerp(sy, a, b);
+
+   q = g3[ b00 + bz1 ] ; u = at3(rx0,ry0,rz1);
+   q = g3[ b10 + bz1 ] ; v = at3(rx1,ry0,rz1);
+   a = lerp(t, u, v);
+
+   q = g3[ b01 + bz1 ] ; u = at3(rx0,ry1,rz1);
+   q = g3[ b11 + bz1 ] ; v = at3(rx1,ry1,rz1);
+   b = lerp(t, u, v);
+
+   d = lerp(sy, a, b);
+
+   //fprintf(stderr, "%f\n", lerp(sz, c, d));
+
+   return lerp(sz, c, d);
+}
+
+void normalize2(double v[2])
+{
+   double s;
+
+   s = sqrt(v[0] * v[0] + v[1] * v[1]);
+   v[0] = v[0] / s;
+   v[1] = v[1] / s;
+}
+
+void normalize3(double v[3])
+{
+   double s;
+
+   s = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
+   v[0] = v[0] / s;
+   v[1] = v[1] / s;
+   v[2] = v[2] / s;
+}
+
+void initNoise(void)
+{
+   int i, j, k;
+
+   srand(30757);
+   for (i = 0 ; i < B ; i++) {
+      p[i] = i;
+      g1[i] = (double)((rand() % (B + B)) - B) / B;
+
+      for (j = 0 ; j < 2 ; j++)
+         g2[i][j] = (double)((rand() % (B + B)) - B) / B;
+      normalize2(g2[i]);
+
+      for (j = 0 ; j < 3 ; j++)
+         g3[i][j] = (double)((rand() % (B + B)) - B) / B;
+      normalize3(g3[i]);
+   }
+
+   while (--i) {
+      k = p[i];
+      p[i] = p[j = rand() % B];
+      p[j] = k;
+   }
+
+   for (i = 0 ; i < B + 2 ; i++) {
+      p[B + i] = p[i];
+      g1[B + i] = g1[i];
+      for (j = 0 ; j < 2 ; j++)
+         g2[B + i][j] = g2[i][j];
+      for (j = 0 ; j < 3 ; j++)
+         g3[B + i][j] = g3[i][j];
+   }
+}
+
+/* --- My harmonic summing functions - PDB --------------------------*/
+
+/*
+   In what follows "alpha" is the weight when the sum is formed.
+   Typically it is 2, As this approaches 1 the function is noisier.
+   "beta" is the harmonic scaling/spacing, typically 2.
+*/
+
+double PerlinNoise1D(double x,double alpha,double beta,int n)
+{
+   int i;
+   double val,sum = 0;
+   double p,scale = 1;
+
+   p = x;
+   for (i=0;i<n;i++) {
+      val = noise1(p);
+      sum += val / scale;
+      scale *= alpha;
+      p *= beta;
+   }
+   return(sum);
+}
+
+double PerlinNoise2D(double x,double y,double alpha,double beta,int n)
+{
+   int i;
+   double val,sum = 0;
+   double p[2],scale = 1;
+
+   p[0] = x;
+   p[1] = y;
+   for (i=0;i<n;i++) {
+      val = noise2(p);
+      sum += val / scale;
+      scale *= alpha;
+      p[0] *= beta;
+      p[1] *= beta;
+   }
+   return(sum);
+}
+
+double PerlinNoise3D(double x,double y,double z,double alpha,double beta,int n)
+{
+   int i;
+   double val,sum = 0;
+   double p[3],scale = 1;
+
+   p[0] = x;
+   p[1] = y;
+   p[2] = z;
+   for (i=0;i<n;i++) {
+      val = noise3(p);
+      sum += val / scale;
+      scale *= alpha;
+      p[0] *= beta;
+      p[1] *= beta;
+      p[2] *= beta;
+   }
+   return(sum);
+}
Index: simgear/scene/material/Noise.hxx
===================================================================
RCS file: simgear/scene/material/Noise.hxx
diff -N simgear/scene/material/Noise.hxx
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ simgear/scene/material/Noise.hxx	30 Jul 2009 19:44:46 -0000
@@ -0,0 +1,51 @@
+/* -*-c++-*-
+*
+*  OpenSceneGraph example, osgshaders.
+*
+*  Permission is hereby granted, free of charge, to any person obtaining a copy
+*  of this software and associated documentation files (the "Software"), to deal
+*  in the Software without restriction, including without limitation the rights
+*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*  copies of the Software, and to permit persons to whom the Software is
+*  furnished to do so, subject to the following conditions:
+*
+*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+*  THE SOFTWARE.
+*/
+
+
+/************************************************************************
+ *                                                                      *
+ *                   Copyright (C) 2002  3Dlabs Inc. Ltd.               *
+ *                                                                      *
+ ***********************************************************************/
+
+#ifndef __ogl2_demo_h__
+#define __ogl2_demo_h__
+
+
+extern void SetNoiseFrequency(int frequency);
+
+extern double noise1(double arg);
+extern double noise2(double vec[2]);
+extern double noise3(double vec[3]);
+extern void normalize2(double vec[2]);
+extern void normalize3(double vec[3]);
+
+/*
+   In what follows "alpha" is the weight when the sum is formed.
+   Typically it is 2, As this approaches 1 the function is noisier.
+   "beta" is the harmonic scaling/spacing, typically 2.
+*/
+
+extern double PerlinNoise1D(double x,double alpha, double beta, int n);
+extern double PerlinNoise2D(double x,double y,double alpha, double beta, int n);
+extern double PerlinNoise3D(double x,double y,double z,double alpha, double beta, int n);
+
+
+#endif // __ogl2_demo_h__
Index: simgear/scene/material/makeEffect.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/material/makeEffect.cxx,v
retrieving revision 1.3
diff -u -p -r1.3 makeEffect.cxx
--- simgear/scene/material/makeEffect.cxx	26 Jul 2009 18:54:17 -0000	1.3
+++ simgear/scene/material/makeEffect.cxx	30 Jul 2009 19:44:46 -0000
@@ -134,8 +134,10 @@ Effect* makeEffect(const string& name,
     effectFileName += ".eff";
     string absFileName
         = osgDB::findDataFile(effectFileName, options);
-    if (absFileName.empty())
+    if (absFileName.empty()) {
+        SG_LOG(SG_INPUT, SG_WARN, "can't find \"" << effectFileName << "\"");
         return 0;
+    }
     SGPropertyNode_ptr effectProps = new SGPropertyNode();
     readProperties(absFileName, effectProps.ptr(), 0, true);
     Effect* result = makeEffect(effectProps.ptr(), realizeTechniques, options);
@@ -179,9 +181,15 @@ Effect* makeEffect(SGPropertyNode* prop,
     if (inheritProp) {
         parent = makeEffect(inheritProp->getStringValue(), realizeTechniques,
                             options);
-        effect->root = new SGPropertyNode;
-        mergePropertyTrees(effect->root, prop, parent->root);
-        effect->root->removeChild("inherits-from");
+        if(parent)
+        {
+            effect->root = new SGPropertyNode;
+            mergePropertyTrees(effect->root, prop, parent->root);
+            effect->root->removeChild("inherits-from");
+        } else {
+            effect->root = prop;
+            effect->root->removeChild("inherits-from");
+        }
     } else {
         effect->root = prop;
     }
Index: simgear/scene/material/mat.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/material/mat.cxx,v
retrieving revision 1.59
diff -u -p -r1.59 mat.cxx
--- simgear/scene/material/mat.cxx	17 Jul 2009 14:21:50 -0000	1.59
+++ simgear/scene/material/mat.cxx	30 Jul 2009 19:44:46 -0000
@@ -269,13 +269,12 @@ void SGMaterial::buildEffectProperties(c
         copyProperties(propRoot, effectProp);
         SGPropertyNode* effectParamProp = effectProp->getChild("parameters", 0);
         SGPropertyNode* texProp = makeChild(effectParamProp, "texture");
-        SGPropertyNode* tex2dProp = makeChild(texProp, "texture2d");
-        makeChild(tex2dProp, "image")->setStringValue(matState.texture_path);
-        makeChild(tex2dProp, "filter")
+        makeChild(texProp, "image")->setStringValue(matState.texture_path);
+        makeChild(texProp, "filter")
             ->setStringValue(mipmap ? "linear-mipmap-linear" : "nearest");
-        makeChild(tex2dProp, "wrap-s")
+        makeChild(texProp, "wrap-s")
             ->setStringValue(wrapu ? "repeat" : "clamp");
-        makeChild(tex2dProp, "wrap-t")
+        makeChild(texProp, "wrap-t")
             ->setStringValue(wrapv ? "repeat" : "clamp");
         matState.effect = makeEffect(effectProp, false, options);
         matState.effect->setUserData(user.get());
Index: simgear/scene/material/mat.hxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/material/mat.hxx,v
retrieving revision 1.42
diff -u -p -r1.42 mat.hxx
--- simgear/scene/material/mat.hxx	16 Jul 2009 16:35:16 -0000	1.42
+++ simgear/scene/material/mat.hxx	30 Jul 2009 19:44:46 -0000
@@ -55,6 +55,7 @@ class StateSet;
 namespace simgear
 {
 class Effect;
+void reload_shaders();
 }
 
 class SGMaterialGlyph;

