//VS
float4x4 B;
float4x4 o;
float4 n;
float4 _;
float4 A;
float4 n;
float4 n2;
float4 i;
float4 v;
float4 _;
float4 P;
float4 o2;
float4 l;
float4 o3;
struct VS_OUTPUT
{
float4 Pos: POSITION;
float3 Norm: TEXCOORD0;
float2 Tex: TEXCOORD1;
float3 View: TEXCOORD2;
float3 Light: TEXCOORD3;
};
VS_OUTPUT vs_main( float4 inPos: POSITION,
float3 inNorm:NORMAL,
float2 inTex: TEXCOORD0 )
{
VS_OUTPUT Out = (VS_OUTPUT) 0;
Out.Pos = mul(matViewProjection, inPos);
Out.Light = vDirLight;
Out.Tex = inTex;
float3 vPosWorld = normalize( mul( matWorld, inPos ) );
Out.View = normalize( vViewPosition - vPosWorld );
Out.Norm = normalize( mul( matWorld, inNorm ) );
return Out;
}
//PS
float fShinyness;
float4 colDiffuse;
float4 colSpecular;
float4 colAmbient;
float4 lightAmbient;
float4 lightDiffuse;
float4 lightSpecular;
float4 globalAmbient;
sampler Texture0;
float4 ps_main( float3 inNorm: TEXCOORD0,
float2 inTex: TEXCOORD1,
float3 inView: TEXCOORD2,
float3 inLight: TEXCOORD3 ) : COLOR
{
//normalize inputs
float3 vNormal = normalize(inNorm);
float3 vLight = -normalize(inLight);
float3 vView = normalize(inView);
//calc diffuse/specular
float fNormalDotLight = saturate ( dot(vNormal, vLight) );
float3 vLightReflect = 2.0*fNormalDotLight*vNormal - vLight;
float fViewDotReflect = saturate( dot(vView, vLightReflect) );
float4 fSpecIntensity = pow(fViewDotReflect, fShinyness);
float4 diffuse = fNormalDotLight * colDiffuse * lightDiffuse;
float4 specular = fSpecIntensity * colSpecular * lightSpecular;
float4 ambient = ( colAmbient * lightAmbient ) + globalAmbient;
return (ambient + diffuse) * tex2D(Texture0, inTex) + specular;
}