Advertisement
Guest User

Untitled

a guest
Apr 11th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float4x4 View;
  2. float4x4 Projection;
  3.  
  4. float3 LightDirection = float3(1, -1, 0);
  5. float TextureTiling = 1;
  6.  
  7. texture2D BaseTexture;
  8.  
  9. sampler2D BaseTextureSampler = sampler_state {
  10.     Texture = <BaseTexture>;
  11.     AdressU = Wrap;
  12.     AderssV = Wrap;
  13.     MinFilter = Anisotropic;
  14.     MaxFilter = Anisotropic;
  15. };
  16.  
  17. struct VertexShaderInput
  18. {
  19.     float4 Position : POSITION0;
  20.     float2 UV : TEXCORRD0;
  21.     float3 Normal : NORMAL0;
  22. };
  23.  
  24. struct VertexShaderOutput
  25. {
  26.     float4 Position : POSITION0;
  27.     float2 UV : TEXCOORD0;
  28.     float3 Normal : TEXCOORD1;
  29. };
  30.  
  31. VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
  32. {
  33.     VertexShaderOutput output;
  34.  
  35.     output.Position = mul(input.Position, mul(View, Projection));
  36.     output.Normal = input.Normal;
  37.     output.UV = input.UV;
  38.  
  39.     return output;
  40. }
  41.  
  42. float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
  43. {
  44.     float light = dot(normalize(input.Normal), normalize(LightDirection));
  45.     light = clamp(light + 0.4f, 0, 1);
  46.  
  47.     float3 tex = tex2D(BaseTextureSampler, input.UV * TextureTiling);
  48.  
  49.     return float4(tex * light, 1);
  50. }
  51.  
  52. technique Technique1
  53. {
  54.     pass Pass1
  55.     {
  56.         VertexShader = compile vs_2_0 VertexShaderFunction();
  57.         PixelShader = compile ps_2_0 PixelShaderFunction();
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement