Commits

Nathan Koenig  committed fdad397 Merge

Merged in shadows (pull request #237)

Collada and Shadows

  • Participants
  • Parent commits 3094227, 2241880
  • Branches gazebo_1.4

Comments (0)

Files changed (38)

File cmake/SearchForStuff.cmake

File contents unchanged.

File gazebo/common/ColladaLoader.cc

       for (unsigned int i = 0; i < outputStrs.size(); i++)
         values.push_back(math::parseFloat(outputStrs[i]));
 
-      TiXmlElement *accesor =
+      TiXmlElement *accessor =
         frameTransXml->FirstChildElement("technique_common");
-      accesor  = accesor->FirstChildElement("accessor");
+      accessor = accessor->FirstChildElement("accessor");
 
-      unsigned int stride = math::parseInt(accesor->Attribute("stride"));
+      unsigned int stride = math::parseInt(accessor->Attribute("stride"));
 
       for (unsigned int i = 0; i < times.size(); i++)
       {
   boost::split(strs, valueStr, boost::is_any_of("   "));
 
   end = strs.end();
-  for (iter = strs.begin(); iter != end; iter+= 3)
+  for (iter = strs.begin(); iter != end; iter += 3)
   {
     math::Vector3 vec(math::parseFloat(*iter), math::parseFloat(*(iter+1)),
         math::parseFloat(*(iter+2)));
 void ColladaLoader::LoadTexCoords(const std::string &_id,
                                   std::vector<math::Vector2d> &_values)
 {
+  int stride = 0;
+  int texCount = 0;
+  int totCount = 0;
+
+  // Get the source element for the texture coordinates.
   TiXmlElement *xml = this->GetElementId("source", _id);
   if (!xml)
   {
     return;
   }
 
+  // Get the array of float values. These are the raw values for the texture
+  // coordinates.
   TiXmlElement *floatArrayXml = xml->FirstChildElement("float_array");
   if (!floatArrayXml)
   {
     return;
   }
 
+  // The technique_common holds an <accessor> element that indicates how to
+  // parse the float array.
+  xml = xml->FirstChildElement("technique_common");
+  if (!xml)
+  {
+    gzerr << "Unable to find technique_common element for texture "
+          << "coordinates with id[" << _id << "]\n";
+    return;
+  }
+
+  // Get the accessor XML element.
+  xml = xml->FirstChildElement("accessor");
+  if (!xml)
+  {
+    gzerr << "Unable to find <accessor> as a child of <technique_common> "
+          << "for texture coordinates with id[" << _id << "]\n";
+    return;
+  }
+
+  // Read in the total number of texture coordinate values
+  if (floatArrayXml->Attribute("count"))
+    totCount = boost::lexical_cast<int>(floatArrayXml->Attribute("count"));
+  else
+  {
+    gzerr << "<float_array> has no count attribute in texture coordinate "
+          << "element with id[" << _id << "]\n";
+    return;
+  }
+
+  // Read in the stride for the texture coordinate values. The stride
+  // indicates the number of values in the float array the comprise
+  // a complete texture coordinate.
+  if (xml->Attribute("stride"))
+    stride = boost::lexical_cast<int>(xml->Attribute("stride"));
+  else
+  {
+    gzerr << "<accessor> has no stride attribute in texture coordinate element "
+          << "with id[" << _id << "]\n";
+    return;
+  }
+
+  // Read in the count of texture coordinates.
+  if (xml->Attribute("count"))
+    texCount = boost::lexical_cast<int>(xml->Attribute("count"));
+  else
+  {
+    gzerr << "<accessor> has no count attribute in texture coordinate element "
+          << "with id[" << _id << "]\n";
+    return;
+  }
+
+  // \TODO This is a good a GZ_ASSERT
+  // The total number of texture values should equal the stride multiplied
+  // by the number of texture coordinates.
+  if (texCount * stride != totCount)
+  {
+    gzerr << "Error reading texture coordinates. Coordinate counts in element "
+             "with id[" << _id << "] do not add up correctly\n";
+    return;
+  }
+
+  // Read the raw texture values, and split them on spaces.
   std::string valueStr = floatArrayXml->GetText();
-  std::istringstream iss(valueStr);
-  do
+  std::vector<std::string> values;
+  boost::split(values, valueStr, boost::is_any_of(" "));
+
+  // Read in all the texture coordinates.
+  for (int i = 0; i < totCount; i += stride)
   {
-    math::Vector2d vec;
-    iss >> vec.x >> vec.y;
-    if (iss)
-    {
-      vec.y = 1.0 - vec.y;
-      _values.push_back(vec);
-    }
-  } while (iss);
+    // We only handle 2D texture coordinates right now.
+    _values.push_back(math::Vector2d(boost::lexical_cast<double>(values[i]),
+          1.0 - boost::lexical_cast<double>(values[i+1])));
+  }
 }
 
 /////////////////////////////////////////////////
   // break poly into triangles
   // if vcount >= 4, anchor around 0 (note this is bad for concave elements)
   //   e.g. if vcount = 4, break into triangle 1: [0,1,2], triangle 2: [0,2,3]
-  std::vector<std::string> vcount_strs;
+  std::vector<std::string> vcountStrs;
   TiXmlElement *vcountXml = _polylistXml->FirstChildElement("vcount");
   std::string vcountStr = vcountXml->GetText();
-  boost::split(vcount_strs, vcountStr, boost::is_any_of("   "));
+  boost::split(vcountStrs, vcountStr, boost::is_any_of("   "));
   std::vector<int> vcounts;
-  for (unsigned int j = 0; j < vcount_strs.size(); ++j)
-    vcounts.push_back(math::parseInt(vcount_strs[j]));
+  for (unsigned int j = 0; j < vcountStrs.size(); ++j)
+    vcounts.push_back(math::parseInt(vcountStrs[j]));
 
   // read p
   TiXmlElement *pXml = _polylistXml->FirstChildElement("p");
   std::vector<math::Vector3> norms;
   std::vector<math::Vector2d> texcoords;
 
-  std::map<std::string, int> inputs;
+  // A list of all the input values.
+  std::list<std::pair<std::string, int> > inputs;
   while (trianglesInputXml)
   {
     std::string semantic = trianglesInputXml->Attribute("semantic");
     else if (semantic == "TEXCOORD")
       this->LoadTexCoords(source, texcoords);
 
-    inputs[semantic] = math::parseInt(offset);
+    inputs.push_back(std::make_pair(semantic, math::parseInt(offset)));
 
     trianglesInputXml = trianglesInputXml->NextSiblingElement("input");
   }
   std::fill(vertNormsCounts.begin(), vertNormsCounts.end(), 0);
 
   int *values = new int[inputs.size()];
-  std::map<std::string, int>::iterator end = inputs.end();
-  std::map<std::string, int>::iterator iter;
+  std::list<std::pair<std::string, int> >::iterator end = inputs.end();
+  std::list<std::pair<std::string, int> >::iterator iter;
   math::Vector2d vec;
 
   std::vector<std::string> strs;
   boost::split(strs, pStr, boost::is_any_of("   "));
+
   for (unsigned int j = 0; j < strs.size(); j += inputs.size())
   {
     for (unsigned int i = 0; i < inputs.size(); i++)
       values[i] = math::parseInt(strs[j+i]);
+
+    bool already = false;
     for (iter = inputs.begin(); iter != end; ++iter)
     {
-      if (iter->first == "VERTEX")
+      if ((*iter).first == "VERTEX")
       {
-        subMesh->AddVertex(verts[values[iter->second]]);
+        subMesh->AddVertex(verts[values[(*iter).second]]);
         subMesh->AddIndex(subMesh->GetVertexCount()-1);
         if (combinedVertNorms)
-          subMesh->AddNormal(norms[values[iter->second]]);
+          subMesh->AddNormal(norms[values[(*iter).second]]);
         if (_mesh->HasSkeleton())
         {
           Skeleton *skel = _mesh->GetSkeleton();
           for (unsigned int i = 0;
-                  i < skel->GetNumVertNodeWeights(values[iter->second]); i++)
+                  i < skel->GetNumVertNodeWeights(values[(*iter).second]); i++)
           {
             std::pair<std::string, double> node_weight =
-                              skel->GetVertNodeWeight(values[iter->second], i);
+              skel->GetVertNodeWeight(values[(*iter).second], i);
             SkeletonNode *node =
                 _mesh->GetSkeleton()->GetNodeByName(node_weight.first);
             subMesh->AddNodeAssignment(subMesh->GetVertexCount()-1,
           }
         }
       }
-      else if (iter->first == "NORMAL")
+      else if ((*iter).first == "NORMAL")
       {
-        subMesh->AddNormal(norms[values[iter->second]]);
+        subMesh->AddNormal(norms[values[(*iter).second]]);
       }
-      else if (iter->first == "TEXCOORD")
+      else if ((*iter).first == "TEXCOORD" && !already)
       {
-        subMesh->AddTexCoord(texcoords[values[iter->second]].x,
-            texcoords[values[iter->second]].y);
+        already = true;
+        subMesh->AddTexCoord(texcoords[values[(*iter).second]].x,
+            texcoords[values[(*iter).second]].y);
       }
       // else
-      // gzerr << "Unhandled semantic[" << iter->first << "]\n";
+      // gzerr << "Unhandled semantic[" << (*iter).first << "]\n";
     }
   }
   delete [] values;

File gazebo/gui/SphereMaker.cc

File contents unchanged.

File gazebo/rendering/Light.cc

File contents unchanged.

File gazebo/rendering/RTShaderSystem.cc

   if (!this->initialized)
     return;
 
-  this->entityMutex->lock();
+  boost::mutex::scoped_lock lock(*this->entityMutex);
   this->entities.remove(_vis);
-  this->entityMutex->unlock();
 }
 
+//////////////////////////////////////////////////
 void RTShaderSystem::Clear()
 {
-  this->entityMutex->lock();
+  boost::mutex::scoped_lock lock(*this->entityMutex);
   this->entities.clear();
-  this->entityMutex->unlock();
 }
 
 //////////////////////////////////////////////////
 #endif
 }
 
+//////////////////////////////////////////////////
 void RTShaderSystem::DetachViewport(Ogre::Viewport *_viewport, ScenePtr _scene)
 {
 #if OGRE_VERSION_MAJOR == 1 && OGRE_VERSION_MINOR >= 7
 #endif
 }
 
-
 //////////////////////////////////////////////////
 void RTShaderSystem::UpdateShaders()
 {
 
   std::list<Visual*>::iterator iter;
 
-  this->entityMutex->lock();
+  boost::mutex::scoped_lock lock(*this->entityMutex);
+
   // Update all the shaders
   for (iter = this->entities.begin(); iter != this->entities.end(); ++iter)
     this->GenerateShaders(*iter);
-  this->entityMutex->unlock();
 }
 
 //////////////////////////////////////////////////
           // Remove all sub render states.
           renderState->reset();
 
-          if (vis->GetShaderType() == "vertex")
+          /// This doesn't seem to work properly.
+          if (vis->GetShaderType() == "normal_map_object_space")
           {
-            Ogre::RTShader::SubRenderState* perPerVertexLightModel =
+            Ogre::RTShader::SubRenderState* subRenderState =
+              this->shaderGenerator->createSubRenderState(
+                  Ogre::RTShader::NormalMapLighting::Type);
+
+            Ogre::RTShader::NormalMapLighting* normalMapSubRS =
+              static_cast<Ogre::RTShader::NormalMapLighting*>(subRenderState);
+
+            normalMapSubRS->setNormalMapSpace(
+                Ogre::RTShader::NormalMapLighting::NMS_OBJECT);
+
+            normalMapSubRS->setNormalMapTextureName(vis->GetNormalMap());
+            renderState->addTemplateSubRenderState(normalMapSubRS);
+          }
+          else if (vis->GetShaderType() == "normal_map_tangent_space")
+          {
+            Ogre::RTShader::SubRenderState* subRenderState =
+              this->shaderGenerator->createSubRenderState(
+                  Ogre::RTShader::NormalMapLighting::Type);
+
+            Ogre::RTShader::NormalMapLighting* normalMapSubRS =
+              static_cast<Ogre::RTShader::NormalMapLighting*>(subRenderState);
+
+            normalMapSubRS->setNormalMapSpace(
+                Ogre::RTShader::NormalMapLighting::NMS_TANGENT);
+
+            normalMapSubRS->setNormalMapTextureName(vis->GetNormalMap());
+
+            renderState->addTemplateSubRenderState(normalMapSubRS);
+          }
+          else if (vis->GetShaderType() == "vertex")
+          {
+            Ogre::RTShader::SubRenderState *perPerVertexLightModel =
               this->shaderGenerator->createSubRenderState(
                   Ogre::RTShader::FFPLighting::Type);
 
           }
           else
           {
-            Ogre::RTShader::SubRenderState* perPixelLightModel =
+            Ogre::RTShader::SubRenderState *perPixelLightModel =
               this->shaderGenerator->createSubRenderState(
                   Ogre::RTShader::PerPixelLighting::Type);
 
             renderState->addTemplateSubRenderState(perPixelLightModel);
           }
 
-          /// This doesn't seem to work properly.
-          /*if (vis->GetShaderType() == "normal_map_object_space")
-            {
-            Ogre::RTShader::SubRenderState* subRenderState =
-            this->shaderGenerator->createSubRenderState(
-            Ogre::RTShader::NormalMapLighting::Type);
 
-            Ogre::RTShader::NormalMapLighting* normalMapSubRS =
-            static_cast<Ogre::RTShader::NormalMapLighting*>(subRenderState);
-
-            normalMapSubRS->setNormalMapSpace(
-            Ogre::RTShader::NormalMapLighting::NMS_OBJECT);
-
-            normalMapSubRS->setNormalMapTextureName(vis->GetNormalMap());
-            renderState->addTemplateSubRenderState(normalMapSubRS);
-            }
-            else if (vis->GetShaderType() ==)
-            {
-            Ogre::RTShader::SubRenderState* subRenderState =
-            this->shaderGenerator->createSubRenderState(
-            Ogre::RTShader::NormalMapLighting::Type);
-
-            Ogre::RTShader::NormalMapLighting* normalMapSubRS =
-            static_cast<Ogre::RTShader::NormalMapLighting*>(subRenderState);
-
-            normalMapSubRS->setNormalMapSpace(
-            Ogre::RTShader::NormalMapLighting::NMS_TANGENT);
-
-            normalMapSubRS->setNormalMapTextureName(vis->GetNormalMap());
-
-            renderState->addTemplateSubRenderState(normalMapSubRS);
-            }
-            */
           // Invalidate this material in order to re-generate its shaders.
           this->shaderGenerator->invalidateMaterial(
               this->scenes[s]->GetName() +
   sceneMgr->setShadowTextureConfig(0, 1024, 1024, Ogre::PF_FLOAT32_R);
   sceneMgr->setShadowTextureConfig(1, 512, 512, Ogre::PF_FLOAT32_R);
   sceneMgr->setShadowTextureConfig(2, 512, 512, Ogre::PF_FLOAT32_R);
-  sceneMgr->setShadowTextureSelfShadow(true);
+  sceneMgr->setShadowTextureSelfShadow(false);
+  sceneMgr->setShadowCasterRenderBackFaces(true);
 
   // TODO: We have two different shadow caster materials, both taken from
   // OGRE samples. They should be compared and tested.
   // sceneMgr->setShadowTextureCasterMaterial("PSSM/shadow_caster");
   sceneMgr->setShadowTextureCasterMaterial("Gazebo/shadow_caster");
 
-  sceneMgr->setShadowCasterRenderBackFaces(true);
-
   // Disable fog on the caster pass.
   //  Ogre::MaterialPtr passCaterMaterial =
   //   Ogre::MaterialManager::getSingleton().getByName("PSSM/shadow_caster");
 
   // shadow camera setup
   this->pssmSetup = new Ogre::PSSMShadowCameraSetup();
-  sceneMgr->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(this->pssmSetup));
 
-  double shadowFarDistance = 1000;
-  double cameraNearClip = 0.01;
+  double shadowFarDistance = 200;
+  double cameraNearClip = 0.1;
   sceneMgr->setShadowFarDistance(shadowFarDistance);
 
   this->pssmSetup->calculateSplitPoints(3, cameraNearClip, shadowFarDistance);
   this->pssmSetup->setSplitPadding(0);
+  this->pssmSetup->setOptimalAdjustFactor(0, 4);
+  this->pssmSetup->setOptimalAdjustFactor(1, 1);
+  this->pssmSetup->setOptimalAdjustFactor(2, .1);
+
+  sceneMgr->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(this->pssmSetup));
 
   // These values do not seem to help at all. Leaving here until I have time
   // to properly fix shadow z-fighting.

File gazebo/rendering/UserCamera.cc

   else if (RenderEngine::Instance()->GetRenderPathType() ==
            RenderEngine::FORWARD)
   {
-    this->SetClipDist(0.1, 5000);
+    this->SetClipDist(.1, 5000);
   }
   else
   {
-    this->SetClipDist(0.1, 5000);
+    this->SetClipDist(.1, 5000);
   }
 
   // Removing for now because the axis doesn't not move properly when the

File gazebo/sdf/1.3/scene.sdf

 <element name="scene" required="1">
   <description>Specifies the look of the environment.</description>
 
-  <element name="ambient" type="color" default="0.0 0.0 0.0 1.0" required="1">
+  <element name="ambient" type="color" default="0.2 0.2 0.2 1.0" required="1">
     <description>Color of the ambient light.</description>
   </element>
 

File media/materials/programs/shadow_caster_fp.glsl

-uniform vec4 depth_range;
+// uniform vec4 depth_range;
 varying vec4 vertex_depth;
 
 void main()
 {
-  float depth = vertex_depth.z / vertex_depth.w;
+  float depth = (vertex_depth.z) / vertex_depth.w;
 
   // Linear
-  //float depth = (vertex_depth.z - depth_range.x) * depth_range.w;
+  // float depth = (vertex_depth.z - depth_range.x) / depth_range.w;
 
-  gl_FragColor = vec4(depth, depth*depth, 0.0, 1.0);
+  gl_FragColor = vec4(depth, depth, depth, 1.0);
 }

File media/materials/programs/shadow_caster_vp.glsl

 
 void main()
 {
-  gl_Position = world_view_proj_mat * gl_Vertex;
-  vertex_depth = gl_Position;
+  vertex_depth = world_view_proj_mat * gl_Vertex;
+  gl_Position = vertex_depth;
   gl_Position.xy += texel_offsets.zw * gl_Position.w;
 }

File media/materials/scripts/shadow_caster.program

 
   default_params
   {
-    param_named_auto depth_range shadow_scene_depth_range
+    // param_named_auto depth_range shadow_scene_depth_range
   }
 }
 
     // all this will do is write depth and depth*depth to red and green
     pass
     {
-      depth_check on
-      depth_write on
-      //cull_software none
-      //cull_hardware none
-
       vertex_program_ref shadow_caster_vp_glsl
       {
       }

File media/rtshaderlib/CMakeLists.txt

 add_subdirectory(materials)
 
 set (files 
-FFPLib_Common.cg
-FFPLib_Common.hlsl
 FFPLib_Common.glsl
-FFPLib_Fog.cg
 FFPLib_Fog.glsl
-FFPLib_Fog.hlsl
-FFPLib_Lighting.cg
 FFPLib_Lighting.glsl
-FFPLib_Lighting.hlsl
-FFPLib_Texturing.cg
 FFPLib_Texturing.glsl
-FFPLib_Texturing.hlsl
-FFPLib_Transform.cg
 FFPLib_Transform.glsl
-FFPLib_Transform.hlsl
-SampleLib_ReflectionMap.cg
 SampleLib_ReflectionMap.glsl
-SampleLib_ReflectionMap.hlsl
-SGXLib_IntegratedPSSM.cg
 SGXLib_IntegratedPSSM.glsl
-SGXLib_IntegratedPSSM.hlsl
-SGXLib_NormalMapLighting.cg
 SGXLib_NormalMapLighting.glsl
-SGXLib_NormalMapLighting.hlsl
-SGXLib_PerPixelLighting.cg
 SGXLib_PerPixelLighting.glsl
-SGXLib_PerPixelLighting.hlsl
 )
 
 install(FILES ${files} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/gazebo-${GAZEBO_VERSION}/media/rtshaderlib)

File media/rtshaderlib/FFPLib_Common.cg

-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2009 Torus Knot Software Ltd
-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 above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-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.
------------------------------------------------------------------------------
-*/
-
-//-----------------------------------------------------------------------------
-// Program Name: FFPLib_Common
-// Program Desc: Common functions of the FFP.
-// Program Type: Vertex/Pixel shader
-// Language: CG
-// Notes: Common functions needed by all FFP implementation classes.
-//-----------------------------------------------------------------------------
-void FFP_Assign(in unsigned int iColor_0, out float4 oColor_0)
-{
-	oColor_0.w = ((iColor_0 >> 24) & 0xFF) / 255.0f;
-	oColor_0.x = ((iColor_0 >> 16) & 0xFF) / 255.0f;
-	oColor_0.y = ((iColor_0 >> 8) & 0xFF) / 255.0f;
-	oColor_0.z = (iColor_0 & 0xFF) / 255.0f;
-
-}
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float vIn, out float vOut)
-{
-	vOut = vIn;
-}
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float2 vIn, out float2 vOut)
-{
-	vOut = vIn;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float3 vIn, out float3 vOut)
-{
-	vOut = vIn;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float4 vIn, out float4 vOut)
-{
-	vOut = vIn;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 
-				   in float g,
-				   in float b,
-				   in float a,
-				   out float4 vOut)
-{
-	vOut = float4(r,g,b,a);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 
-			 in float g,
-			 out float2 vOut)
-{
-	vOut = float2(r,g);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 
-				   in float g,
-				   in float b,
-				   out float3 vOut)
-{
-	vOut = float3(r,g,b);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 				   
-				   out float4 vOut)
-{
-	vOut = float4(r,r,r,r);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float vIn0, in float vIn1, float T, out float vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float2 vIn0, in float2 vIn1, float T, out float2 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float3 vIn0, in float3 vIn1, float T, out float3 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float4 vIn0, in float4 vIn1, float T, out float4 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float4 vIn0, in float4 vIn1, float4 T, out float4 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-
-

File media/rtshaderlib/FFPLib_Common.glsl

 (Object-oriented Graphics Rendering Engine)
 For the latest info, see http://www.ogre3d.org
 
-Copyright (c) 2000-2009 Torus Knot Software Ltd
+Copyright (c) 2000-2012 Torus Knot Software Ltd
 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
 	vOut = vIn.xyz;
 }
 //-----------------------------------------------------------------------------
+void FFP_Assign(in mat2x4 vIn, out mat2x4 vOut)
+{
+	vOut = vIn;
+}
+//-----------------------------------------------------------------------------
+void FFP_Assign(in mat3x4 vIn, out mat3x4 vOut)
+{
+	vOut = vIn;
+}
+//-----------------------------------------------------------------------------
 void FFP_Construct(in float r, 
 			 in float g,
 			 in float b,
 }
 
 //-----------------------------------------------------------------------------
