FILEVERSION = 1.5.0.0;
LIBVERSION = 3.0.0.0;
PLATFORM = xenondx;

CONSTANTS {
}

SHADER point_bump_spec {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  STAGE 1 = {
  }
  STAGE 2 = {
    texturetype = normalmap;
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 EyePos : register(c129);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 HalfAngleTS : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(In.Tangent, In.Normal);
  float3 nrmTangent = normalize(In.Tangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - In.ObjPos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, In.Normal, nrmBiNormal);

  Out.LightVector = LightDir; 

  /* Compute half-angle vector */
  float3 EyeDir = EyePos - In.ObjPos;
  float3 EyeTS =  GetVectorInTextureSpace(EyeDir, nrmTangent, In.Normal, nrmBiNormal);
  Out.HalfAngleTS = EyeTS + Out.LightTS;
  
  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 HalfAngleTS : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  float3 EyeSpaceNormal = mul((float3x3)mMV, In.Normal);
  float3 EyeSpaceTangent = mul((float3x3)mMV, In.Tangent);
  float4 EyeSpacePos = mul(mMV, In.ObjPos);

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(EyeSpaceTangent, EyeSpaceNormal);
  float3 nrmTangent = normalize(EyeSpaceTangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - EyeSpacePos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, EyeSpaceNormal, nrmBiNormal);

  Out.LightVector = LightDir; 

  /* Compute half-angle vector */
  float3 EyeDir = - EyeSpacePos;
  float3 EyeTS =  GetVectorInTextureSpace(EyeDir, nrmTangent, EyeSpaceNormal, nrmBiNormal);
  Out.HalfAngleTS = EyeTS + Out.LightTS;
  
  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 2;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 1000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 0.643137,0.901961,1.000000,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);
sampler2D NormalMap : register(s1);

/*
LightParams:
x = Intensity
y = Specular Exponent
z = Specular Multiplier
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 HalfAngleTS : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
};                                             

float GetSpecularIlluminationPoint(float3 HalfAngleInTextureSpace, float3 Normal, float Exp, float Mult)
{
    float SpecProd;
    float3 nrmHalfAngleVec = normalize(HalfAngleInTextureSpace.xyz);
    SpecProd = dot(nrmHalfAngleVec, Normal);
    SpecProd = pow(SpecProd, Exp) * Mult;
    return SpecProd;
}

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;

  float3 NormLightVec = normalize(In.LightTS);

  float4 NormalMapValue = tex2D(NormalMap, In.TexMapCoord);
  NormalMapValue = (NormalMapValue * 2.0) - 1.0;
  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  float DotProd = dot(NormLightVec.xyz, NormalMapValue.xyz);

  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd;
  ResColor *= LightColor.xyzz;

  bool UseSpecular = true;
  if (UseSpecular) {
    float SpecProd = GetSpecularIlluminationPoint(In.HalfAngleTS, NormalMapValue.xyz, LightParams.y, LightParams.z);
    SpecProd *= NormalMapValue.a;
    SpecProd = clamp(SpecProd * LightInt * DotProd, 0.0, 1.0);
    ResColor += SpecProd * LightColor;
  }

  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

SHADER point_bump_diff {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  STAGE 1 = {
  }
  STAGE 2 = {
    texturetype = normalmap;
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 LightVector : TEXCOORD3;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(In.Tangent, In.Normal);
  float3 nrmTangent = normalize(In.Tangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - In.ObjPos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, In.Normal, nrmBiNormal);

  Out.LightVector = LightDir; 
  
  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 LightVector : TEXCOORD3;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  float3 EyeSpaceNormal = mul((float3x3)mMV, In.Normal);
  float3 EyeSpaceTangent = mul((float3x3)mMV, In.Tangent);
  float4 EyeSpacePos = mul(mMV, In.ObjPos);

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(EyeSpaceTangent, EyeSpaceNormal);
  float3 nrmTangent = normalize(EyeSpaceTangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - EyeSpacePos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, EyeSpaceNormal, nrmBiNormal);

  Out.LightVector = LightDir; 
  
  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 2;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 100000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 1.000000,1.000000,1.000000,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);
sampler2D NormalMap : register(s1);

/*
LightParams:
x = Intensity
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 LightVector : TEXCOORD3;
};                                             

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;
 
  float3 NormLightVec = normalize(In.LightTS);

  float4 NormalMapValue = tex2D(NormalMap, In.TexMapCoord);
  NormalMapValue = (NormalMapValue * 2.0) - 1.0;
  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  float DotProd = dot(NormLightVec.xyz, NormalMapValue.xyz);
  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd;

  ResColor *= LightColor.xyzz;
  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

SHADER point_flat_spec {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  STAGE 1 = {
  }
  STAGE 2 = {
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 EyePos : register(c129);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 HalfAngleVector : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;
  Out.Normal = In.Normal;

  Out.LightVector = LightPos.xyz - In.ObjPos.xyz;
  float3 EyeVector = EyePos.xyz - In.ObjPos.xyz;
  Out.HalfAngleVector = EyeVector + Out.LightVector;

  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 HalfAngleVector : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  float4 EyeSpacePos = mul(mMV, In.ObjPos);

  Out.Normal = mul((float3x3)mMV, In.Normal);

  Out.LightVector = LightPos.xyz - EyeSpacePos;
  float3 EyeVector = - EyeSpacePos;
  Out.HalfAngleVector = EyeVector + Out.LightVector.xyz;

  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 2;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 100000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 1.000000,0.000000,0.501961,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);

/*
LightParams:
x = Intensity
y = Specular Exponent
z = Specular Multiplier
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 HalfAngleVector : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
};                                             

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;

  float3 NormLightVec = normalize(In.LightVector);
  float3 NormNormal = normalize(In.Normal);
  float DotProd = clamp(dot(NormLightVec, NormNormal), 0.0f, 1.0f);

  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd;
  ResColor *= LightColor.xyzz;

  bool UseSpecular = true;
  if (UseSpecular) {
    float3 NormHalfAngle = normalize(In.HalfAngleVector);
    float SpecProd = dot(NormHalfAngle, NormNormal);
    SpecProd = pow(SpecProd, LightParams.y) * LightParams.z;
    SpecProd = clamp(SpecProd * LightInt * DotProd, 0.0, 1.0);
    ResColor += SpecProd*LightColor;
  }

  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

SHADER point_flat_diff {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  STAGE 1 = {
  }
  STAGE 2 = {
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;
  Out.Normal = In.Normal;
  Out.LightVector = LightPos.xyz - In.ObjPos.xyz;

  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  Out.Normal = mul((float3x3)mMV, In.Normal);
  float4 WorldSpacePos = mul(mMV, In.ObjPos);
  Out.LightVector = LightPos.xyz - WorldSpacePos.xyz;

  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 2;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 10000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 0.643137,0.901961,1.000000,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);

/*
LightParams:
x = Intensity
y = Specular Exponent
z = Specular Multiplier
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
};                                             

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;

  float3 NormLightVec = normalize(In.LightVector);
  float3 NormNormal = normalize(In.Normal);
  float DotProd = clamp(dot(NormLightVec, NormNormal), 0.0f, 1.0f);

  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd;
  ResColor *= LightColor.xyzz;

  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

SHADER spot_bump_spec {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  numstages = 3;
  STAGE 1 = {
  }
  STAGE 2 = {
    texturetype = normalmap;
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  STAGE 3 = {
    texturetype = texture_index;
    textureindex = nomodifier("attenuation_lin.tex",clamp,nos3tc);
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 EyePos : register(c129);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);


struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 HalfAngleTS : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(In.Tangent, In.Normal);
  float3 nrmTangent = normalize(In.Tangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - In.ObjPos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, In.Normal, nrmBiNormal);

  Out.LightVector = LightDir; 

  /* Compute half-angle vector */
  float3 EyeDir = EyePos - In.ObjPos;
  float3 EyeTS =  GetVectorInTextureSpace(EyeDir, nrmTangent, In.Normal, nrmBiNormal);
  Out.HalfAngleTS = EyeTS + Out.LightTS;

  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, In.ObjPos);
  Out.ProjTexCoord.y = mul(RefPlaneY, In.ObjPos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, In.ObjPos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;
  
  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 HalfAngleTS : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  float3 EyeSpaceNormal = mul((float3x3)mMV, In.Normal);
  float3 EyeSpaceTangent = mul((float3x3)mMV, In.Tangent);
  float4 EyeSpacePos = mul(mMV, In.ObjPos);

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(EyeSpaceTangent, EyeSpaceNormal);
  float3 nrmTangent = normalize(EyeSpaceTangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - EyeSpacePos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, EyeSpaceNormal, nrmBiNormal);

  Out.LightVector = LightDir; 

  /* Compute half-angle vector */
  float3 EyeDir = - EyeSpacePos;
  float3 EyeTS =  GetVectorInTextureSpace(EyeDir, nrmTangent, EyeSpaceNormal, nrmBiNormal);
  Out.HalfAngleTS = EyeTS + Out.LightTS;
  
  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, EyeSpacePos);
  Out.ProjTexCoord.y = mul(RefPlaneY, EyeSpacePos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, EyeSpacePos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;

  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 5;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 1000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 0.643137,0.901961,1.000000,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);
