Guest User

GeometryPass.hlsl

a guest
Feb 8th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Texture2D diffuseTexture : register(t0);
  2. SamplerState textureSampler : register(s0);
  3.  
  4. cbuffer TransformBuffer : register(b0) {
  5. float4x4 worldMatrix,
  6. transformMatrix,
  7. viewProjectionMatrix;
  8. };
  9.  
  10. cbuffer MaterialBuffer : register(b1) {
  11. float3 materialDiffuseAlbedo;
  12. float materialSpecularExponent;
  13. float3 materialSpecularAlbedo;
  14. bool isTextured,
  15. isLighted;
  16. };
  17.  
  18. struct vsInput {
  19. float3 positionLS : POSITION;
  20. float3 textureLS : TEXTURE;
  21. float3 normalLS : NORMAL;
  22. };
  23.  
  24. struct vsOutput {
  25. float4 positionCS : SV_POSITION;
  26. float2 textureLS : TEXTURE;
  27. float3 normalWS : NORMAL;
  28. float3 positionWS : POSITION;
  29. };
  30.  
  31. struct psOutput {
  32. float4 positionWS : SV_Target0;
  33. float4 normalWS : SV_Target1;
  34. float4 diffuseAlbedoWS : SV_Target2;
  35. float4 specularAlbedoWS : SV_Target3;
  36. };
  37.  
  38. vsOutput VS( in const vsInput _in ) {
  39. vsOutput _out;
  40.  
  41. _out.positionCS = mul(float4(_in.positionLS, 1.0f), mul(transformMatrix, viewProjectionMatrix));
  42. _out.positionWS = mul(_in.positionLS, (float3x3) worldMatrix);
  43. _out.normalWS = mul(_in.normalLS, (float3x3) worldMatrix);
  44. _out.textureLS = (float2)_in.textureLS;
  45.  
  46. return _out;
  47. }
  48.  
  49. psOutput PS( in vsOutput _in ) {
  50. psOutput _out;
  51.  
  52. _out.normalWS = float4(normalize(_in.normalWS), materialSpecularExponent);
  53.  
  54. float _lightEffectModifier;
  55. if (isLighted)
  56. _lightEffectModifier = 1.0f;
  57. else _lightEffectModifier = 0.0f;
  58. _out.positionWS = float4(_in.positionWS, _lightEffectModifier);
  59.  
  60. _out.diffuseAlbedoWS = float4(materialDiffuseAlbedo, 1.0f);
  61. if (isTextured)
  62. _out.diffuseAlbedoWS *= diffuseTexture.Sample(textureSampler, _in.textureLS);
  63.  
  64. _out.specularAlbedoWS = float4(materialSpecularAlbedo, 1.0f);
  65.  
  66. return _out;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment