Index: /Swollen/distros/windistro.py
===================================================================
--- /Swollen/distros/windistro.py	(revision 104)
+++ /Swollen/distros/windistro.py	(revision 105)
@@ -37,6 +37,6 @@
 # sample sww file for testing
 localtestdir = localrootdir + os.sep + 'tests'
-localfiles.append(localtestdir + os.sep + 'cylinders2.sww')
-localfiles.append(localtestdir + os.sep + 'cylinders2.tif')
+localfiles.append(localtestdir + os.sep + 'cylinders.sww')
+localfiles.append(localtestdir + os.sep + 'cylinders.tif')
 
 
Index: /Swollen/include/swwreader.h
===================================================================
--- /Swollen/include/swwreader.h	(revision 104)
+++ /Swollen/include/swwreader.h	(revision 105)
@@ -87,13 +87,17 @@
     virtual unsigned int getNumberOfTimesteps() {return _ntimesteps;}
 
-    virtual float getAlphaMin() {return _alphamin;}    
-    virtual float getAlphaMax() {return _alphamax;}    
-    virtual float getHeightMin() {return _heightmin;}        
-    virtual float getHeightMax() {return _heightmax;}            
+    virtual float getAlphaMin() {return _alphamin;}
+    virtual float getAlphaMax() {return _alphamax;}
+    virtual float getHeightMin() {return _heightmin;}
+    virtual float getHeightMax() {return _heightmax;}
+    virtual float getCullAngle() {return _cullangle;}
 
-    virtual void setAlphaMin( float value ) {_alphamin = value;}    
-    virtual void setAlphaMax( float value ) {_alphamax = value;}        
-    virtual void setHeightMin( float value ) {_heightmin = value;}     
-    virtual void setHeightMax( float value ) {_heightmax = value;}        
+    virtual void setAlphaMin( float value ) {_alphamin = value;}
+    virtual void setAlphaMax( float value ) {_alphamax = value;}
+    virtual void setHeightMin( float value ) {_heightmin = value;}
+    virtual void setHeightMax( float value ) {_heightmax = value;}
+
+    virtual void setCullAngle( float value ) {_cullangle = value;}
+    virtual void toggleCulling() {_culling = _culling ? false : true;}
     
     virtual triangle_list getConnectivity(unsigned int index) {return _connectivity.at(index);}
@@ -145,9 +149,9 @@
     struct
     {
-	bool hasData;
-	int xresolution, yresolution;
-	float xorigin, yorigin;
-	float xpixel, ypixel;
-	float rotation;
+        bool hasData;
+        int xresolution, yresolution;
+        float xorigin, yorigin;
+        float xpixel, ypixel;
+        float rotation;
     } _bedslopegeodata;
 
@@ -174,4 +178,8 @@
     float _alphamax, _alphamin, _heightmax, _heightmin;
 
+    // cull triangles with steepness angle above this value
+    float _cullangle;
+    bool _culling;
+
 };
 
Index: /Swollen/swollen/main.cpp
===================================================================
--- /Swollen/swollen/main.cpp	(revision 104)
+++ /Swollen/swollen/main.cpp	(revision 105)
@@ -47,4 +47,5 @@
     arguments.getApplicationUsage()->addCommandLineOption("-lightpos <float>,<float>,<float>","x,y,z of bedslope directional light (z is up, default is overhead)");
     arguments.getApplicationUsage()->addCommandLineOption("-nosky","Omit background sky");
+    arguments.getApplicationUsage()->addCommandLineOption("-cullangle <float angle 0-90>","Cull triangles steeper than this value");
     arguments.getApplicationUsage()->addCommandLineOption("-texture <file>","Image to use for bedslope topography");
     arguments.getApplicationUsage()->addCommandLineOption("-version","Revision number and creation (not compile) date");
@@ -104,4 +105,5 @@
     if( arguments.read("-alphamin",tmpfloat) ) sww->setAlphaMin( tmpfloat );   
     if( arguments.read("-alphamax",tmpfloat) ) sww->setAlphaMax( tmpfloat );
+    if( arguments.read("-cullangle",tmpfloat) ) sww->setCullAngle( tmpfloat );
 
     std::string bedslopetexture;
@@ -202,4 +204,5 @@
         viewer.sync();
 
+
         // current time
         double time = viewer.getFrameStamp()->getReferenceTime();
@@ -219,6 +222,8 @@
 
         if( event_handler->toggleCulling() )
-            std::cout << "toggle culling" << std::endl;
-
+        {
+            sww->toggleCulling();
+            water->setTimeStep(timestep);  // refresh
+        }
 
         // update the scene by traversing with the update visitor 
Index: /Swollen/swollen/watersurface.cpp
===================================================================
--- /Swollen/swollen/watersurface.cpp	(revision 104)
+++ /Swollen/swollen/watersurface.cpp	(revision 105)
@@ -67,6 +67,6 @@
 
     osg::TexEnv* texenv = new osg::TexEnv;
-    //texenv->setMode( osg::TexEnv::DECAL );
-    texenv->setMode( osg::TexEnv::BLEND );
+    texenv->setMode( osg::TexEnv::DECAL );
+    //texenv->setMode( osg::TexEnv::BLEND );
     texenv->setColor( osg::Vec4(0.6f,0.6f,0.6f,0.2f) );
     _stateset->setTextureAttributeAndModes( 1, texgen, osg::StateAttribute::ON );