sampler2D NormalMap : register(s1);
sampler2D ProjTex : register(s2);

/*
LightParams:
x = Intensity
y = Specular Exponent
z = Specular Multiplier
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 HalfAngleTS : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float GetSpecularIlluminationPoint(float3 HalfAngleInTextureSpace, float3 Normal, float Exp, float Mult)
{
    float SpecProd;
    float3 nrmHalfAngleVec = normalize(HalfAngleInTextureSpace.xyz);
    SpecProd = dot(nrmHalfAngleVec, Normal);
    SpecProd = pow(SpecProd, Exp) * Mult;
    return SpecProd;
}

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;

  float3 NormLightVec = normalize(In.LightTS);

  float4 NormalMapValue = tex2D(NormalMap, In.TexMapCoord);
  NormalMapValue = (NormalMapValue * 2.0) - 1.0;
  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  float DotProd = dot(NormLightVec.xyz, NormalMapValue.xyz);

  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd; 
  ResColor *= LightColor.xyzz;

  float4 ProjCol = tex2Dproj(ProjTex, In.ProjTexCoord);
  ResColor *=ProjCol;

  bool UseSpecular = true;
  if (UseSpecular) {
    float SpecProd = GetSpecularIlluminationPoint(In.HalfAngleTS, NormalMapValue.xyz, LightParams.y, LightParams.z);
    SpecProd *= NormalMapValue.a;
    SpecProd = clamp(SpecProd * LightInt * DotProd, 0.0, 1.0);
    ResColor += SpecProd * LightColor * ProjCol;
  }

  /* Remove backprojection */
  ResColor*=clamp(sign(In.ProjTexCoord.w),0.0f,1.0f);

  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

