Index: experimental/distortionNG/DistortionManipulator.cpp
===================================================================
--- experimental/distortionNG/DistortionManipulator.cpp	(revision 360)
+++ experimental/distortionNG/DistortionManipulator.cpp	(revision 361)
@@ -23,4 +23,8 @@
 #include <osg/PolygonMode>
 
+#include <osgDB/Registry>
+#include <osgDB/ReaderWriter>
+#include <osgDB/WriteFile>
+
 using namespace osg;
 using namespace osgViewer;
@@ -42,4 +46,9 @@
 	_camera = 0;
 	//_distortionMesh(distortionMesh)
+
+	// Create Shader to vizualize intensitymap during blending setup.
+	osg::Shader* sh = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, "shaderIntensityMapVis.frag" ); 
+	sh->setName("shaderIntensityMapVis");
+	ds->setShaderIntensityMapVis( sh );
 }
 
@@ -96,5 +105,5 @@
 		{
 			OSG_ALWAYS<<"mouse click!"<<std::endl;
-			if ( activeSetupMode == MANUAL /*&& ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL*/ && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
+ 			if ( activeSetupMode == MANUAL /*&& ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL*/ && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
 			{
 				osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
@@ -210,4 +219,63 @@
 			{
 				OSG_ALWAYS<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl;
+
+
+
+	// Configure Compression and instantiate read/write-options
+	bool asAscii_ = true;
+	bool compressionEnabled = false;
+
+	std::string readOptionString = "";
+	std::string writeOptionString = "";
+	if(asAscii_)
+	{
+		readOptionString = "Ascii";
+		writeOptionString = "Ascii";
+	}
+	if (compressionEnabled)
+		writeOptionString+=" Compressor=zlib";
+	
+	osg::ref_ptr<osgDB::Options> readOptions = new osgDB::Options( readOptionString.c_str() );
+	osg::ref_ptr<osgDB::Options> writeOptions = new osgDB::Options( writeOptionString.c_str() );
+
+	//// Get ReaderWriter
+	//osg::ref_ptr<osgDB::ReaderWriter> rw = osgDB::Registry::instance()->getReaderWriterForExtension("osgb");	
+
+	//// Writing node to stream
+	//std::stringstream myOstream;
+	//if ( rw )
+	//{
+	//	osgDB::ReaderWriter::WriteResult wr = rw->writeObject( *_distortionSet, myOstream, writeOptions );
+	//	if (wr.success() )			
+	//	{
+	//		OSG_ALWAYS<<"write node success"<<std::endl;
+	//	}
+	//	else
+	//	{
+	//		OSG_ALWAYS<<"write node failed"<<std::endl;
+	//	}
+	//}
+
+	if( osgDB::writeObjectFile(*_distortionSet, "test.osgt", writeOptions) )
+	{
+		OSG_ALWAYS<<"write node success"<<std::endl;
+	}
+	else
+	{
+		OSG_ALWAYS<<"write node failed"<<std::endl;
+	}
+
+
+
+
+
+
+
+
+
+
+
+
+
 				return(true);
 			}
@@ -277,5 +345,5 @@
     {
         polyModeObj = new osg::PolygonMode;
-        stateset->setAttribute(polyModeObj);
+        stateset->setAttribute(polyModeObj, osg::StateAttribute::PROTECTED|osg::StateAttribute::ON);
     }
  
@@ -289,8 +357,20 @@
 void DistortionManipulator::showIntensityMap(bool show)
 {
-		OSG_ALWAYS<<"ToDo: showIntensityMap(bool) is now "<<show<<std::endl;
-
-		if(_distortionSet.valid())
-			_distortionSet->setShowIntensityMapOnly(show);
+	if(_distortionSet.valid())
+	{
+		osg::StateSet* stateset = _distortionSet->getDistortionInternals()->getChild(DistortionSet::MESH)->getOrCreateStateSet();
+		osg::Program* program = static_cast<osg::Program*>(stateset->getAttribute(::osg::StateAttribute::PROGRAM));
+
+		if(show)
+		{
+			program->removeShader( _distortionSet->getShaderIntensityMap() );
+			program->addShader( _distortionSet->getShaderIntensityMapVis() );
+		}
+		else
+		{
+			program->removeShader( _distortionSet->getShaderIntensityMapVis() );
+			program->addShader( _distortionSet->getShaderIntensityMap() );
+		}
+	}
 }
 
Index: experimental/distortionNG/DistortionSet.cpp
===================================================================
--- experimental/distortionNG/DistortionSet.cpp	(revision 360)
+++ experimental/distortionNG/DistortionSet.cpp	(revision 361)
@@ -41,4 +41,5 @@
 
 	_distortionInternals = new osg::Switch();
+
 }
 
Index: experimental/distortionNG/DistortionSet.h
===================================================================
--- experimental/distortionNG/DistortionSet.h	(revision 360)
+++ experimental/distortionNG/DistortionSet.h	(revision 361)
@@ -61,5 +61,8 @@
 	osg::Switch* getDistortionInternals()	{ return _distortionInternals; }
 
-
+	osg::Shader* getShaderIntensityMap()	{ return shaderIntensityMap; }
+	void setShaderIntensityMap(osg::Shader* shader)	{ shaderIntensityMap = shader; }
+	osg::Shader* getShaderIntensityMapVis()	{ return shaderIntensityMapVis; }
+	void setShaderIntensityMapVis(osg::Shader* shader)	{ shaderIntensityMapVis = shader; }
 
 
@@ -113,4 +116,7 @@
 	osg::observer_ptr<osg::Camera> _camera;	// is used to pass the distortion cam from osgViewers setupDistortion() method to the manipulator.
 	osg::ref_ptr<osg::Switch> _distortionInternals;	// definition: child #0 = mesh, #1 = highlighter, #2 HUD
+
+	osg::ref_ptr<osg::Shader> shaderIntensityMap;	// used in 99%, it provides active intensity map blending
+	osg::ref_ptr<osg::Shader> shaderIntensityMapVis;	// only used during setup process, this shaders discards the fragment color and only displays the intensitymapcolor to visualize the blendmap
 };
 
Index: experimental/distortionNG/distortionNG.vcproj
===================================================================
--- experimental/distortionNG/distortionNG.vcproj	(revision 360)
+++ experimental/distortionNG/distortionNG.vcproj	(revision 361)
@@ -375,9 +375,9 @@
 		</Filter>
 		<File
-			RelativePath=".\shader.frag"
+			RelativePath=".\shaderIntensityMap.frag"
 			>
 		</File>
 		<File
-			RelativePath=".\shader.vert"
+			RelativePath=".\shaderIntensityMapVis.frag"
 			>
 		</File>
Index: experimental/distortionNG/extViewer.cpp
===================================================================
--- experimental/distortionNG/extViewer.cpp	(revision 360)
+++ experimental/distortionNG/extViewer.cpp	(revision 361)
@@ -41,7 +41,32 @@
 	// Add help for command-line options here
     arguments.getApplicationUsage()->addCommandLineOption("--distort","load distortion file and set up geometrical distortion for viewer. This includes blending");
-    arguments.getApplicationUsage()->addCommandLineOption("--blend","Set up viewer vor simple blending CullDrawThreadPerContext threading model for viewer.");
-
-	osgDB::Registry::instance()->addFileExtensionAlias("dist", "osgt");
+    arguments.getApplicationUsage()->addCommandLineOption("--blend","Set up viewer for simple intensity map blending.");
+
+	std::string distortionSetFilename = "";
+	std::string intensityMapFilename = "";
+	while( arguments.read("--blend",intensityMapFilename) ) {}
+	while( arguments.read("--distort",distortionSetFilename) ) {}
+
+	if( !intensityMapFilename.empty() )
+	{
+		OSG_ALWAYS<<"Pure blendmap setup with : "<<intensityMapFilename<<std::endl;
+		setUpIntensityMapBlending(intensityMapFilename);
+	}
+	else if( !distortionSetFilename.empty() )
+	{
+		OSG_ALWAYS<<"Set up distortion by loaded distortionSet: "<<distortionSetFilename<<std::endl;
+
+		osg::Object* distSet = osgDB::readObjectFile( distortionSetFilename );
+		if( distSet != NULL )
+		{
+			OSG_ALWAYS<<"read distortionSet success"<<std::endl;
+			setUpViewForManualDistortion(static_cast<osgViewer::DistortionSet*>(distSet));
+		}
+		else
+		{
+			OSG_ALWAYS<<"read distortionSet failed"<<std::endl;
+		}
+	}	
+	
 }
 
@@ -236,4 +261,5 @@
 
         addSlave(camera.get(), _distortionSet->getProjectionOffset(), _distortionSet->getViewOffset() );
+
     }
 
