Certainly can, its the BasicShader
float4x4 World;
float4x4 View;
float4x4 Projection;
float3 EyePosition;
float4 AmbientLightColor;
float4 DiffuseColor;
float SpecularPower;
float3 LightPosition;
float4 LightDiffuseColor;
float4 LightSpecularColor;
struct VS_INPUT {
float4 Position : POSITION0;
float3 Normal : NORMAL0;
};
struct VS_OUTPUT {
float4 Position : POSITION0;
float3 Normal : TEXCOORD1;
float3 ViewDirection : TEXCOORD2;
float3 LightDirection : TEXCOORD3;
};
VS_OUTPUT Transform(VS_INPUT Input){
float4x4 WorldViewProjection = mul(mul(World, View), Projection);
float3 ObjectPosition = mul(Input.Position, World);
VS_OUTPUT Output;
Output.Position = mul(Input.Position, WorldViewProjection);
Output.Normal = mul(Input.Normal, World);
Output.ViewDirection = EyePosition - ObjectPosition;
Output.LightDirection = LightPosition - ObjectPosition;
return Output;
}
struct PS_INPUT {
float3 Normal : TEXCOORD1;
float3 ViewDirection : TEXCOORD2;
float3 LightDirection : TEXCOORD3;
};
float4 BasicShader(PS_INPUT Input) : COLOR0{
float3 Normal = normalize(Input.Normal);
float3 ViewDirection = normalize(Input.ViewDirection);
float3 LightDirection = normalize(Input.LightDirection);
float EdgeComponent = dot(Normal, ViewDirection);
float4 TotalAmbient = saturate(AmbientLightColor * EdgeComponent);
float NDotL = dot(Normal, LightDirection);
float4 DiffuseAverage = (DiffuseColor + LightDiffuseColor) * 0.5f;
float4 TotalDiffuse = saturate(DiffuseAverage * NDotL);
float3 Reflection = normalize(2.0f * NDotL * Normal - LightDirection);
float RDotV = max(0.0f, dot(Reflection, ViewDirection));
float4 TotalSpecular = saturate(LightSpecularColor * pow(RDotV, SpecularPower));
float4 FinalColor = saturate(TotalAmbient + TotalDiffuse + TotalSpecular);
return FinalColor;
}
technique BasicShader {
pass P0 {
VertexShader = compile vs_2_0 Transform();
PixelShader = compile ps_2_0 BasicShader();
}
}
I have managed to get around it by combining the polygons in maya and exporting it as one model, but i would like to know why its doing that
