PPEyeAdaptHistogramReduce.bsl 810 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "$ENGINE$\PPBase.bslinc"
  2. technique PPEyeAdaptHistogramReduce
  3. {
  4. mixin PPBase;
  5. code
  6. {
  7. [internal]
  8. cbuffer Input
  9. {
  10. uint gThreadGroupCount;
  11. }
  12. Texture2D gHistogramTex;
  13. Texture2D gEyeAdaptationTex;
  14. float4 fsmain(VStoFS input) : SV_Target0
  15. {
  16. int2 iUV = trunc(input.uv0);
  17. float4 outputValue = 0.0f;
  18. // Output texture only has two rows, store histogram on the first
  19. if(input.uv0.y < 1.0f)
  20. {
  21. // TODO - Potentially optimize using bilinear filtering
  22. for(uint i = 0; i < gThreadGroupCount; i++)
  23. outputValue += gHistogramTex.Load(int3(iUV.x, i, 0));
  24. return outputValue / gThreadGroupCount;
  25. }
  26. else
  27. {
  28. // Store eye adaptation from last frame in the second row of the texture
  29. return gEyeAdaptationTex.Load(int3(0, 0, 0)).x;
  30. }
  31. }
  32. };
  33. };