2
0

PSApproach_DownScale3x3PS.hlsl 1.4 KB

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