    struct Vertex2Fragment
    {
        float4 projectedPt : POSITION; // Clip-space position of the vertex.
        float4 uv : TEXCOORD0;         // Texture coordinates for the vertex.
        float3 eyeVec : TEXCOORD1;     // Eye vector in TANGENT-SPACE.
        float4 light0 : TEXCOORD2;     // Light-0 definition in TANGENT-SPACE.
        float4 light1 : TEXCOORD3;     // Light-1 definition in TANGENT-SPACE.
    };

    uniform sampler2D diffuseMap  : TEXUNIT0; /*{ bind: DiffuseMap  }*/
    uniform sampler2D normalMap   : TEXUNIT1; /*{ bind: NormalMap   }*/

    uniform float4 lightingCoeff; /*{ bind: Ambient, Diffuse, Specular, GlossPower }*/
    uniform float4 l0_AttCoeff;   /*{ bind: Light0.Attenuation, null, null, null   }*/
    uniform float4 l1_AttCoeff;   /*{ bind: Light1.Attenuation, null, null, null   }*/
    uniform float4 miscData;      /*{ bind: Opacity, BumpRatio, null, null         }*/

    float4 main( Vertex2Fragment input ) : COLOR    
    {
        float const ambientFactor = lightingCoeff.x;
        float const diffuseFactor = lightingCoeff.y;
        float const specularFactor = lightingCoeff.z;
        float const glossiness = lightingCoeff.w;
        float const opaqueness = miscData.x;
        float const bumpRatio = miscData.y;
	float3 const fogColour = float3( 0.2, 0.2, 0.2 );
	
        float3 const E = normalize(input.eyeVec);
        float const kR = (glossiness + 2.0) * 0.1591549;

        float3 const L0 = normalize(input.light0.xyz);
        float3 const L1 = normalize(input.light1.xyz);
        float3 const H0 = normalize(L0 + E);
        float3 const H1 = normalize(L1 + E);
        float const EL0 = dot(L0, E);
        float const EL1 = dot(L1, E);

        float termC0 = l0_AttCoeff.x;
        float termC1 = l0_AttCoeff.y * input.light0.w;
        float termC2 = l0_AttCoeff.z * input.light0.w * input.light0.w;
        float L0att = saturate(1.0 / (termC0 + termC1 + termC2));

        termC0 = l1_AttCoeff.x;
        termC1 = l1_AttCoeff.y * input.light1.w;
        termC2 = l1_AttCoeff.z * input.light1.w * input.light1.w;
        float L1att = saturate(1.0 / (termC0 + termC1 + termC2));

        float3 tc = input.uv.xyz;
        float4 colour = tex2D(diffuseMap, tc.xy);
        float3 N = normalize(tex2D(normalMap, tc.xy).xyz * 2.0 - 1.0);


        // ### Calculate DIFFUSE & SPECULAR REFLECTION co-efficients.

        float NE = dot(N, E);

        float kF = pow(1.0 - NE, 5);
        float F = (kF * (glossiness - 1.0)) + 1.0;

        float NH0 = dot(N, H0);
        float NL0 = dot(N, L0);  
        float minCosPheta0 = max(NE, NL0);
        float R0 = kR * pow(saturate(2.0 * NE * NL0 - EL0), glossiness) / minCosPheta0;
        float I0 = L0att * ((diffuseFactor * NL0) + (specularFactor * R0 * F)) * ceil(NL0);

        float NH1 = dot(N, H1);
        float NL1 = dot(N, L1);  
        float minCosPheta1 = max(NE, NL1);
        float R1 = kR * pow(saturate(2.0 * NE * NL1 - EL1), glossiness) / minCosPheta1;
        float I1 = L1att * ((diffuseFactor * NL1) + (specularFactor * R1 * F)) * ceil(NL1);

        float4 finalColour;
        finalColour.rgb = lerp(colour.rgb * saturate(I0 + I1), colour.rgb, ambientFactor);
        finalColour.a = colour.a * opaqueness;

//	finalColour.a = input.projectedPt.y;
	
//	finalColour.rgb = lerp(finalColour.rgb, fogColour.rgb, input.projectedPt.z );
	
        return finalColour;
    }
