PSApproach_FinalPassPS.hlsl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
  2. // CHECK: sample
  3. // CHECK: sample
  4. // CHECK: sample
  5. // CHECK: storeOutput
  6. //--------------------------------------------------------------------------------------
  7. // File: PSApproach.hlsl
  8. //
  9. // The PSs for doing post-processing, used in PS path of
  10. // HDRToneMappingCS11 sample
  11. //
  12. // Copyright (c) Microsoft Corporation. All rights reserved.
  13. //--------------------------------------------------------------------------------------
  14. static const float4 LUM_VECTOR = float4(.299, .587, .114, 0);
  15. static const float MIDDLE_GRAY = 0.72f;
  16. static const float LUM_WHITE = 1.5f;
  17. static const float BRIGHT_THRESHOLD = 0.5f;
  18. SamplerState PointSampler : register (s0);
  19. SamplerState LinearSampler : register (s1);
  20. struct QuadVS_Output
  21. {
  22. float4 Pos : SV_POSITION;
  23. float2 Tex : TEXCOORD0;
  24. };
  25. Texture2D s0 : register(t0);
  26. Texture2D s1 : register(t1);
  27. Texture2D s2 : register(t2);
  28. float4 main( QuadVS_Output Input ) : SV_TARGET
  29. {
  30. //float4 vColor = 0;
  31. float4 vColor = s0.Sample( PointSampler, Input.Tex );
  32. float4 vLum = s1.Sample( PointSampler, float2(0,0) );
  33. float3 vBloom = s2.Sample( LinearSampler, Input.Tex );
  34. // Tone mapping
  35. vColor.rgb *= MIDDLE_GRAY / (vLum.r + 0.001f);
  36. vColor.rgb *= (1.0f + vColor/LUM_WHITE);
  37. vColor.rgb /= (1.0f + vColor);
  38. vColor.rgb += 0.6f * vBloom;
  39. vColor.a = 1.0f;
  40. return vColor;
  41. }