| 210 | } |
| 211 | |
| 212 | void ToneMapper::execute(RenderContext* pRenderContext, const RenderData& renderData) |
| 213 | { |
| 214 | auto pSrc = renderData.getTexture(kSrc); |
| 215 | auto pDst = renderData.getTexture(kDst); |
| 216 | FALCOR_ASSERT(pSrc && pDst); |
| 217 | |
| 218 | // Issue warning if image will be resampled. The render pass supports this but image quality may suffer. |
| 219 | if (pSrc->getWidth() != pDst->getWidth() || pSrc->getHeight() != pDst->getHeight()) |
| 220 | { |
| 221 | logWarning("ToneMapper pass I/O has different dimensions. The image will be resampled."); |
| 222 | } |
| 223 | |
| 224 | ref<Fbo> pFbo = Fbo::create(mpDevice); |
| 225 | pFbo->attachColorTarget(pDst, 0); |
| 226 | |
| 227 | // Run luminance pass if auto exposure is enabled |
| 228 | if (mAutoExposure) |
| 229 | { |
| 230 | createLuminanceFbo(pSrc); |
| 231 | |
| 232 | auto var = mpLuminancePass->getRootVar(); |
| 233 | var["gColorTex"] = pSrc; |
| 234 | var["gColorSampler"] = mpLinearSampler; |
| 235 | |
| 236 | mpLuminancePass->execute(pRenderContext, mpLuminanceFbo); |
| 237 | mpLuminanceFbo->getColorTexture(0)->generateMips(pRenderContext); |
| 238 | } |
| 239 | |
| 240 | // Run main pass |
| 241 | if (mRecreateToneMapPass) |
| 242 | { |
| 243 | createToneMapPass(); |
| 244 | mUpdateToneMapPass = true; |
| 245 | mRecreateToneMapPass = false; |
| 246 | } |
| 247 | |
| 248 | if (mUpdateToneMapPass) |
| 249 | { |
| 250 | updateWhiteBalanceTransform(); |
| 251 | updateColorTransform(); |
| 252 | |
| 253 | ToneMapperParams params; |
| 254 | params.whiteScale = mWhiteScale; |
| 255 | params.whiteMaxLuminance = mWhiteMaxLuminance; |
| 256 | params.colorTransform = float3x4(mColorTransform); |
| 257 | mpToneMapPass->getRootVar()["PerImageCB"]["gParams"].setBlob(¶ms, sizeof(params)); |
| 258 | mUpdateToneMapPass = false; |
| 259 | } |
| 260 | |
| 261 | auto var = mpToneMapPass->getRootVar(); |
| 262 | var["gColorTex"] = pSrc; |
| 263 | var["gColorSampler"] = mpPointSampler; |
| 264 | |
| 265 | if (mAutoExposure) |
| 266 | { |
| 267 | var["gLuminanceTexSampler"] = mpLinearSampler; |
| 268 | var["gLuminanceTex"] = mpLuminanceFbo->getColorTexture(0); |
| 269 | } |
nothing calls this directly
no test coverage detected