PPEyeAdaptHistogramReduce.bsl 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "$ENGINE$\PPBase.bslinc"
  2. Parameters =
  3. {
  4. Texture2D gHistogramTex;
  5. Texture2D gEyeAdaptationTex;
  6. };
  7. Blocks =
  8. {
  9. Block Input;
  10. };
  11. Technique : inherits("PPBase") =
  12. {
  13. Pass =
  14. {
  15. Fragment =
  16. {
  17. cbuffer Input
  18. {
  19. uint gThreadGroupCount;
  20. }
  21. Texture2D gHistogramTex;
  22. Texture2D gEyeAdaptationTex;
  23. float4 main(VStoFS input) : SV_Target0
  24. {
  25. int2 iUV = trunc(input.uv0);
  26. float4 outputValue = 0.0f;
  27. // Output texture only has two rows, store histogram on the first
  28. if(input.uv0.y < 1.0f)
  29. {
  30. // TODO - Potentially optimize using bilinear filtering
  31. for(uint i = 0; i < gThreadGroupCount; i++)
  32. outputValue += gHistogramTex.Load(int3(iUV.x, i, 0));
  33. return outputValue / gThreadGroupCount;
  34. }
  35. else
  36. {
  37. // Store eye adaptation from last frame in the second row of the texture
  38. return gEyeAdaptationTex.Load(int3(0, 0, 0)).x;
  39. }
  40. }
  41. };
  42. };
  43. };