Index: /experimental/distortionNG/extViewer.cpp
===================================================================
--- /experimental/distortionNG/extViewer.cpp	(revision 332)
+++ /experimental/distortionNG/extViewer.cpp	(revision 333)
@@ -46,6 +46,10 @@
         "void main() \n"
         "{ \n"
-        "    gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; \n"
-		"	 gl_FrontColor = osg_Color;\n"
+        //"    gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; \n"
+		"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"	
+		"	 gl_FrontColor = gl_Color;\n"
+		"	 gl_TexCoord[0] = gl_MultiTexCoord0;	\n"
+//		"	 gl_TexCoord[1] = gl_MultiTexCoord1;	\n"
+		""
 		" \n"
         "} \n";
@@ -61,7 +65,12 @@
         "void main(void) \n"
         "{\n"
-		"	 vec2 texcoord0 = vec2( gl_TexCoord[0] );\n"
-		"	 vec2 texcoord1 = vec2( gl_TexCoord[1] );\n"
-        "    gl_FragColor = texture2D( sceneTexture, texcoord0) * texture2D( sceneTexture, texcoord0); \n"
+		"	vec4 distortColor;	\n"
+		"	vec4 blendColor;	\n"
+		"\n"
+		"	distortColor = texture2D(sceneTexture, gl_TexCoord[0]);	\n"
+		//"	blendColor = texture2D(intensityMapTexture, gl_TexCoord[1].st);	\n"
+		"	blendColor = texture2D(intensityMapTexture, gl_FragCoord);	\n"
+		//"    gl_FragColor = vec4( 1.,1.,1.,1.); \n"
+		"gl_FragColor =  blendColor;	\n"
         "}\n";
     osg::Shader* fShader = new osg::Shader( osg::Shader::FRAGMENT, fragmentSource );
@@ -137,5 +146,6 @@
 
 			// Set coordinates for second texcoords array (if applyIntensityMapAsColours==true)
-			if (texcoords1) texcoords1->push_back( texcoord );
+			if (texcoords1) 
+				texcoords1->push_back( texcoord );
 		}
 	}
@@ -149,5 +159,6 @@
 
     geom->setTexCoordArray(0,texcoords0);
-    if (texcoords1) geom->setTexCoordArray(1,texcoords1);
+    if (texcoords1)
+		geom->setTexCoordArray(1,texcoords1);
 
  //   osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
@@ -168,5 +179,4 @@
 	{
 		configureShaders( geom->getOrCreateStateSet() );
-		geom->setInitialBound( osg::BoundingBox(origin, origin+widthVector+heightVector) );
 	}
 
@@ -216,5 +226,5 @@
         return;
     }
-	
+
 	// Set up projection Matrix as it is done in View::setUpViewOnSingleScreen(
 	double fovy, aspectRatio, zNear, zFar;
@@ -273,10 +283,7 @@
     // distortion correction set up.
     {
-        osg::Geode* geode = new osg::Geode();
-		//geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 1, 0.45, intensityMap, projectorMatrix));
-		osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, intensityMap, applyIntensityMapAsColours, projectorMatrix);
-		geode->addDrawable(distortionMesh);
-
-        // new we need to add the scene texture to the mesh, we do so by creating a
+		osg::Geode* geode = new osg::Geode();
+
+		// new we need to add the scene texture to the mesh, we do so by creating a
         // StateSet to contain the Texture StateAttribute.
         osg::StateSet* stateset = geode->getOrCreateStateSet();
@@ -284,12 +291,18 @@
         stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
 
-        osg::TexMat* texmat = new osg::TexMat;
+		osg::TexMat* texmat = new osg::TexMat;
         texmat->setScaleByTextureRectangleSize(true);
         stateset->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON);
 
-        if (!applyIntensityMapAsColours && intensityMap)
+		// If the intensityMap is used but not applyIntensityMapAsColours: Apply intensityMap as intensityMapTexture on unit 1
+		if (!applyIntensityMapAsColours && intensityMap)
         {
             stateset->setTextureAttributeAndModes(1, new osg::Texture2D(intensityMap), osg::StateAttribute::ON);
         }
+
+        //geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 1, 0.45, intensityMap, projectorMatrix));
+		osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, intensityMap, applyIntensityMapAsColours, projectorMatrix);
+		geode->addDrawable(distortionMesh);
+
 
         osg::ref_ptr<osg::Camera> camera = new osg::Camera;
@@ -309,19 +322,16 @@
         camera->setViewMatrix(osg::Matrix::identity());
 
-        // add subgraph to render
-        //camera->addChild(geode);
-
-		// selector
-		geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
-		geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) );
-		osg::ref_ptr<distortionHandler> selector = new distortionHandler( camera, distortionMesh );
+		//// selector
+		//geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
+		//geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) );
+		//osg::ref_ptr<distortionHandler> selector = new distortionHandler( camera, distortionMesh );
 		osg::ref_ptr<osg::Group> root = new osg::Group;
 		root->addChild(geode);
-		root->addChild(selector->createVertexHighlighter());
-		addEventHandler( selector.get() );
+		//root->addChild(selector->createVertexHighlighter());
+		//addEventHandler( selector.get() );
 		camera->addChild(root);
-		// Avoid that the highlighter is culled away
-		osg::CullSettings::CullingMode mode = camera->getCullingMode();
-		camera->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) );
+		//// Avoid that the highlighter is culled away
+		//osg::CullSettings::CullingMode mode = camera->getCullingMode();
+		//camera->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) );
 
 
