Hi
I have recently finished a creature model that i plan on using in a demo project. but as is to be expected, things aren't quite what they're supposed to be.
The model is a subdivisions model converted to polygons built in Maya 4.
When the model is placed in WED the lighting on the model isnt quite what i expected.
I am using a shader to do phong lighting.
What could be the possible causes for the anomalies? See pics below:
[image]http://img2.freeimagehosting.net/image.php?87487c6f51.jpg[/image]
[image]http://img2.freeimagehosting.net/image.php?a2f0510331.jpg[/image]
also, here is the shader code, perhaps the problem is there?
Code:
float4x4 matView ;
float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecLightPos[8];
float4 vecLightColor[8];
struct VS_OUTPUT
{
float4 Pos : POSITION;
float3 Norm : TEXCOORD0;
float3 Light : TEXCOORD2;
float2 Tex : TEXCOORD4;
};
VS_OUTPUT Textured_Phong_Illumination_Single_Pass_Vertex_Shader_main(
float4 inPos : POSITION,
float3 inNorm : NORMAL,
float2 inTex : TEXCOORD0 )
{
VS_OUTPUT Out = (VS_OUTPUT) 0;
Out.Pos = mul( inPos, matWorldViewProj );
Out.Tex = inTex;
float3 Pview = mul( inPos, matWorld );
float3 llight = Pview-vecLightPos[1];
Out.Light = normalize( -llight);
Out.Norm = normalize( mul( inNorm, matWorld ) );
return Out;
}
float4 ambient = ( 0.93, 0.94, 0.94, 1.00 );
float4 diffuse = ( 0.84, 0.86, 0.89, 1.00 );
float4 specular = ( 1.00, 0.96, 0.67, 1.00 );
float n_specular = 7.00;
float Ka = 0.10;
float Ks = 1.00;
float Kd = 4.00;
texture entSkin1;
sampler baseMap = sampler_state
{
Texture = (entSkin1);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
};
float4 Textured_Phong_Illumination_Single_Pass_Pixel_Shader_main( float4 Diff : COLOR0,
float3 Normal : TEXCOORD0,
float3 View : TEXCOORD1,
float3 Light : TEXCOORD2,
float2 Tex : TEXCOORD4 ) : COLOR
{
float3 vReflect = normalize( 2 * dot( Normal, Light) * Normal - Light );
float4 AmbientColor = ambient * Ka;
float4 DiffuseColor = vecLightColor[1] * Kd * max( 0, dot( Normal, Light ));
float4 SpecularColor = specular * Ks * pow( max( 0, dot(vReflect, View)), n_specular );
float4 FinalColor;
float4 ad = (AmbientColor + DiffuseColor) * tex2D( baseMap, Tex) + SpecularColor;
FinalColor = ad;
float DFactor;
float D = length(vecLightPos[1].xyz)/vecLightPos[1].w;
if (D < 0.0)
DFactor = 1.0 - D;
FinalColor *= DFactor;
return FinalColor;
}
technique Textured_Phong_Illumination
{
pass Single_Pass
{
VertexShader = compile vs_1_1 Textured_Phong_Illumination_Single_Pass_Vertex_Shader_main();
PixelShader = compile ps_2_0 Textured_Phong_Illumination_Single_Pass_Pixel_Shader_main();
}
}