SHADER spot_bump_diff {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  numstages = 3;
  STAGE 1 = {
  }
  STAGE 2 = {
    texturetype = normalmap;
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  STAGE 3 = {
    texturetype = texture_index;
    textureindex = nomodifier("attenuation_lin.tex",clamp,nos3tc);
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 LightVector : TEXCOORD3;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(In.Tangent, In.Normal);
  float3 nrmTangent = normalize(In.Tangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - In.ObjPos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, In.Normal, nrmBiNormal);

  Out.LightVector = LightDir; 

  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, In.ObjPos);
  Out.ProjTexCoord.y = mul(RefPlaneY, In.ObjPos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, In.ObjPos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;
  
  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);


struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;   
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 LightVector : TEXCOORD3;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float3 ComputeBiNormal(float3 Tangent, float3 Normal)
{
  float len = dot(Tangent, Tangent);
  float3 BiNormal = cross(Tangent, Normal) * (len - 2.0f);
  BiNormal = normalize(BiNormal);
  return BiNormal;
}

float3 GetVectorInTextureSpace(float3 InVector, float3 Tangent, float3 Normal, float3 BiNormal)
{
  float3 OutVector;
  OutVector.x = dot (BiNormal, InVector);
  OutVector.y = dot (Tangent, InVector);
  OutVector.z = dot (Normal, InVector);
  return OutVector;
}

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                
  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  float3 EyeSpaceNormal = mul((float3x3)mMV, In.Normal);
  float3 EyeSpaceTangent = mul((float3x3)mMV, In.Tangent);
  float4 EyeSpacePos = mul(mMV, In.ObjPos);

  /* Create normalized Texture Space */
  float3 nrmBiNormal = ComputeBiNormal(EyeSpaceTangent, EyeSpaceNormal);
  float3 nrmTangent = normalize(EyeSpaceTangent);
  
  /* Get Light in Texture Space */
  float3 LightDir = LightPos.xyz - EyeSpacePos.xyz;
  Out.LightTS = GetVectorInTextureSpace(LightDir, nrmTangent, EyeSpaceNormal, nrmBiNormal);

  Out.LightVector = LightDir; 

  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, EyeSpacePos);
  Out.ProjTexCoord.y = mul(RefPlaneY, EyeSpacePos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, EyeSpacePos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;
  
  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 5;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 100000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 1.000000,1.000000,1.000000,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);
sampler2D NormalMap : register(s1);
sampler2D ProjTex : register(s2);

/*
LightParams:
x = Intensity
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightTS : TEXCOORD1;
  float3 LightVector : TEXCOORD3;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;
 
  float3 NormLightVec = normalize(In.LightTS);

  float4 NormalMapValue = tex2D(NormalMap, In.TexMapCoord);
  NormalMapValue = (NormalMapValue * 2.0) - 1.0;
  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  float DotProd = dot(NormLightVec.xyz, NormalMapValue.xyz);
  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd;

  float4 ProjCol = tex2Dproj(ProjTex, In.ProjTexCoord);
  ResColor *= ProjCol;
  ResColor *= LightColor.xyzz;

  /* Remove backprojection */
  ResColor*=clamp(sign(In.ProjTexCoord.w),0.0f,1.0f);

  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

SHADER spot_flat_spec {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  numstages = 3;
  STAGE 1 = {
  }
  STAGE 2 = {
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  STAGE 3 = {
    texturetype = texture_index;
    textureindex = nomodifier("attenuation_lin.tex",clamp,nos3tc);
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 EyePos : register(c129);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 HalfAngleVector : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;
  Out.Normal = In.Normal;

  Out.LightVector = LightPos.xyz - In.ObjPos.xyz;
  float3 EyeVector = EyePos.xyz - In.ObjPos.xyz;
  Out.HalfAngleVector = EyeVector + Out.LightVector;

  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, In.ObjPos);
  Out.ProjTexCoord.y = mul(RefPlaneY, In.ObjPos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, In.ObjPos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;

  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 HalfAngleVector : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  float4 EyeSpacePos = mul(mMV, In.ObjPos);

  Out.Normal = mul((float3x3)mMV, In.Normal);

  Out.LightVector = LightPos.xyz - EyeSpacePos;
  float3 EyeVector = - EyeSpacePos;
  Out.HalfAngleVector = EyeVector + Out.LightVector.xyz;

  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, EyeSpacePos);
  Out.ProjTexCoord.y = mul(RefPlaneY, EyeSpacePos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, EyeSpacePos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;

  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 5;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 100000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 1.000000,0.000000,0.501961,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);
sampler2D ProjTex : register(s2);
/*
LightParams:
x = Intensity
y = Specular Exponent
z = Specular Multiplier
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 HalfAngleVector : TEXCOORD2;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;

  float3 NormLightVec = normalize(In.LightVector);
  float3 NormNormal = normalize(In.Normal);
  float DotProd = clamp(dot(NormLightVec, NormNormal), 0.0f, 1.0f);

  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd;
  ResColor *= LightColor.xyzz;

  float4 ProjCol = tex2Dproj(ProjTex, In.ProjTexCoord);
  ResColor *= ProjCol;

  bool UseSpecular = true;
  if (UseSpecular) {
    float3 NormHalfAngle = normalize(In.HalfAngleVector);
    float SpecProd = dot(NormHalfAngle, NormNormal);
    SpecProd = pow(SpecProd, LightParams.y) * LightParams.z;
    SpecProd = clamp(SpecProd * LightInt * DotProd, 0.0, 1.0);
    ResColor += SpecProd*LightColor*ProjCol;
  }

  /* Remove backprojection */
  ResColor*=clamp(sign(In.ProjTexCoord.w),0.0f,1.0f);

  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

SHADER spot_flat_diff {
  renderbasepass = true;
  useblending = true;
  zfunction = equal;
  faceculling = back;
  fogpass = true;
  numstages = 3;
  STAGE 1 = {
  }
  STAGE 2 = {
    envmode = modulate;
    texgen_s = tangent_vector;
    texgen_t = tangent_vector;
    texgen_r = tangent_vector;
  }
  STAGE 3 = {
    texturetype = texture_index;
    textureindex = nomodifier("attenuation_lin.tex",clamp,nos3tc);
  }
  perframe_callback = none;
  perrenderscene_callback = none;
  perpolygon_callback = none;
  lightsourcekey = none;
  usevertexprg = true;
  useworldvp = false;
  vp_syntax = xenon;
  vertexprogram=$SOURCECODETAG{
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;
  Out.Normal = In.Normal;
  Out.LightVector = LightPos.xyz - In.ObjPos.xyz;

  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, In.ObjPos);
  Out.ProjTexCoord.y = mul(RefPlaneY, In.ObjPos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, In.ObjPos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;

  return Out;                              
}
  }$SOURCECODETAG
  vertexprogram_model=$SOURCECODETAG{
float4x4 mMV : register(c0);
float4x4 mMVP : register(c8);
float4 LightPos : register(c128);
float4 RefPlaneX : register(c130);
float4 RefPlaneY : register(c131);
float4 RefPlaneW : register(c132);

struct VS_IN                   
{                              
  float4 ObjPos   : POSITION;  
  float2 UV0 : TEXCOORD0;  
  float3 Tangent : TEXCOORD1;  
  float3 Normal : NORMAL;
};                                           

struct VS_OUT                                 
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

VS_OUT main( VS_IN In )                        
{                                              
  VS_OUT Out;                                

  Out.ProjPos = mul( mMVP, In.ObjPos );  
  Out.TexMapCoord = In.UV0;

  Out.Normal = mul((float3x3)mMV, In.Normal);
  float4 EyeSpacePos = mul(mMV, In.ObjPos);
  Out.LightVector = LightPos.xyz - EyeSpacePos.xyz;

  /*Compute projected texture coordinate*/
  Out.ProjTexCoord.x = mul(RefPlaneX, EyeSpacePos);
  Out.ProjTexCoord.y = mul(RefPlaneY, EyeSpacePos);
  Out.ProjTexCoord.z = 0.0f;
  Out.ProjTexCoord.w = mul(RefPlaneW, EyeSpacePos);
  float4 bias = Out.ProjTexCoord.w*float4(0.5f, 0.5f, 0.0f, 0.0f);
  Out.ProjTexCoord += bias;

  return Out;                              
}
  }$SOURCECODETAG
  numcustomparams = 5;
  usefragmentshader = true;
  fragment_syntax = xenon;
  numfragmentconst = 2;
  fragmentscale_bitmask = 2;
  fragmentconst0 = 10000.000000,16.000000,1.000000,0.000000;
  fragmentconst1 = 0.643137,0.901961,1.000000,1.000000;
  fragmentshader=$SOURCECODETAG{
sampler2D BaseTexture : register(s0);
sampler2D ProjTex : register(s2);

/*
LightParams:
x = Intensity
y = Specular Exponent
z = Specular Multiplier
*/ 
float4 LightParams : register(c16);
float4 LightColor : register(c17);
 
struct PS_IN  
{                                             
  float4 ProjPos  : POSITION;              
  float2 TexMapCoord : TEXCOORD0;
  float3 LightVector : TEXCOORD3;
  float3 Normal : TEXCOORD1;
  float4 ProjTexCoord : TEXCOORD4;
};                                             

float4 main( PS_IN In ) : COLOR              
{
  float LightInt = rsqrt(dot(In.LightVector, In.LightVector));
  LightInt = LightInt * LightParams.x;

  float3 NormLightVec = normalize(In.LightVector);
  float3 NormNormal = normalize(In.Normal);
  float DotProd = clamp(dot(NormLightVec, NormNormal), 0.0f, 1.0f);

  float4 BaseMapValue = tex2D(BaseTexture, In.TexMapCoord);

  LightInt = clamp(LightInt - LightParams.w, 0.0, 1.0);
  float4 ResColor = BaseMapValue * LightInt * DotProd;
  ResColor *= LightColor.xyzz;
  float4 ProjCol = tex2Dproj(ProjTex, In.ProjTexCoord);
  ResColor *= ProjCol;

  /* Remove backprojection */
  ResColor*=clamp(sign(In.ProjTexCoord.w),0.0f,1.0f);

  ResColor.a = BaseMapValue.a;

  return ResColor;
}
  }$SOURCECODETAG
  PARAMETER = LightPosition,c[128];
  PARAMETER = EyePosition,c[129];
  PARAMETER = LightParams,fragmentconst0;
  PARAMETER = LightColor,fragmentconst1;
}

EFFECT point_world_bump_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_bump_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_diff};
}

EFFECT point_world_flat_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_world_flat_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_diff};
}

EFFECT point_world_bump_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_bump_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_bump_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_bump_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_bump_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_bump_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_bump_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_diff};
}

EFFECT point_model_bump_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_model_bump_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_bump_spec};
}

EFFECT point_world_flat_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_world_flat_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_world_flat_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_world_flat_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_world_flat_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_world_flat_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_world_flat_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_diff};
}

EFFECT point_model_flat_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT point_model_flat_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={point_flat_spec};
}

EFFECT spot_world_bump_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_model_bump_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_spec};
}

EFFECT spot_world_bump_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_diff};
}

EFFECT spot_model_bump_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_bump_diff};
}

EFFECT spot_model_flat_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_diff};
}

EFFECT spot_world_flat_diff {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_diff};
}

EFFECT spot_world_flat_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_world_flat_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_world_flat_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_world_flat_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_world_flat_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_world_flat_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_world_flat_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_world_flat_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec1 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec2 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec3 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec4 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec5 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec6 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec7 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

EFFECT spot_model_flat_spec8 {
  DESCRIPTION = {};
  FALLBACK(fallback 1)={spot_flat_spec};
}