@@ -332,13 +358,14 @@
     stateset->setTextureAttributeAndModes(_distortionSet->getTexUnitIntensityMap(), intensityMapTexture, osg::StateAttribute::ON);
 
-	// create shaders for blending
+	// create shader for blending
 	osg::Program* IntensityMapProgram = new osg::Program;
 	IntensityMapProgram->setName( "intensityMapBlending" );
-	osg::Shader* fShader = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, "shader.frag" ); 
-	fShader->setName("intensityMapFragShader");
-
-	if ( fShader )
-	{
-		IntensityMapProgram->addShader( fShader );
+	osg::Shader* shaderIntensityMap = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, "shaderIntensityMap.frag" ); 
+	shaderIntensityMap->setName("shaderIntensityMap");
+	_distortionSet->setShaderIntensityMap( shaderIntensityMap );
+
+	if ( shaderIntensityMap )
+	{
+		IntensityMapProgram->addShader( shaderIntensityMap );
 		stateset->addUniform( new osg::Uniform("sceneTexture", (int)_distortionSet->getTexUnitScene()) );
 		stateset->addUniform( new osg::Uniform("intensityMapTexture", (int)_distortionSet->getTexUnitIntensityMap()) );
Index: experimental/distortionNG/main.cpp
===================================================================
--- experimental/distortionNG/main.cpp	(revision 360)
+++ experimental/distortionNG/main.cpp	(revision 361)
@@ -56,5 +56,4 @@
 	viewer.setUpViewForManualDistortion(_distortionSet, 0);
    
-	//viewer.setUpIntensityMapBlending("intensitymap.png");
 
 	// set up the camera manipulators.
@@ -88,5 +87,6 @@
     // add the state manipulator
     viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
-
+	//viewer.addEventHandler( new osgGA::StateSetManipulator);
+	
     // add the stats handler
     viewer.addEventHandler(new osgViewer::StatsHandler);
@@ -118,10 +118,9 @@
 		if(!rootnode)
 		{
-			osg::notify(osg::WARN)<<"Warning: no valid data loaded, please specify a database on the command line."<<std::endl;
+			OSG_WARN<<"Warning: no valid data loaded, please specify a database on the command line."<<std::endl;
 			return 1;
 		}
     }
