Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Texture2D ObjTexture;
  2. SamplerState ObjSamplerState;
  3.  
  4. struct Light
  5. {
  6. float3 dir;
  7. float4 ambient;
  8. float4 diffuse;
  9. };
  10.  
  11. cbuffer cbPerFrame
  12. {
  13. Light light;
  14. };
  15.  
  16. cbuffer cbPerObject
  17. {
  18. float4x4 WVP;
  19. float4x4 World;
  20. };
  21.  
  22. struct VS_OUT
  23. {
  24. float4 pos : SV_POSITION;
  25. float2 tex : TEXCOORD;
  26. float3 normal : NORMAL;
  27. };
  28.  
  29.  
  30. VS_OUT VS(float4 inPos : POSITION, float2 inTex : TEXCOORD, float3 inNormal : NORMAL )
  31. {
  32. VS_OUT output;
  33. output.pos = mul(inPos, WVP);
  34. output.tex = inTex;
  35. output.normal = mul(inNormal, World);
  36.  
  37. return output;
  38. }
  39.  
  40. float4 PS(VS_OUT input) : SV_TARGET
  41. {
  42. input.normal = normalize(input.normal);
  43. float4 diffRefl = ObjTexture.Sample(ObjSamplerState, input.tex);
  44.  
  45. float3 col;
  46.  
  47. col = diffRefl * light.ambient;
  48. col += saturate(dot(light.dir, input.normal) * light.diffuse * diffRefl);
  49.  
  50. return float4(col, diffRefl.a);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement