Basic effect per pixel lighting is looking good than a Custom effect normal mapping, well sometimes ^ _^ Y
I’m pretty sure the model is very familiar to XNA users ^_^y
EDIT : I know now why, my pixel lighting is using 3 light source and my custom effect Normal mapping is only using 1 light source. [ Need help on shader below ]
Guide me how to multiply 3 lights on my pixel shader my BasicEffect is using 3 light source and my Normal Mapping only using 1 light source.
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR
{
float4 m_Color = tex2D(ColorMapSampler, input.TexCoord);
float3 m_NormalMap = (2.0 * (tex2D(NormalMapSampler, input.TexCoord))) - 1.0 ;
m_NormalMap = normalize(mul(m_NormalMap, input.WorldToTangentSpace));
float m_Diffuse = saturate(dot(-__LightDirection, m_NormalMap));
float4 m_Reflect = normalize(2 * m_Diffuse*m_NormalMap - __LightDirection );
float m_Specular = pow(saturate(dot( m_Reflect, input.View)), 32);
return m_Color * AmbientColor * AmbientIntensity +
m_Color * DiffuseIntensity * DiffuseColor * m_Diffuse +
m_Color * SpecularColor * m_Specular;
}
The above code is only using __LightDirection :
What if I wanna add another __LightDirection1 and __LightDirection2 how can I combine to output color?
Do the same calculations for the extra lights, and then add them all together at the end.
float m_Diffuse = saturate(dot(-__LightDirection, m_NormalMap));
float4 m_Reflect = normalize(2 * m_Diffuse*m_NormalMap - __LightDirection );
float m_Specular = pow(saturate(dot( m_Reflect, input.View)), 32);
float m_Diffuse1 = saturate(dot(-__LightDirection1, m_NormalMap));
float4 m_Reflect1 = normalize(2 * m_Diffuse1*m_NormalMap - __LightDirection1 );
float m_Specular1 = pow(saturate(dot( m_Reflect1, input.View)), 32);
return m_Color * AmbientColor * AmbientIntensity +
m_Color * DiffuseIntensity * DiffuseColor * (m_Diffuse + m_Diffuse1) +
m_Color * SpecularColor * (m_Specular + m_Specular1);
That’s for one extra light, but you should get the idea.
1 Like
Hi Markus,
Appreciated much bro ^ _^ y … I’ll try it immediately !
Work’s like a charm bro ^ _^ y