Advertisement
Guest User

Untitled

a guest
Aug 18th, 2016
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. //LIGHTING
  2. texture texNormal;
  3. texture texPosition;
  4. texture texColor;
  5.  
  6. sampler gPosition = sampler_state
  7. {
  8. Texture = (texPosition);
  9. AddressU = CLAMP;
  10. AddressV = CLAMP;
  11. MagFilter = LINEAR;
  12. MinFilter = LINEAR;
  13. Mipfilter = LINEAR;
  14. };
  15. sampler gNormal = sampler_state
  16. {
  17. Texture = (texNormal);
  18. AddressU = CLAMP;
  19. AddressV = CLAMP;
  20. MagFilter = LINEAR;
  21. MinFilter = LINEAR;
  22. Mipfilter = LINEAR;
  23. };
  24. sampler gColor = sampler_state
  25. {
  26. Texture = (texColor);
  27. AddressU = CLAMP;
  28. AddressV = CLAMP;
  29. MagFilter = LINEAR;
  30. MinFilter = LINEAR;
  31. Mipfilter = LINEAR;
  32. };
  33.  
  34. const int Lights = 32;
  35. float3 lightPosition;
  36. float3 lightColor;
  37.  
  38. float3 viewPosition;
  39.  
  40. struct LightInput
  41. {
  42. float4 Position : POSITION;
  43. float2 UV : TEXCOORD;
  44. };
  45.  
  46. struct LightOutput
  47. {
  48. float4 Position : POSITION;
  49. float2 UV : TEXCOORD;
  50. };
  51.  
  52. LightOutput LightVS(LightInput input)
  53. {
  54. LightOutput output = (LightOutput)0;
  55.  
  56. output.Position = input.Position;
  57. output.UV = input.UV;
  58.  
  59. return output;
  60. }
  61.  
  62. float4 LightPS(LightOutput input) : COLOR
  63. {
  64. float3 fragPosition = tex2D(gPosition, input.UV).rgb;
  65. float3 normal = tex2D(gNormal, input.UV).rgb;
  66. float3 color = tex2D(gColor, input.UV).rgb;
  67.  
  68. float3 lighting = color*0.1;
  69. float3 viewDirection = normalize(viewPosition - fragPosition);
  70.  
  71. float3 lightDirection = normalize(lightPosition - fragPosition);
  72. float3 diffuse = max(dot(normal, lightDirection), 0) * color * lightColor;
  73. lighting += diffuse;
  74.  
  75. return float4(normal, 1);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement