2
0

BsPostProcessing.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsPostProcessing.h"
  4. #include "BsRenderTexture.h"
  5. #include "BsRenderTexturePool.h"
  6. #include "BsRendererUtility.h"
  7. #include "BsTextureManager.h"
  8. #include "BsCamera.h"
  9. #include "BsGpuParamsSet.h"
  10. #include "BsRendererCamera.h"
  11. namespace bs { namespace ct
  12. {
  13. DownsampleParamDef gDownsampleParamDef;
  14. DownsampleMat::DownsampleMat()
  15. {
  16. mParamBuffer = gDownsampleParamDef.createBuffer();
  17. mParamsSet->setParamBlockBuffer("Input", mParamBuffer);
  18. mParamsSet->getGpuParams()->getTextureParam(GPT_FRAGMENT_PROGRAM, "gInputTex", mInputTexture);
  19. }
  20. void DownsampleMat::_initDefines(ShaderDefines& defines)
  21. {
  22. // Do nothing
  23. }
  24. void DownsampleMat::execute(const SPtr<RenderTexture>& target, PostProcessInfo& ppInfo)
  25. {
  26. // Set parameters
  27. SPtr<Texture> colorTexture = target->getColorTexture(0);
  28. mInputTexture.set(colorTexture);
  29. const RenderTextureProperties& rtProps = target->getProperties();
  30. Vector2 invTextureSize(1.0f / rtProps.getWidth(), 1.0f / rtProps.getHeight());
  31. gDownsampleParamDef.gInvTexSize.set(mParamBuffer, invTextureSize);
  32. // Set output
  33. const TextureProperties& colorProps = colorTexture->getProperties();
  34. UINT32 width = std::max(1, Math::ceilToInt(colorProps.getWidth() * 0.5f));
  35. UINT32 height = std::max(1, Math::ceilToInt(colorProps.getHeight() * 0.5f));
  36. mOutputDesc = POOLED_RENDER_TEXTURE_DESC::create2D(colorProps.getFormat(), width, height, TU_RENDERTARGET);
  37. // Render
  38. ppInfo.downsampledSceneTex = RenderTexturePool::instance().get(mOutputDesc);
  39. RenderAPI& rapi = RenderAPI::instance();
  40. rapi.setRenderTarget(ppInfo.downsampledSceneTex->renderTexture, true);
  41. gRendererUtility().setPass(mMaterial);
  42. gRendererUtility().setPassParams(mParamsSet);
  43. gRendererUtility().drawScreenQuad();
  44. rapi.setRenderTarget(nullptr);
  45. mOutput = ppInfo.downsampledSceneTex->renderTexture;
  46. }
  47. void DownsampleMat::release(PostProcessInfo& ppInfo)
  48. {
  49. RenderTexturePool::instance().release(ppInfo.downsampledSceneTex);
  50. mOutput = nullptr;
  51. }
  52. EyeAdaptHistogramParamDef gEyeAdaptHistogramParamDef;
  53. EyeAdaptHistogramMat::EyeAdaptHistogramMat()
  54. {
  55. mParamBuffer = gEyeAdaptHistogramParamDef.createBuffer();
  56. mParamsSet->setParamBlockBuffer("Input", mParamBuffer);
  57. SPtr<GpuParams> params = mParamsSet->getGpuParams();
  58. params->getTextureParam(GPT_COMPUTE_PROGRAM, "gSceneColorTex", mSceneColor);
  59. params->getLoadStoreTextureParam(GPT_COMPUTE_PROGRAM, "gOutputTex", mOutputTex);
  60. }
  61. void EyeAdaptHistogramMat::_initDefines(ShaderDefines& defines)
  62. {
  63. defines.set("THREADGROUP_SIZE_X", THREAD_GROUP_SIZE_X);
  64. defines.set("THREADGROUP_SIZE_Y", THREAD_GROUP_SIZE_Y);
  65. defines.set("LOOP_COUNT_X", LOOP_COUNT_X);
  66. defines.set("LOOP_COUNT_Y", LOOP_COUNT_Y);
  67. }
  68. void EyeAdaptHistogramMat::execute(PostProcessInfo& ppInfo)
  69. {
  70. // Set parameters
  71. SPtr<RenderTexture> target = ppInfo.downsampledSceneTex->renderTexture;
  72. mSceneColor.set(ppInfo.downsampledSceneTex->texture);
  73. const RenderTextureProperties& props = target->getProperties();
  74. int offsetAndSize[4] = { 0, 0, (INT32)props.getWidth(), (INT32)props.getHeight() };
  75. gEyeAdaptHistogramParamDef.gHistogramParams.set(mParamBuffer, getHistogramScaleOffset(ppInfo));
  76. gEyeAdaptHistogramParamDef.gPixelOffsetAndSize.set(mParamBuffer, Vector4I(offsetAndSize));
  77. Vector2I threadGroupCount = getThreadGroupCount(target);
  78. gEyeAdaptHistogramParamDef.gThreadGroupCount.set(mParamBuffer, threadGroupCount);
  79. // Set output
  80. UINT32 numHistograms = threadGroupCount.x * threadGroupCount.y;
  81. mOutputDesc = POOLED_RENDER_TEXTURE_DESC::create2D(PF_FLOAT16_RGBA, HISTOGRAM_NUM_TEXELS, numHistograms,
  82. TU_LOADSTORE);
  83. // Dispatch
  84. ppInfo.histogramTex = RenderTexturePool::instance().get(mOutputDesc);
  85. mOutputTex.set(ppInfo.histogramTex->texture);
  86. RenderAPI& rapi = RenderAPI::instance();
  87. gRendererUtility().setComputePass(mMaterial);
  88. gRendererUtility().setPassParams(mParamsSet);
  89. rapi.dispatchCompute(threadGroupCount.x, threadGroupCount.y);
  90. mOutput = ppInfo.histogramTex->renderTexture;
  91. }
  92. void EyeAdaptHistogramMat::release(PostProcessInfo& ppInfo)
  93. {
  94. RenderTexturePool::instance().release(ppInfo.histogramTex);
  95. mOutput = nullptr;
  96. }
  97. Vector2I EyeAdaptHistogramMat::getThreadGroupCount(const SPtr<RenderTexture>& target)
  98. {
  99. const UINT32 texelsPerThreadGroupX = THREAD_GROUP_SIZE_X * LOOP_COUNT_X;
  100. const UINT32 texelsPerThreadGroupY = THREAD_GROUP_SIZE_Y * LOOP_COUNT_Y;
  101. const RenderTextureProperties& props = target->getProperties();
  102. Vector2I threadGroupCount;
  103. threadGroupCount.x = ((INT32)props.getWidth() + texelsPerThreadGroupX - 1) / texelsPerThreadGroupX;
  104. threadGroupCount.y = ((INT32)props.getHeight() + texelsPerThreadGroupY - 1) / texelsPerThreadGroupY;
  105. return threadGroupCount;
  106. }
  107. Vector2 EyeAdaptHistogramMat::getHistogramScaleOffset(const PostProcessInfo& ppInfo)
  108. {
  109. const StandardPostProcessSettings& settings = *ppInfo.settings;
  110. float diff = settings.autoExposure.histogramLog2Max - settings.autoExposure.histogramLog2Min;
  111. float scale = 1.0f / diff;
  112. float offset = -settings.autoExposure.histogramLog2Min * scale;
  113. return Vector2(scale, offset);
  114. }
  115. EyeAdaptHistogramReduceParamDef gEyeAdaptHistogramReduceParamDef;
  116. EyeAdaptHistogramReduceMat::EyeAdaptHistogramReduceMat()
  117. {
  118. mParamBuffer = gEyeAdaptHistogramReduceParamDef.createBuffer();
  119. mParamsSet->setParamBlockBuffer("Input", mParamBuffer);
  120. SPtr<GpuParams> params = mParamsSet->getGpuParams();
  121. params->getTextureParam(GPT_FRAGMENT_PROGRAM, "gHistogramTex", mHistogramTex);
  122. params->getTextureParam(GPT_FRAGMENT_PROGRAM, "gEyeAdaptationTex", mEyeAdaptationTex);
  123. }
  124. void EyeAdaptHistogramReduceMat::_initDefines(ShaderDefines& defines)
  125. {
  126. // Do nothing
  127. }
  128. void EyeAdaptHistogramReduceMat::execute(PostProcessInfo& ppInfo)
  129. {
  130. // Set parameters
  131. mHistogramTex.set(ppInfo.histogramTex->texture);
  132. SPtr<PooledRenderTexture> eyeAdaptationRT = ppInfo.eyeAdaptationTex[ppInfo.lastEyeAdaptationTex];
  133. SPtr<Texture> eyeAdaptationTex;
  134. if (eyeAdaptationRT != nullptr) // Could be that this is the first run
  135. eyeAdaptationTex = eyeAdaptationRT->texture;
  136. else
  137. eyeAdaptationTex = Texture::WHITE;
  138. mEyeAdaptationTex.set(eyeAdaptationTex);
  139. Vector2I threadGroupCount = EyeAdaptHistogramMat::getThreadGroupCount(ppInfo.downsampledSceneTex->renderTexture);
  140. UINT32 numHistograms = threadGroupCount.x * threadGroupCount.y;
  141. gEyeAdaptHistogramReduceParamDef.gThreadGroupCount.set(mParamBuffer, numHistograms);
  142. // Set output
  143. mOutputDesc = POOLED_RENDER_TEXTURE_DESC::create2D(PF_FLOAT16_RGBA, EyeAdaptHistogramMat::HISTOGRAM_NUM_TEXELS, 2,
  144. TU_RENDERTARGET);
  145. // Render
  146. ppInfo.histogramReduceTex = RenderTexturePool::instance().get(mOutputDesc);
  147. RenderAPI& rapi = RenderAPI::instance();
  148. rapi.setRenderTarget(ppInfo.histogramReduceTex->renderTexture, true);
  149. gRendererUtility().setPass(mMaterial);
  150. gRendererUtility().setPassParams(mParamsSet);
  151. Rect2 drawUV(0.0f, 0.0f, (float)EyeAdaptHistogramMat::HISTOGRAM_NUM_TEXELS, 2.0f);
  152. gRendererUtility().drawScreenQuad(drawUV);
  153. rapi.setRenderTarget(nullptr);
  154. mOutput = ppInfo.histogramReduceTex->renderTexture;
  155. }
  156. void EyeAdaptHistogramReduceMat::release(PostProcessInfo& ppInfo)
  157. {
  158. RenderTexturePool::instance().release(ppInfo.histogramReduceTex);
  159. mOutput = nullptr;
  160. }
  161. EyeAdaptationParamDef gEyeAdaptationParamDef;
  162. EyeAdaptationMat::EyeAdaptationMat()
  163. {
  164. mParamBuffer = gEyeAdaptationParamDef.createBuffer();
  165. mParamsSet->setParamBlockBuffer("Input", mParamBuffer);
  166. mParamsSet->getGpuParams()->getTextureParam(GPT_FRAGMENT_PROGRAM, "gHistogramTex", mReducedHistogramTex);
  167. }
  168. void EyeAdaptationMat::_initDefines(ShaderDefines& defines)
  169. {
  170. defines.set("THREADGROUP_SIZE_X", EyeAdaptHistogramMat::THREAD_GROUP_SIZE_X);
  171. defines.set("THREADGROUP_SIZE_Y", EyeAdaptHistogramMat::THREAD_GROUP_SIZE_Y);
  172. }
  173. void EyeAdaptationMat::execute(PostProcessInfo& ppInfo, float frameDelta)
  174. {
  175. bool texturesInitialized = ppInfo.eyeAdaptationTex[0] != nullptr && ppInfo.eyeAdaptationTex[1] != nullptr;
  176. if(!texturesInitialized)
  177. {
  178. POOLED_RENDER_TEXTURE_DESC outputDesc = POOLED_RENDER_TEXTURE_DESC::create2D(PF_FLOAT32_R, 1, 1, TU_RENDERTARGET);
  179. ppInfo.eyeAdaptationTex[0] = RenderTexturePool::instance().get(outputDesc);
  180. ppInfo.eyeAdaptationTex[1] = RenderTexturePool::instance().get(outputDesc);
  181. }
  182. ppInfo.lastEyeAdaptationTex = (ppInfo.lastEyeAdaptationTex + 1) % 2; // TODO - Do I really need two targets?
  183. // Set parameters
  184. mReducedHistogramTex.set(ppInfo.histogramReduceTex->texture);
  185. Vector2 histogramScaleAndOffset = EyeAdaptHistogramMat::getHistogramScaleOffset(ppInfo);
  186. const StandardPostProcessSettings& settings = *ppInfo.settings;
  187. Vector4 eyeAdaptationParams[3];
  188. eyeAdaptationParams[0].x = histogramScaleAndOffset.x;
  189. eyeAdaptationParams[0].y = histogramScaleAndOffset.y;
  190. float histogramPctHigh = Math::clamp01(settings.autoExposure.histogramPctHigh);
  191. eyeAdaptationParams[0].z = std::min(Math::clamp01(settings.autoExposure.histogramPctLow), histogramPctHigh);
  192. eyeAdaptationParams[0].w = histogramPctHigh;
  193. eyeAdaptationParams[1].x = std::min(settings.autoExposure.minEyeAdaptation, settings.autoExposure.maxEyeAdaptation);
  194. eyeAdaptationParams[1].y = settings.autoExposure.maxEyeAdaptation;
  195. eyeAdaptationParams[1].z = settings.autoExposure.eyeAdaptationSpeedUp;
  196. eyeAdaptationParams[1].w = settings.autoExposure.eyeAdaptationSpeedDown;
  197. eyeAdaptationParams[2].x = Math::pow(2.0f, settings.exposureScale);
  198. eyeAdaptationParams[2].y = frameDelta;
  199. eyeAdaptationParams[2].z = 0.0f; // Unused
  200. eyeAdaptationParams[2].w = 0.0f; // Unused
  201. gEyeAdaptationParamDef.gEyeAdaptationParams.set(mParamBuffer, eyeAdaptationParams[0], 0);
  202. gEyeAdaptationParamDef.gEyeAdaptationParams.set(mParamBuffer, eyeAdaptationParams[1], 1);
  203. gEyeAdaptationParamDef.gEyeAdaptationParams.set(mParamBuffer, eyeAdaptationParams[2], 2);
  204. // Render
  205. SPtr<PooledRenderTexture> eyeAdaptationRT = ppInfo.eyeAdaptationTex[ppInfo.lastEyeAdaptationTex];
  206. RenderAPI& rapi = RenderAPI::instance();
  207. rapi.setRenderTarget(eyeAdaptationRT->renderTexture, true);
  208. gRendererUtility().setPass(mMaterial);
  209. gRendererUtility().setPassParams(mParamsSet);
  210. gRendererUtility().drawScreenQuad();
  211. rapi.setRenderTarget(nullptr);
  212. }
  213. CreateTonemapLUTParamDef gCreateTonemapLUTParamDef;
  214. WhiteBalanceParamDef gWhiteBalanceParamDef;
  215. CreateTonemapLUTMat::CreateTonemapLUTMat()
  216. {
  217. mParamBuffer = gCreateTonemapLUTParamDef.createBuffer();
  218. mWhiteBalanceParamBuffer = gWhiteBalanceParamDef.createBuffer();
  219. mParamsSet->setParamBlockBuffer("Input", mParamBuffer);
  220. mParamsSet->setParamBlockBuffer("WhiteBalanceInput", mWhiteBalanceParamBuffer);
  221. SPtr<GpuParams> params = mParamsSet->getGpuParams();
  222. params->getLoadStoreTextureParam(GPT_COMPUTE_PROGRAM, "gOutputTex", mOutputTex);
  223. }
  224. void CreateTonemapLUTMat::_initDefines(ShaderDefines& defines)
  225. {
  226. defines.set("LUT_SIZE", LUT_SIZE);
  227. }
  228. void CreateTonemapLUTMat::execute(PostProcessInfo& ppInfo)
  229. {
  230. const StandardPostProcessSettings& settings = *ppInfo.settings;
  231. // Set parameters
  232. gCreateTonemapLUTParamDef.gGammaAdjustment.set(mParamBuffer, 2.2f / settings.gamma);
  233. // Note: Assuming sRGB (PC monitor) for now, change to Rec.709 when running on console (value 1), or to raw 2.2
  234. // gamma when running on Mac (value 2)
  235. gCreateTonemapLUTParamDef.gGammaCorrectionType.set(mParamBuffer, 0);
  236. Vector4 tonemapParams[2];
  237. tonemapParams[0].x = settings.tonemapping.filmicCurveShoulderStrength;
  238. tonemapParams[0].y = settings.tonemapping.filmicCurveLinearStrength;
  239. tonemapParams[0].z = settings.tonemapping.filmicCurveLinearAngle;
  240. tonemapParams[0].w = settings.tonemapping.filmicCurveToeStrength;
  241. tonemapParams[1].x = settings.tonemapping.filmicCurveToeNumerator;
  242. tonemapParams[1].y = settings.tonemapping.filmicCurveToeDenominator;
  243. tonemapParams[1].z = settings.tonemapping.filmicCurveLinearWhitePoint;
  244. tonemapParams[1].w = 0.0f; // Unused
  245. gCreateTonemapLUTParamDef.gTonemapParams.set(mParamBuffer, tonemapParams[0], 0);
  246. gCreateTonemapLUTParamDef.gTonemapParams.set(mParamBuffer, tonemapParams[1], 1);
  247. // Set color grading params
  248. gCreateTonemapLUTParamDef.gSaturation.set(mParamBuffer, settings.colorGrading.saturation);
  249. gCreateTonemapLUTParamDef.gContrast.set(mParamBuffer, settings.colorGrading.contrast);
  250. gCreateTonemapLUTParamDef.gGain.set(mParamBuffer, settings.colorGrading.gain);
  251. gCreateTonemapLUTParamDef.gOffset.set(mParamBuffer, settings.colorGrading.offset);
  252. // Set white balance params
  253. gWhiteBalanceParamDef.gWhiteTemp.set(mWhiteBalanceParamBuffer, settings.whiteBalance.temperature);
  254. gWhiteBalanceParamDef.gWhiteOffset.set(mWhiteBalanceParamBuffer, settings.whiteBalance.tint);
  255. // Set output
  256. POOLED_RENDER_TEXTURE_DESC outputDesc = POOLED_RENDER_TEXTURE_DESC::create3D(PF_R8G8B8A8,
  257. LUT_SIZE, LUT_SIZE, LUT_SIZE, TU_LOADSTORE);
  258. // Dispatch
  259. ppInfo.colorLUT = RenderTexturePool::instance().get(outputDesc);
  260. mOutputTex.set(ppInfo.colorLUT->texture);
  261. RenderAPI& rapi = RenderAPI::instance();
  262. gRendererUtility().setComputePass(mMaterial);
  263. gRendererUtility().setPassParams(mParamsSet);
  264. rapi.dispatchCompute(LUT_SIZE / 8, LUT_SIZE / 8, LUT_SIZE);
  265. }
  266. void CreateTonemapLUTMat::release(PostProcessInfo& ppInfo)
  267. {
  268. RenderTexturePool::instance().release(ppInfo.colorLUT);
  269. }
  270. TonemappingParamDef gTonemappingParamDef;
  271. template<bool GammaOnly, bool AutoExposure>
  272. TonemappingMat<GammaOnly, AutoExposure>::TonemappingMat()
  273. {
  274. mParamBuffer = gTonemappingParamDef.createBuffer();
  275. mParamsSet->setParamBlockBuffer("Input", mParamBuffer);
  276. SPtr<GpuParams> params = mParamsSet->getGpuParams();
  277. params->getTextureParam(GPT_VERTEX_PROGRAM, "gEyeAdaptationTex", mEyeAdaptationTex);
  278. params->getTextureParam(GPT_FRAGMENT_PROGRAM, "gInputTex", mInputTex);
  279. if(!GammaOnly)
  280. params->getTextureParam(GPT_FRAGMENT_PROGRAM, "gColorLUT", mColorLUT);
  281. }
  282. template<bool GammaOnly, bool AutoExposure>
  283. void TonemappingMat<GammaOnly, AutoExposure>::_initDefines(ShaderDefines& defines)
  284. {
  285. if(GammaOnly)
  286. defines.set("GAMMA_ONLY", 1);
  287. if (AutoExposure)
  288. defines.set("AUTO_EXPOSURE", 1);
  289. defines.set("LUT_SIZE", CreateTonemapLUTMat::LUT_SIZE);
  290. }
  291. template<bool GammaOnly, bool AutoExposure>
  292. void TonemappingMat<GammaOnly, AutoExposure>::execute(const SPtr<RenderTexture>& sceneColor,
  293. const SPtr<RenderTarget>& outputRT, const Rect2& outputRect, PostProcessInfo& ppInfo)
  294. {
  295. gTonemappingParamDef.gRawGamma.set(mParamBuffer, 1.0f / ppInfo.settings->gamma);
  296. gTonemappingParamDef.gManualExposureScale.set(mParamBuffer, Math::pow(2.0f, ppInfo.settings->exposureScale));
  297. // Set parameters
  298. SPtr<Texture> colorTexture = sceneColor->getColorTexture(0);
  299. mInputTex.set(colorTexture);
  300. SPtr<Texture> colorLUT;
  301. if(ppInfo.colorLUT != nullptr)
  302. colorLUT = ppInfo.colorLUT->texture;
  303. mColorLUT.set(colorLUT);
  304. SPtr<Texture> eyeAdaptationTexture;
  305. if(ppInfo.eyeAdaptationTex[ppInfo.lastEyeAdaptationTex] != nullptr)
  306. eyeAdaptationTexture = ppInfo.eyeAdaptationTex[ppInfo.lastEyeAdaptationTex]->texture;
  307. mEyeAdaptationTex.set(eyeAdaptationTexture);
  308. // Render
  309. RenderAPI& rapi = RenderAPI::instance();
  310. rapi.setRenderTarget(outputRT);
  311. rapi.setViewport(outputRect);
  312. gRendererUtility().setPass(mMaterial);
  313. gRendererUtility().setPassParams(mParamsSet);
  314. gRendererUtility().drawScreenQuad();
  315. }
  316. template class TonemappingMat<true, true>;
  317. template class TonemappingMat<false, true>;
  318. template class TonemappingMat<true, false>;
  319. template class TonemappingMat<false, false>;
  320. void PostProcessing::postProcess(RendererCamera* viewInfo, const SPtr<RenderTexture>& sceneColor, float frameDelta)
  321. {
  322. PostProcessInfo& ppInfo = viewInfo->getPPInfo();
  323. const StandardPostProcessSettings& settings = *ppInfo.settings;
  324. SPtr<RenderTarget> finalRT = viewInfo->getFinalTarget();
  325. Rect2 viewportRect = viewInfo->getViewportRect();
  326. bool hdr = viewInfo->isHDR();
  327. if(hdr && settings.enableAutoExposure)
  328. {
  329. mDownsample.execute(sceneColor, ppInfo);
  330. mEyeAdaptHistogram.execute(ppInfo);
  331. mDownsample.release(ppInfo);
  332. mEyeAdaptHistogramReduce.execute(ppInfo);
  333. mEyeAdaptHistogram.release(ppInfo);
  334. mEyeAdaptation.execute(ppInfo, frameDelta);
  335. mEyeAdaptHistogramReduce.release(ppInfo);
  336. }
  337. if (hdr && settings.enableTonemapping)
  338. {
  339. if (ppInfo.settingDirty) // Rebuild LUT if PP settings changed
  340. mCreateLUT.execute(ppInfo);
  341. if (settings.enableAutoExposure)
  342. mTonemapping_AE.execute(sceneColor, finalRT, viewportRect, ppInfo);
  343. else
  344. mTonemapping.execute(sceneColor, finalRT, viewportRect, ppInfo);
  345. }
  346. else
  347. {
  348. if (hdr && settings.enableAutoExposure)
  349. mTonemapping_AE_GO.execute(sceneColor, finalRT, viewportRect, ppInfo);
  350. else
  351. mTonemapping_GO.execute(sceneColor, finalRT, viewportRect, ppInfo);
  352. }
  353. if (ppInfo.settingDirty)
  354. ppInfo.settingDirty = false;
  355. }
  356. }}