|
|
@@ -0,0 +1,83 @@
|
|
|
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
|
|
|
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
|
|
|
+#include "BsPostProcessing.h"
|
|
|
+#include "BsRenderTexture.h"
|
|
|
+
|
|
|
+namespace BansheeEngine
|
|
|
+{
|
|
|
+ DownsampleMat::DownsampleMat()
|
|
|
+ {
|
|
|
+ mMaterial->setParamBlockBuffer("Input", mParams.getBuffer());
|
|
|
+
|
|
|
+ mInputTexture = mMaterial->getParamTexture("gInputTex");
|
|
|
+ mInvTexSize = mMaterial->getParamVec2("gInvTexSize");
|
|
|
+ }
|
|
|
+
|
|
|
+ void DownsampleMat::_initDefines(ShaderDefines& defines)
|
|
|
+ {
|
|
|
+ // Do nothing
|
|
|
+ }
|
|
|
+
|
|
|
+ void DownsampleMat::setParameters(const SPtr<RenderTextureCore>& target)
|
|
|
+ {
|
|
|
+ mInputTexture.set(target->getBindableColorTexture());
|
|
|
+
|
|
|
+ const RenderTextureProperties& props = target->getProperties();
|
|
|
+ Vector2 invTextureSize(1.0f / props.getWidth(), 1.0f / props.getHeight());
|
|
|
+
|
|
|
+ mParams.gInvTexSize.set(invTextureSize);
|
|
|
+
|
|
|
+ // TODO - Output
|
|
|
+ }
|
|
|
+
|
|
|
+ EyeAdaptHistogramMat::EyeAdaptHistogramMat()
|
|
|
+ {
|
|
|
+ mMaterial->setParamBlockBuffer("Input", mParams.getBuffer());
|
|
|
+
|
|
|
+ mSceneColor = mMaterial->getParamTexture("gSceneColorTex");
|
|
|
+ mOutputTex = mMaterial->getParamLoadStoreTexture("gOutputTex");
|
|
|
+ }
|
|
|
+
|
|
|
+ void EyeAdaptHistogramMat::_initDefines(ShaderDefines& defines)
|
|
|
+ {
|
|
|
+ defines.set("THREADGROUP_SIZE_X", THREAD_GROUP_SIZE_X);
|
|
|
+ defines.set("THREADGROUP_SIZE_Y", THREAD_GROUP_SIZE_Y);
|
|
|
+ defines.set("LOOP_COUNT_X", LOOP_COUNT_X);
|
|
|
+ defines.set("LOOP_COUNT_Y", LOOP_COUNT_Y);
|
|
|
+ }
|
|
|
+
|
|
|
+ void EyeAdaptHistogramMat::setParameters(const SPtr<RenderTextureCore>& target, const PostProcessSettings& settings)
|
|
|
+ {
|
|
|
+ mSceneColor.set(target->getBindableColorTexture());
|
|
|
+
|
|
|
+ float diff = settings.histogramLog2Max - settings.histogramLog2Min;
|
|
|
+ float scale = 1.0f / diff;
|
|
|
+ float offset = -settings.histogramLog2Min * scale;
|
|
|
+
|
|
|
+ const RenderTextureProperties& props = target->getProperties();
|
|
|
+ int offsetAndSize[4] = { 0, 0, (INT32)props.getWidth(), (INT32)props.getHeight() };
|
|
|
+
|
|
|
+ mParams.gHistogramParams.set(Vector2(scale, offset));
|
|
|
+ mParams.gPixelOffsetAndSize.set(Vector4I(offsetAndSize));
|
|
|
+
|
|
|
+ const UINT32 texelsPerThreadGroupX = THREAD_GROUP_SIZE_X * LOOP_COUNT_X;
|
|
|
+ const UINT32 texelsPerThreadGroupY = THREAD_GROUP_SIZE_Y * LOOP_COUNT_Y;
|
|
|
+
|
|
|
+ Vector2I threadGroupCount;
|
|
|
+ threadGroupCount.x = ((INT32)props.getWidth() + texelsPerThreadGroupX - 1) / texelsPerThreadGroupX;
|
|
|
+ threadGroupCount.y = ((INT32)props.getHeight() + texelsPerThreadGroupY - 1) / texelsPerThreadGroupY;
|
|
|
+
|
|
|
+ mParams.gThreadGroupCount.set(threadGroupCount);
|
|
|
+
|
|
|
+ // TODO - Output
|
|
|
+ }
|
|
|
+
|
|
|
+ void PostProcessing::postProcess(const SPtr<RenderTextureCore>& target, const PostProcessSettings& settings)
|
|
|
+ {
|
|
|
+ RenderAPICore& rapi = RenderAPICore::instance();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // TODO - Downsample
|
|
|
+ }
|
|
|
+}
|