Index: /experimental/distortionNG/distortionNG.vcproj
===================================================================
--- /experimental/distortionNG/distortionNG.vcproj	(revision 333)
+++ /experimental/distortionNG/distortionNG.vcproj	(revision 334)
@@ -210,4 +210,12 @@
 			>
 		</Filter>
+		<File
+			RelativePath=".\shader.frag"
+			>
+		</File>
+		<File
+			RelativePath=".\shader.vert"
+			>
+		</File>
 	</Files>
 	<Globals>
Index: /experimental/distortionNG/extViewer.cpp
===================================================================
--- /experimental/distortionNG/extViewer.cpp	(revision 333)
+++ /experimental/distortionNG/extViewer.cpp	(revision 334)
@@ -3,11 +3,12 @@
 
 #include <osg/PolygonOffset>
-#include<osg/Texture2D>
-#include<osg/TextureRectangle>
-#include<osg/TexMat>
-#include<osg/ComputeBoundsVisitor>
-#include<osg/Vec2>
-
-#include<osgDB/ReadFile>
+#include <osg/Texture2D>
+#include <osg/TextureRectangle>
+#include <osg/TexMat>
+#include <osg/ComputeBoundsVisitor>
+#include <osg/Vec2>
+
+#include <osgDB/ReadFile>
+#include <osgDB/FileUtils>
 
 #include <osgUtil/SmoothingVisitor>
@@ -30,67 +31,4 @@
 {
 
-}
-
-static void configureShaders( osg::StateSet* stateSet )
-{
-	// Create Shaders
-    const std::string vertexSource = 
-		"uniform sampler2D sceneTexture;\n"
-		"uniform sampler2D intensityMapTexture;\n"
-        "uniform mat4 osg_ModelViewProjectionMatrix; \n"
-		//"uniform vec3 ecLightDir; \n"
-        " \n"
-        "in vec4 osg_Vertex; \n"
-		"in vec4 osg_Color; \n"
-        " \n"
-        "void main() \n"
-        "{ \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";
-
-    osg::Shader* vShader = new osg::Shader( osg::Shader::VERTEX, vertexSource );
-	vShader->setName("intensityMapVertShader");
-
-    const std::string fragmentSource = 
-		"uniform sampler2D sceneTexture;\n"
-		"uniform sampler2D intensityMapTexture;\n"
-        "varying vec2 texcoord;\n"
-        "\n"
-        "void main(void) \n"
-        "{\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 );
-	fShader->setName("intensityMapFragShader");
-
-	// Create Programm
-    osg::Program* program = new osg::Program;
-    program->addShader( vShader );
-    program->addShader( fShader );
-	program->setName("intensityMapFragProgramm");
-    stateSet->setAttribute( program );
-
-	osg::Uniform* sceneTextureSampler = new osg::Uniform("sceneTexture",0);
-    stateSet->addUniform(sceneTextureSampler);
-	osg::Uniform* intensityMapTextureSampler = new osg::Uniform("intensityMapTexture",1);
-    stateSet->addUniform(intensityMapTextureSampler);
-
-
-    /*osg::Vec3f lightDir( 0., 0.5, 1. );
-    lightDir.normalize();
-    stateSet->addUniform( new osg::Uniform( "ecLightDir", lightDir ) );*/
 }
 
@@ -178,5 +116,20 @@
 	if (intensityMap && !applyIntensityMapAsColours)
 	{
-		configureShaders( geom->getOrCreateStateSet() );
+		// create shaders for distortion
+		osg::Program* distortProgram = new osg::Program;
+		distortProgram->setName( "distortion" );
+		osg::Shader* vShader = osg::Shader::readShaderFile( osg::Shader::VERTEX, "shader.vert" ); 
+		vShader->setName("intensityMapVertShader");
+		osg::Shader* fShader = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, "shader.frag" ); 
+		fShader->setName("intensityMapFragShader");
+
+		if ( vShader && fShader )
+		{
+			//distortProgram->addShader( vShader );
+			distortProgram->addShader( fShader );
+			geom->getOrCreateStateSet()->addUniform( new osg::Uniform("sceneTexture", 0) );
+			geom->getOrCreateStateSet()->addUniform( new osg::Uniform("intensityMapTexture", 1) );
+			geom->getOrCreateStateSet()->setAttributeAndModes(distortProgram, osg::StateAttribute::ON);
+		}
 	}
 
@@ -245,12 +198,12 @@
     int camera_height = tex_height;
 
-    osg::TextureRectangle* texture = new osg::TextureRectangle;
-
-    texture->setTextureSize(tex_width, tex_height);
-    texture->setInternalFormat(GL_RGB);
-    texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
-    texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
-    texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
-    texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
+    osg::TextureRectangle* sceneTexture = new osg::TextureRectangle;
+
+    sceneTexture->setTextureSize(tex_width, tex_height);
+    sceneTexture->setInternalFormat(GL_RGB);
+    sceneTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
+    sceneTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
+    sceneTexture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
+    sceneTexture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
 
 
@@ -274,7 +227,6 @@
         // tell the camera to use OpenGL frame buffer object where supported.
         camera->setRenderTargetImplementation(renderTargetImplementation);
-
         // attach the texture and use it as the color buffer.
-        camera->attach(osg::Camera::COLOR_BUFFER, texture);
+        camera->attach(osg::Camera::COLOR_BUFFER, sceneTexture);
 
         addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
@@ -288,5 +240,5 @@
         // StateSet to contain the Texture StateAttribute.
         osg::StateSet* stateset = geode->getOrCreateStateSet();
-        stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
+        stateset->setTextureAttributeAndModes(0, sceneTexture,osg::StateAttribute::ON);
         stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
 
@@ -298,8 +250,13 @@
 		if (!applyIntensityMapAsColours && intensityMap)
         {
-            stateset->setTextureAttributeAndModes(1, new osg::Texture2D(intensityMap), osg::StateAttribute::ON);
+			osg::Texture2D* intensityMapTexture = new osg::Texture2D(intensityMap);
+            intensityMapTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST);
+            intensityMapTexture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST);
+            intensityMapTexture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP_TO_EDGE);
+            intensityMapTexture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP_TO_EDGE);
+
+            stateset->setTextureAttributeAndModes(1, intensityMapTexture, 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);
@@ -309,5 +266,5 @@
         camera->setGraphicsContext(gc.get());
         camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
-        camera->setClearColor( osg::Vec4(0.0,0.0,0.0,1.0) );
+        camera->setClearColor( osg::Vec4(0.0,1.0,0.0,1.0) );
         camera->setViewport(new osg::Viewport(0, 0, width, height));
         GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
Index: /experimental/distortionNG/shader.frag
===================================================================
--- /experimental/distortionNG/shader.frag	(revision 334)
+++ /experimental/distortionNG/shader.frag	(revision 334)
@@ -0,0 +1,15 @@
+uniform sampler2D sceneTexture;
+uniform sampler2D intensityMapTexture;
+varying vec2 texcoord_scene;
+varying vec2 texcoord_intensityMap;
+
+void main(void)
+{
+	vec4 sceneColor;
+	vec4 blendColor;
+
+	sceneColor = texture2D(sceneTexture, texcoord_scene);
+	blendColor = texture2D(intensityMapTexture, gl_FragCoord);
+	//gl_FragColor = vec4( 1.,1.,1.,1.);
+	gl_FragColor = sceneColor;
+}
Index: /experimental/distortionNG/shader.vert
===================================================================
--- /experimental/distortionNG/shader.vert	(revision 334)
+++ /experimental/distortionNG/shader.vert	(revision 334)
@@ -0,0 +1,10 @@
+varying vec2 texcoord_scene;
+varying vec2 texcoord_intensityMap;
+
+void main()
+{
+	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+	gl_FrontColor = gl_Color;
+	texcoord_scene = vec2(gl_MultiTexCoord0);
+	texcoord_intensityMap = vec2(gl_MultiTexCoord1);
+}