-	viewer.setSceneData( rootnode );
-	
+
 	// run the viewers main loop
 	return viewer.run();
@@ -150,6 +149,6 @@
  * modul								Funktionen / Description
  * 
- * [postponed] plugin .dist				load / Save distContainers					loads and saves via serializers the distortion container from/to file. Can potentially be replaced by a simple extension alias to osgt|b|x
- * 
+ * [postponed] plugin .dist				load / Save distContainers					loads and saves via serializers the distortion container from/to file.
+ *  
  * 
  * [done] Distortion Container					Beinhaltet die folgenden Distortion Details:
@@ -174,5 +173,5 @@
  * distortionManipulator				abgeleitet von osgGA::GUIEventHandler
  *										Grundfunktionen:
- *							[done|.|.]	- Key to Show Distortion Mesh / Intensity Map / none
+ *							[done]		- Key to Show Distortion Mesh / Intensity Map / none
  *										- Key to Save distortion Container  - via plugin
  *							[.]		- Key to toggle MANUAL mode between blending und distortion setup
@@ -199,6 +198,4 @@
  * speichern des containers in ein .dist file
  * Laden des Containers.
- * osgviewer setup fit machen: simple distortion ( nur rows, colums und optional blendmap ist angegeben
- * shaderwechsel funktioniert, so dass die reine blendmap angezeigt werden kann.
  * reset distortion funktioniert.
  * statesetmanipulator muss auf die scene, nicht auf mesh losgehen.
