BsPostProcessing.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsRenderBeastPrerequisites.h"
  5. #include "BsRendererMaterial.h"
  6. #include "BsParamBlocks.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup RenderBeast
  10. * @{
  11. */
  12. /** Settings that control the post-process operation. */
  13. struct PostProcessSettings
  14. {
  15. /**
  16. * Determines minimum luminance value in the eye adaptation histogram. In log2 units (-8 = 1/256). In the range
  17. * [-16, 0].
  18. */
  19. float histogramLog2Min = -8.0f;
  20. /**
  21. * Determines maximum luminance value in the eye adaptation histogram. In log2 units (4 = 16). In the range
  22. * [0, 16].
  23. */
  24. float histogramLog2Max = 4.0f;
  25. };
  26. BS_PARAM_BLOCK_BEGIN(DownsampleParams)
  27. BS_PARAM_BLOCK_ENTRY(Vector2, gInvTexSize)
  28. BS_PARAM_BLOCK_END
  29. /** Shader that downsamples a texture to half its size. */
  30. class DownsampleMat : public RendererMaterial<DownsampleMat>
  31. {
  32. RMAT_DEF("PPDownsample.bsl");
  33. public:
  34. DownsampleMat();
  35. /** Updates the parameter buffers used by the material. */
  36. void setParameters(const SPtr<RenderTextureCore>& target);
  37. private:
  38. DownsampleParams mParams;
  39. MaterialParamVec2Core mInvTexSize;
  40. MaterialParamTextureCore mInputTexture;
  41. };
  42. BS_PARAM_BLOCK_BEGIN(EyeAdaptHistogramParams)
  43. BS_PARAM_BLOCK_ENTRY(Vector4I, gPixelOffsetAndSize)
  44. BS_PARAM_BLOCK_ENTRY(Vector2, gHistogramParams)
  45. BS_PARAM_BLOCK_ENTRY(Vector2I, gThreadGroupCount)
  46. BS_PARAM_BLOCK_END
  47. /** Shader that creates a luminance histogram used for eye adaptation. */
  48. class EyeAdaptHistogramMat : public RendererMaterial<EyeAdaptHistogramMat>
  49. {
  50. RMAT_DEF("PPEyeAdaptHistogram.bsl");
  51. public:
  52. EyeAdaptHistogramMat();
  53. /** Updates the parameter buffers used by the material. */
  54. void setParameters(const SPtr<RenderTextureCore>& target, const PostProcessSettings& settings);
  55. private:
  56. EyeAdaptHistogramParams mParams;
  57. MaterialParamTextureCore mSceneColor;
  58. MaterialParamLoadStoreTextureCore mOutputTex;
  59. static const INT32 THREAD_GROUP_SIZE_X = 4;
  60. static const INT32 THREAD_GROUP_SIZE_Y = 4;
  61. static const INT32 LOOP_COUNT_X = 8;
  62. static const INT32 LOOP_COUNT_Y = 8;
  63. };
  64. /**
  65. * Renders post-processing effects for the provided render target.
  66. *
  67. * @note Core thread only.
  68. */
  69. class BS_BSRND_EXPORT PostProcessing
  70. {
  71. public:
  72. /** Renders post-processing effects for the provided render target. */
  73. static void postProcess(const SPtr<RenderTextureCore>& target, const PostProcessSettings& settings);
  74. private:
  75. };
  76. /** @} */
  77. }