material Spec_ef
{
effect ="struct VS_OUT
{
float4 Position : POSITION;
float4 Diffuse : COLOR0;
float4 Specular : COLOR1;
float2 TexCoord : TEXCOORD;
};
struct VS_IN
{
float4 Position : POSITION;
float3 Normal : NORMAL;
float2 TexCoord : TEXCOORD;
};
VS_OUT main(VS_IN In)
{
VS_OUT ret;
// Transform model vertex position to
// screen space.
ret.Position = mul(In.Position, MatrixWVP);
// Transform model vertex normal to view space
float3 ViewNormal = mul(In.Normal, (float3x3)MatrixWV);
ret.Diffuse = max(0, dot(ViewNormal, LightDirection));
// Find Eye Vector by Normalizing view position
float3 ViewDir = normalize(mul((float3)In.Position, (float3x3)MatrixWV));
// Calculate reflect vector
float3 ViewReflect = reflect(-ViewNormal, LightDirection);
ret.Specular = pow(max(0, dot(ViewReflect, ViewDir)), 4);
// Output texture coordinates to pixel shader
ret.TexCoord = In.TexCoord;
return ret;
}"
}
action spec_effect
{
my.material = spec_ef;
}
Plz help me, so that i can understand once and for all.