Index: /Swollen/swwreader/swwreader.cpp
===================================================================
--- /Swollen/swwreader/swwreader.cpp	(revision 104)
+++ /Swollen/swwreader/swwreader.cpp	(revision 105)
@@ -21,4 +21,14 @@
 #include <stdio.h>
 #include <gdal_priv.h>
+
+
+// compile time defaults
+#define DEFAULT_CULLANGLE 85.0
+#define DEFAULT_ALPHAMIN 0.8
+#define DEFAULT_ALPHAMAX 1.0
+#define DEFAULT_HEIGHTMIN 0.0
+#define DEFAULT_HEIGHTMAX 1.0
+#define DEFAULT_BEDSLOPEOFFSET 0.0
+#define DEFAULT_CULLONSTART false
 
 
@@ -108,4 +118,14 @@
     }
 
+
+    // alpha-scaling defaults, can be overridden after construction by command line parameters
+    _alphamin = DEFAULT_ALPHAMIN;
+    _alphamax = DEFAULT_ALPHAMAX;
+    _heightmin = DEFAULT_HEIGHTMIN;
+    _heightmax = DEFAULT_HEIGHTMAX;
+
+    // steepness culling default, can be overridden after construction by command line parameter
+    _cullangle = DEFAULT_CULLANGLE;
+    _culling = DEFAULT_CULLONSTART;
 
     // loop index
@@ -191,5 +211,5 @@
 	_bedslopevertices->push_back( osg::Vec3( (_px[iv]-_xoffset)*_scale - _xcenter, 
 						 (_py[iv]-_yoffset)*_scale - _ycenter, 
-						 (_pz[iv]-_zoffset)*_scale - _zcenter - 0.00) );
+						 (_pz[iv]-_zoffset)*_scale - _zcenter - DEFAULT_BEDSLOPEOFFSET) );
 
     // bedslope index array, pvolumes array indexes into x, y and z
@@ -330,10 +350,4 @@
     osg::ref_ptr<osg::IntArray> steeptri = new osg::IntArray;
 
-    // alpha-scaling defaults
-    _alphamin = 0.8;
-    _alphamax = 1.0;
-    _heightmin = 0.00;
-    _heightmax = 1.0;
-
     // stage heights from netcdf file (x and y are same as bedslope)
     int status = nc_get_vars_float (_ncid, _stageid, start, count, stride, _pstage);
@@ -354,4 +368,7 @@
     unsigned int v1index, v2index, v3index;
 
+    // cullangle given in degrees, test is against dot product
+    float cullthreshold = cos(osg::DegreesToRadians(_cullangle));
+
     // over all stage triangles
     for (iv=0; iv < _nvolumes; iv++)
@@ -378,15 +395,8 @@
         _stageprimitivenormals->push_back( nrm );
 
-        // identify steep triangles
-        if( fabs(nrm * osg::Vec3f(0,0,1)) < 0.4 )
-        {
+        // identify steep triangles, store index
+        if( fabs(nrm * osg::Vec3f(0,0,1)) < cullthreshold )
             steeptri->push_back( iv );
-        }
-    }
-
-
-    int seed = 5;
-    srand(seed);
-    float r, g, b;
+    }
 
     // stage height above bedslope mapped as alpha value
@@ -399,43 +409,34 @@
     for (iv=0; iv < _npoints; iv++)
     {
+        // water height above corresponding bedslope
         height = _stagevertices->at(iv).z() - _bedslopevertices->at(iv).z();
 	
         if (height < _heightmin)
-        {
             alpha = 0.0;
-        } 
         else 
         {
-	        alpha = alphascale * (height - _heightmin) + _alphamin;
+            alpha = alphascale * (height - _heightmin) + _alphamin;
 	        if( alpha > _alphamax ) 
-		    alpha = _alphamax;	  
+                alpha = _alphamax;
         }
 
-        r = ((float) rand())/RAND_MAX;
-        g = ((float) rand())/RAND_MAX;
-        b = ((float) rand())/RAND_MAX;
-        //alpha = ((float) rand())/RAND_MAX;
-        alpha = 0.9;
-        _stagecolors->push_back( osg::Vec4( r, g, b, alpha ) );
-    }
-
-    for (iv=0; iv < steeptri->size() ; iv++)
-    {
-        int tri = steeptri->at(iv);
-        v1index = _pvolumes[3*tri+0];
-        v2index = _pvolumes[3*tri+1];
-        v3index = _pvolumes[3*tri+2];
-
-        r = ((float) rand())/RAND_MAX;
-        g = ((float) rand())/RAND_MAX;
-        b = ((float) rand())/RAND_MAX;
-
-        std::cout << tri << std::endl;
-
-        // FIXME: needs to be an overwrite rather than a push
-        //_stagecolors->push_back( osg::Vec4( 1, 1, 1, alpha ) );
-    }
-
-
+        _stagecolors->push_back( osg::Vec4( 1.0, 1.0, 1.0, alpha ) );
+    }
+
+	// steep triangle vertices should have alpha=0, overwrite such vertex colours
+    if( _culling )
+    {
+        for (iv=0; iv < steeptri->size() ; iv++)
+        {
+            int tri = steeptri->at(iv);
+            v1index = _pvolumes[3*tri+0];
+            v2index = _pvolumes[3*tri+1];
+            v3index = _pvolumes[3*tri+2];
+
+            _stagecolors->at(v1index) = osg::Vec4( 1, 1, 1, 0 );
+            _stagecolors->at(v2index) = osg::Vec4( 1, 1, 1, 0 );
+            _stagecolors->at(v3index) = osg::Vec4( 1, 1, 1, 0 );
+        }
+    }
 
     // per-vertex normals calculated as average of primitive normals