+void FFP_Add(in mat2x4 vIn0, in mat2x4 vIn1, out mat2x4 vOut)
+{
+	vOut = vIn0 + vIn1;
+}
+
+//-----------------------------------------------------------------------------
+void FFP_Add(in mat3x4 vIn0, in mat3x4 vIn1, out mat3x4 vOut)
+{
+	vOut = vIn0 + vIn1;
+}
+//-----------------------------------------------------------------------------
 void FFP_Subtract(in float vIn0, in float vIn1, out float vOut)
 {
 	vOut = vIn0 - vIn1;
 {
 	vOut = vec4(dot(vIn0, vIn1), 1.0, 1.0, 1.0);
 }
-
-
-
-

File media/rtshaderlib/FFPLib_Common.hlsl

-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2009 Torus Knot Software Ltd
-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 above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-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.
------------------------------------------------------------------------------
-*/
-
-//-----------------------------------------------------------------------------
-// Program Name: FFPLib_Common
-// Program Desc: Common functions of the FFP.
-// Program Type: Vertex/Pixel shader
-// Language: CG
-// Notes: Common functions needed by all FFP implementation classes.
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-void FFP_Assign(in unsigned int iColor_0, out float4 oColor_0)
-{
-	oColor_0.w = ((iColor_0 >> 24) & 0xFF) / 255.0f;
-	oColor_0.x = ((iColor_0 >> 16) & 0xFF) / 255.0f;
-	oColor_0.y = ((iColor_0 >> 8) & 0xFF) / 255.0f;
-	oColor_0.z = (iColor_0 & 0xFF) / 255.0f;
-
-}
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float vIn, out float vOut)
-{
-	vOut = vIn;
-}
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float2 vIn, out float2 vOut)
-{
-	vOut = vIn;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float3 vIn, out float3 vOut)
-{
-	vOut = vIn;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Assign(in float4 vIn, out float4 vOut)
-{
-	vOut = vIn;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 
-				   in float g,
-				   in float b,
-				   in float a,
-				   out float4 vOut)
-{
-	vOut = float4(r,g,b,a);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 
-			 in float g,
-			 out float2 vOut)
-{
-	vOut = float2(r,g);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 
-				   in float g,
-				   in float b,
-				   out float3 vOut)
-{
-	vOut = float3(r,g,b);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Construct(in float r, 				   
-				   out float4 vOut)
-{
-	vOut = float4(r,r,r,r);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Modulate(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = vIn0 * vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Add(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = vIn0 + vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Subtract(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = vIn0 - vIn1;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float vIn0, in float vIn1, float T, out float vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float2 vIn0, in float2 vIn1, float T, out float2 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float3 vIn0, in float3 vIn1, float T, out float3 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float4 vIn0, in float4 vIn1, float T, out float4 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Lerp(in float4 vIn0, in float4 vIn1, float4 T, out float4 vOut)
-{
-	vOut = lerp(vIn0, vIn1, T);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float vIn0, in float vIn1, out float vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float2 vIn0, in float2 vIn1, out float2 vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float3 vIn0, in float3 vIn1, out float3 vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_DotProduct(in float4 vIn0, in float4 vIn1, out float4 vOut)
-{
-	vOut = dot(vIn0, vIn1);
-}
-
-
-

File media/rtshaderlib/FFPLib_Fog.cg

-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2009 Torus Knot Software Ltd
-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 above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-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.
------------------------------------------------------------------------------
-*/
-
-//-----------------------------------------------------------------------------
-// Program Name: FFPLib_Fog
-// Program Desc: Fog functions of the FFP.
-// Program Type: Vertex/Pixel shader
-// Language: CG
-// Notes: Implements cor functions needed by FFPFog class.
-// Based on fog engine. 
-// See http://msdn.microsoft.com/en-us/library/ee418582.aspx
-// Vertex based fog: the w component of the out position is used
-// as the distance parameter to fog formulas. This is basically the z coordinate
-// in world space. See pixel fog under D3D docs. The fog factor is computed according 
-// to each formula, then clamped and output to the pixel shader.
-// Pixel based fog: the w component of the out position is passed to pixel shader
-// that computes the fog factor based on it.
-// Both techniques use the fog factor in the end of the pixel shader to blend
-// the output color with the fog color.
-//-----------------------------------------------------------------------------
-
-
-
-//-----------------------------------------------------------------------------
-void FFP_VertexFog_Linear(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   
-				   in float4 fogParams,				   
-				   out float oFogFactor)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	float distance  = abs(vOutPos.w);	
-	float fogFactor = (fogParams.z - distance) * fogParams.w;
-	
-	oFogFactor  = saturate(fogFactor);	
-}
-
-//-----------------------------------------------------------------------------
-void FFP_VertexFog_Exp(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   
-				   in float4 fogParams,				   
-				   out float oFogFactor)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	float distance  = abs(vOutPos.w);	
-	float exp       = distance*fogParams.x;
-	float fogFactor = 1 / pow(2.71828, exp);
-	
-	oFogFactor  = saturate(fogFactor);	
-}
-
-//-----------------------------------------------------------------------------
-void FFP_VertexFog_Exp2(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   
-				   in float4 fogParams,				   
-				   out float oFogFactor)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	float distance  = abs(vOutPos.w);	
-	float exp       = (distance*fogParams.x*distance*fogParams.x);
-	float fogFactor = 1 / pow(2.71828, exp);
-	
-	oFogFactor  = saturate(fogFactor);	
-}
-
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Depth(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   				   				   
-				   out float oDepth)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	oDepth			= vOutPos.w;	
-}
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Linear(in float depth,		   
-				   in float4 fogParams,				   
-				   in float4 fogColor,
-				   in float4 baseColor,
-				   out float4 oColor)
-{
-	float distance = abs(depth);
-	float fogFactor = saturate((fogParams.z - distance) * fogParams.w);
-	
-	oColor = lerp(fogColor, baseColor, fogFactor);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Exp(in float depth,		   
-				   in float4 fogParams,				   
-				   in float4 fogColor,
-				   in float4 baseColor,
-				   out float4 oColor)
-{
-	float distance  = abs(depth);	
-	float exp       = (distance*fogParams.x);
-	float fogFactor = saturate(1 / pow(2.71828, exp));
-	
-	oColor = lerp(fogColor, baseColor, fogFactor);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Exp2(in float depth,		   
-				   in float4 fogParams,				   
-				   in float4 fogColor,
-				   in float4 baseColor,
-				   out float4 oColor)
-{
-	float distance  = abs(depth);	
-	float exp       = (distance*fogParams.x*distance*fogParams.x);
-	float fogFactor = saturate(1 / pow(2.71828, exp));
-	
-	oColor = lerp(fogColor, baseColor, fogFactor);		
-}

File media/rtshaderlib/FFPLib_Fog.glsl

 (Object-oriented Graphics Rendering Engine)
 For the latest info, see http://www.ogre3d.org
 
-Copyright (c) 2000-2009 Torus Knot Software Ltd
+Copyright (c) 2000-2012 Torus Knot Software Ltd
 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
 // Program Desc: Fog functions of the FFP.
 // Program Type: Vertex/Pixel shader
 // Language: GLSL
-// Notes: Implements cor functions needed by FFPFog class.
+// Notes: Implements core functions needed by FFPFog class.
 // Based on fog engine. 
-// See http://msdn.microsoft.com/en-us/library/ee418582.aspx
+// See http://msdn.microsoft.com/en-us/library/bb173398.aspx
 // Vertex based fog: the w component of the out position is used
 // as the distance parameter to fog formulas. This is basically the z coordinate
 // in world space. See pixel fog under D3D docs. The fog factor is computed according 

File media/rtshaderlib/FFPLib_Fog.hlsl

-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2009 Torus Knot Software Ltd
-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 above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-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.
------------------------------------------------------------------------------
-*/
-
-//-----------------------------------------------------------------------------
-// Program Name: FFPLib_Fog
-// Program Desc: Fog functions of the FFP.
-// Program Type: Vertex/Pixel shader
-// Language: HLSL
-// Notes: Implements cor functions needed by FFPFog class.
-// Based on fog engine. 
-// See http://msdn.microsoft.com/en-us/library/ee418582.aspx
-// Vertex based fog: the w component of the out position is used
-// as the distance parameter to fog formulas. This is basically the z coordinate
-// in world space. See pixel fog under D3D docs. The fog factor is computed according 
-// to each formula, then clamped and output to the pixel shader.
-// Pixel based fog: the w component of the out position is passed to pixel shader
-// that computes the fog factor based on it.
-// Both techniques use the fog factor in the end of the pixel shader to blend
-// the output color with the fog color.
-//-----------------------------------------------------------------------------
-
-
-
-//-----------------------------------------------------------------------------
-void FFP_VertexFog_Linear(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   
-				   in float4 fogParams,				   
-				   out float oFogFactor)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	float distance  = abs(vOutPos.w);	
-	float fogFactor = (fogParams.z - distance) * fogParams.w;
-	
-	oFogFactor  = saturate(fogFactor);	
-}
-
-//-----------------------------------------------------------------------------
-void FFP_VertexFog_Exp(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   
-				   in float4 fogParams,				   
-				   out float oFogFactor)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	float distance  = abs(vOutPos.w);	
-	float exp       = distance*fogParams.x;
-	float fogFactor = 1 / pow(2.71828, exp);
-	
-	oFogFactor  = saturate(fogFactor);	
-}
-
-//-----------------------------------------------------------------------------
-void FFP_VertexFog_Exp2(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   
-				   in float4 fogParams,				   
-				   out float oFogFactor)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	float distance  = abs(vOutPos.w);	
-	float exp       = (distance*fogParams.x*distance*fogParams.x);
-	float fogFactor = 1 / pow(2.71828, exp);
-	
-	oFogFactor  = saturate(fogFactor);	
-}
-
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Depth(in float4x4 mWorldViewProj, 
-				   in float4 pos, 				   				   				   
-				   out float oDepth)
-{
-	float4 vOutPos  = mul(mWorldViewProj, pos);
-	oDepth			= vOutPos.w;	
-}
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Linear(in float depth,		   
-				   in float4 fogParams,				   
-				   in float4 fogColor,
-				   in float4 baseColor,
-				   out float4 oColor)
-{
-	float distance = abs(depth);
-	float fogFactor = saturate((fogParams.z - distance) * fogParams.w);
-	
-	oColor = lerp(fogColor, baseColor, fogFactor);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Exp(in float depth,		   
-				   in float4 fogParams,				   
-				   in float4 fogColor,
-				   in float4 baseColor,
-				   out float4 oColor)
-{
-	float distance  = abs(depth);	
-	float exp       = (distance*fogParams.x);
-	float fogFactor = saturate(1 / pow(2.71828, exp));
-	
-	oColor = lerp(fogColor, baseColor, fogFactor);
-}
-
-//-----------------------------------------------------------------------------
-void FFP_PixelFog_Exp2(in float depth,		   
-				   in float4 fogParams,				   
-				   in float4 fogColor,
-				   in float4 baseColor,
-				   out float4 oColor)
-{
-	float distance  = abs(depth);	
-	float exp       = (distance*fogParams.x*distance*fogParams.x);
-	float fogFactor = saturate(1 / pow(2.71828, exp));
-	
-	oColor = lerp(fogColor, baseColor, fogFactor);		
-}

File media/rtshaderlib/FFPLib_Lighting.cg

-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2009 Torus Knot Software Ltd
-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 above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-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.
------------------------------------------------------------------------------
-*/
-
-//-----------------------------------------------------------------------------
-// Program Name: FFPLib_Lighting
-// Program Desc: Lighting functions of the FFP.
-// Program Type: Vertex shader
-// Language: CG
-// Notes: Implements core functions for FFPLighting class.
-// based on lighting engine. 
-// See http://msdn.microsoft.com/en-us/library/ee422035.aspx
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Directional_Diffuse(in float4x4 mWorldViewIT, 
-				   in float3 vNormal,
-				   in float3 vNegLightDirView,
-				   in float3 vDiffuseColour, 
-				   in float3 vBaseColour, 
-				   out float3 vOut)
-{
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL = dot(vNormalView, vNegLightDirView);
-	
-	vOut = vBaseColour + vDiffuseColour * saturate(nDotL);
-}
-
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Directional_DiffuseSpecular(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-					in float3 vNormal,
-					in float3 vNegLightDirView,
-					in float3 vDiffuseColour, 
-					in float3 vSpecularColour, 
-					in float fSpecularPower, 
-					in float3 vBaseDiffuseColour,
-					in float3 vBaseSpecularColour,					
-					out float3 vOutDiffuse,
-					out float3 vOutSpecular)
-{
-	vOutDiffuse  = vBaseDiffuseColour;
-	vOutSpecular = vBaseSpecularColour;
-	
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));		
-	float nDotL		   = dot(vNormalView, vNegLightDirView);			
-	float3 vView       = -normalize(mul(mWorldView, vPos).xyz);
-	float3 vHalfWay    = normalize(vView + vNegLightDirView);
-	float nDotH        = dot(vNormalView, vHalfWay);
-	
-	if (nDotL > 0)
-	{
-		vOutDiffuse  += vDiffuseColour * nDotL;		
-		vOutSpecular += vSpecularColour * pow(saturate(nDotH), fSpecularPower);						
-	}
-}
-
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Point_Diffuse(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float4 vAttParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vBaseColour, 
-				    out float3 vOut)
-{
-	vOut = vBaseColour;		
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, normalize(vLightView));
-	
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{
-		float fAtten	   = 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);
-			
-		vOut += vDiffuseColour * nDotL * fAtten;
-	}		
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Point_DiffuseSpecular(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float4 vAttParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vSpecularColour, 
-					in float fSpecularPower, 
-				    in float3 vBaseDiffuseColour,
-					in float3 vBaseSpecularColour,					
-					out float3 vOutDiffuse,
-					out float3 vOutSpecular)
-{
-	vOutDiffuse  = vBaseDiffuseColour;
-	vOutSpecular = vBaseSpecularColour;
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	
-	vLightView		   = normalize(vLightView);	
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, vLightView);	
-		
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{					
-		float3 vView       = -normalize(vViewPos);			
-		float3 vHalfWay    = normalize(vView + vLightView);		
-		float nDotH        = dot(vNormalView, vHalfWay);
-		float fAtten	   = 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);					
-		
-		vOutDiffuse  += vDiffuseColour * nDotL * fAtten;
-		vOutSpecular += vSpecularColour * pow(saturate(nDotH), fSpecularPower) * fAtten;					
-	}		
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Spot_Diffuse(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float3 vNegLightDirView,
-				    in float4 vAttParams,
-				    in float3 vSpotParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vBaseColour, 
-				    out float3 vOut)
-{
-	vOut = vBaseColour;		
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	vLightView		   = normalize(vLightView);
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, vLightView);
-	
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{
-		float fAtten	= 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);
-		float rho		= dot(vNegLightDirView, vLightView);						
-		float fSpotE	= saturate((rho - vSpotParams.y) / (vSpotParams.x - vSpotParams.y));
-		float fSpotT	= pow(fSpotE, vSpotParams.z);	
-						
-		vOut += vDiffuseColour * nDotL * fAtten * fSpotT;
-	}		
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Spot_DiffuseSpecular(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float3 vNegLightDirView,
-				    in float4 vAttParams,
-				    in float3 vSpotParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vSpecularColour, 
-					in float fSpecularPower, 
-				    in float3 vBaseDiffuseColour,
-					in float3 vBaseSpecularColour,					
-					out float3 vOutDiffuse,
-					out float3 vOutSpecular)
-{
-	vOutDiffuse  = vBaseDiffuseColour;		
-	vOutSpecular = vBaseSpecularColour;
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	vLightView		   = normalize(vLightView);
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, vLightView);
-	
-	
-	
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{
-		float3 vView       = -normalize(vViewPos);	
-		float3 vHalfWay    = normalize(vView + vLightView);				
-		float nDotH        = dot(vNormalView, vHalfWay);
-		float fAtten	= 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);
-		float rho		= dot(vNegLightDirView, vLightView);						
-		float fSpotE	= saturate((rho - vSpotParams.y) / (vSpotParams.x - vSpotParams.y));
-		float fSpotT	= pow(fSpotE, vSpotParams.z);	
-						
-		vOutDiffuse  += vDiffuseColour * nDotL * fAtten * fSpotT;
-		vOutSpecular += vSpecularColour * pow(saturate(nDotH), fSpecularPower) * fAtten * fSpotT;
-	}		
-}

File media/rtshaderlib/FFPLib_Lighting.glsl

 (Object-oriented Graphics Rendering Engine)
 For the latest info, see http://www.ogre3d.org
 
-Copyright (c) 2000-2009 Torus Knot Software Ltd
+Copyright (c) 2000-2012 Torus Knot Software Ltd
 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
 // Program Name: FFPLib_Lighting
 // Program Desc: Lighting functions of the FFP.
 // Program Type: Vertex shader
-// Language: CG
+// Language: GLSL
 // Notes: Implements core functions for FFPLighting class.
 // based on lighting engine. 
-// See http://msdn.microsoft.com/en-us/library/ee422035.aspx
+// See http://msdn.microsoft.com/en-us/library/bb147178.aspx
 //-----------------------------------------------------------------------------
 
 
 				   in vec3 vBaseColour, 
 				   out vec3 vOut)
 {
-	vec3 vNormalView = normalize(mat3(mWorldViewIT) * vNormal);	
+	vec3 vNormalView = normalize((mWorldViewIT * vec4(vNormal.xyz, 1.0)).xyz); 
 	float nDotL = dot(vNormalView, vNegLightDirView);
 	
 	vOut = vBaseColour + vDiffuseColour * clamp(nDotL, 0.0, 1.0);
 	vOutDiffuse  = vBaseDiffuseColour;
 	vOutSpecular = vBaseSpecularColour;
 	
-	vec3 vNormalView = normalize(mat3(mWorldViewIT) * vNormal);		
+	vec3 vNormalView = normalize((mWorldViewIT * vec4(vNormal.xyz, 1.0)).xyz); 	
 	float nDotL		   = dot(vNormalView, vNegLightDirView);			
 	vec3 vView       = -normalize((mWorldView* vPos).xyz);
 	vec3 vHalfWay    = normalize(vView + vNegLightDirView);
 	vec3 vViewPos    = (mWorldView * vPos).xyz;
 	vec3 vLightView  = vLightPosView - vViewPos;
 	float fLightD      = length(vLightView);
-	vec3 vNormalView = normalize(mat3(mWorldViewIT) * vNormal);	
+	vec3 vNormalView = normalize((mWorldViewIT * vec4(vNormal.xyz, 1.0)).xyz); 
 	float nDotL        = dot(vNormalView, normalize(vLightView));
 	
 	if (nDotL > 0.0 && fLightD <= vAttParams.x)
 	float fLightD      = length(vLightView);
 	
 	vLightView		   = normalize(vLightView);	
-	vec3 vNormalView = normalize(mat3(mWorldViewIT) * vNormal);	
+	vec3 vNormalView = normalize((mWorldViewIT * vec4(vNormal.xyz, 1.0)).xyz); 
 	float nDotL        = dot(vNormalView, vLightView);	
 		
 	if (nDotL > 0.0 && fLightD <= vAttParams.x)
 	vec3 vLightView  = vLightPosView - vViewPos;
 	float fLightD      = length(vLightView);
 	vLightView		   = normalize(vLightView);
-	vec3 vNormalView = normalize(mat3(mWorldViewIT) * vNormal);	
+	vec3 vNormalView = normalize((mWorldViewIT * vec4(vNormal.xyz, 1.0)).xyz); 	
 	float nDotL        = dot(vNormalView, vLightView);
 	
 	if (nDotL > 0.0 && fLightD <= vAttParams.x)
 	vec3 vLightView  = vLightPosView - vViewPos;
 	float fLightD      = length(vLightView);
 	vLightView		   = normalize(vLightView);
-	vec3 vNormalView = normalize(mat3(mWorldViewIT) * vNormal);	
+	vec3 vNormalView = normalize((mWorldViewIT * vec4(vNormal.xyz, 1.0)).xyz); 	
 	float nDotL        = dot(vNormalView, vLightView);
 	
 	

File media/rtshaderlib/FFPLib_Lighting.hlsl

-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2009 Torus Knot Software Ltd
-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 above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-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.
------------------------------------------------------------------------------
-*/
-
-//-----------------------------------------------------------------------------
-// Program Name: FFPLib_Lighting
-// Program Desc: Lighting functions of the FFP.
-// Program Type: Vertex shader
-// Language: HLSL
-// Notes: Implements core functions for FFPLighting class.
-// based on lighting engine. 
-// See http://msdn.microsoft.com/en-us/library/ee422035.aspx
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Directional_Diffuse(in float4x4 mWorldViewIT, 
-				   in float3 vNormal,
-				   in float3 vNegLightDirView,
-				   in float3 vDiffuseColour, 
-				   in float3 vBaseColour, 
-				   out float3 vOut)
-{
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL = dot(vNormalView, vNegLightDirView);
-	
-	vOut = vBaseColour + vDiffuseColour * saturate(nDotL);
-}
-
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Directional_DiffuseSpecular(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-					in float3 vNormal,
-					in float3 vNegLightDirView,
-					in float3 vDiffuseColour, 
-					in float3 vSpecularColour, 
-					in float fSpecularPower, 
-					in float3 vBaseDiffuseColour,
-					in float3 vBaseSpecularColour,					
-					out float3 vOutDiffuse,
-					out float3 vOutSpecular)
-{
-	vOutDiffuse  = vBaseDiffuseColour;
-	vOutSpecular = vBaseSpecularColour;
-	
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));		
-	float nDotL		   = dot(vNormalView, vNegLightDirView);			
-	float3 vView       = -normalize(mul(mWorldView, vPos).xyz);
-	float3 vHalfWay    = normalize(vView + vNegLightDirView);
-	float nDotH        = dot(vNormalView, vHalfWay);
-	
-	if (nDotL > 0)
-	{
-		vOutDiffuse  += vDiffuseColour * nDotL;		
-		vOutSpecular += vSpecularColour * pow(saturate(nDotH), fSpecularPower);						
-	}
-}
-
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Point_Diffuse(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float4 vAttParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vBaseColour, 
-				    out float3 vOut)
-{
-	vOut = vBaseColour;		
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, normalize(vLightView));
-	
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{
-		float fAtten	   = 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);
-			
-		vOut += vDiffuseColour * nDotL * fAtten;
-	}		
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Point_DiffuseSpecular(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float4 vAttParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vSpecularColour, 
-					in float fSpecularPower, 
-				    in float3 vBaseDiffuseColour,
-					in float3 vBaseSpecularColour,					
-					out float3 vOutDiffuse,
-					out float3 vOutSpecular)
-{
-	vOutDiffuse  = vBaseDiffuseColour;
-	vOutSpecular = vBaseSpecularColour;
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	
-	vLightView		   = normalize(vLightView);	
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, vLightView);	
-		
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{					
-		float3 vView       = -normalize(vViewPos);			
-		float3 vHalfWay    = normalize(vView + vLightView);		
-		float nDotH        = dot(vNormalView, vHalfWay);
-		float fAtten	   = 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);					
-		
-		vOutDiffuse  += vDiffuseColour * nDotL * fAtten;
-		vOutSpecular += vSpecularColour * pow(saturate(nDotH), fSpecularPower) * fAtten;					
-	}		
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Spot_Diffuse(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float3 vNegLightDirView,
-				    in float4 vAttParams,
-				    in float3 vSpotParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vBaseColour, 
-				    out float3 vOut)
-{
-	vOut = vBaseColour;		
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	vLightView		   = normalize(vLightView);
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, vLightView);
-	
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{
-		float fAtten	= 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);
-		float rho		= dot(vNegLightDirView, vLightView);						
-		float fSpotE	= saturate((rho - vSpotParams.y) / (vSpotParams.x - vSpotParams.y));
-		float fSpotT	= pow(fSpotE, vSpotParams.z);	
-						
-		vOut += vDiffuseColour * nDotL * fAtten * fSpotT;
-	}		
-}
-
-//-----------------------------------------------------------------------------
-void FFP_Light_Spot_DiffuseSpecular(in float4x4 mWorldView, 
-					in float4 vPos,
-					in float4x4 mWorldViewIT, 
-				    in float3 vNormal,
-				    in float3 vLightPosView,
-				    in float3 vNegLightDirView,
-				    in float4 vAttParams,
-				    in float3 vSpotParams,
-				    in float3 vDiffuseColour, 
-				    in float3 vSpecularColour, 
-					in float fSpecularPower, 
-				    in float3 vBaseDiffuseColour,
-					in float3 vBaseSpecularColour,					
-					out float3 vOutDiffuse,
-					out float3 vOutSpecular)
-{
-	vOutDiffuse  = vBaseDiffuseColour;		
-	vOutSpecular = vBaseSpecularColour;
-
-	float3 vViewPos    = mul(mWorldView, vPos).xyz;
-	float3 vLightView  = vLightPosView - vViewPos;
-	float fLightD      = length(vLightView);
-	vLightView		   = normalize(vLightView);
-	float3 vNormalView = normalize(mul((float3x3)mWorldViewIT, vNormal));
-	float nDotL        = dot(vNormalView, vLightView);
-	
-	
-	
-	if (nDotL > 0 && fLightD <= vAttParams.x)
-	{
-		float3 vView       = -normalize(vViewPos);	
-		float3 vHalfWay    = normalize(vView + vLightView);				
-		float nDotH        = dot(vNormalView, vHalfWay);
-		float fAtten	= 1 / (vAttParams.y + vAttParams.z*fLightD + vAttParams.w*fLightD*fLightD);
-		float rho		= dot(vNegLightDirView, vLightView);						
-		float fSpotE	= saturate((rho - vSpotParams.y) / (vSpotParams.x - vSpotParams.y));
-		float fSpotT	= pow(fSpotE, vSpotParams.z);	
-						
-		vOutDiffuse  += vDiffuseColour * nDotL * fAtten * fSpotT;
-		vOutSpecular += vSpecularColour * pow(saturate(nDotH), fSpecularPower) * fAtten * fSpotT;
-	}		
-}

File media/rtshaderlib/FFPLib_Texturing.cg

-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2009 Torus Knot Software Ltd
-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 above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-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.
------------------------------------------------------------------------------
-*/
-
-//-----------------------------------------------------------------------------
-// Program Name: FFPLib_TextureStage
-// Program Desc: Texture functions of the FFP.
-// Program Type: Vertex/Pixel shader
-// Language: CG
-// Notes: Implements core functions for FFPTexturing class.
-// based on texturing operations needed by render system.
-// Implements texture coordinate processing:
-// see http://msdn.microsoft.com/en-us/library/ee422494.aspx
-// Implements texture blending operation:
-// see http://msdn.microsoft.com/en-us/library/ee422488.aspx
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-void FFP_TransformTexCoord(in float4x4 m, in float2 v, out float2 vOut)
-{
-	vOut = mul(m, float4(v, 0, 1)).xy;
-}
-
-//-----------------------------------------------------------------------------
-void FFP_TransformTexCoord(in float4x4 m, in float3 v, out float3 vOut)
-{