2
0

normalmap.fx 751 B

1234567891011121314151617181920212223242526272829303132
  1. // Effect applies normalmapped lighting to a 2D sprite.
  2. float3 LightDirection;
  3. float3 LightColor = 1.5;
  4. float3 AmbientColor = 0;
  5. sampler TextureSampler : register(s0);
  6. sampler NormalSampler : register(s1);
  7. float4 main(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
  8. {
  9. // Look up the texture and normalmap values.
  10. float4 tex = tex2D(TextureSampler, texCoord);
  11. float3 normal = tex2D(NormalSampler, texCoord);
  12. // Compute lighting.
  13. float lightAmount = max(dot(normal, LightDirection), 0);
  14. color.rgb *= AmbientColor + lightAmount * LightColor;
  15. return tex * color;
  16. }
  17. technique Normalmap
  18. {
  19. pass Pass1
  20. {
  21. PixelShader = compile ps_2_0 main();
  22. }
  23. }