| 171 | } |
| 172 | |
| 173 | void SVGFPass::execute(RenderContext* pRenderContext, const RenderData& renderData) |
| 174 | { |
| 175 | ref<Texture> pAlbedoTexture = renderData.getTexture(kInputBufferAlbedo); |
| 176 | ref<Texture> pColorTexture = renderData.getTexture(kInputBufferColor); |
| 177 | ref<Texture> pEmissionTexture = renderData.getTexture(kInputBufferEmission); |
| 178 | ref<Texture> pWorldPositionTexture = renderData.getTexture(kInputBufferWorldPosition); |
| 179 | ref<Texture> pWorldNormalTexture = renderData.getTexture(kInputBufferWorldNormal); |
| 180 | ref<Texture> pPosNormalFwidthTexture = renderData.getTexture(kInputBufferPosNormalFwidth); |
| 181 | ref<Texture> pLinearZTexture = renderData.getTexture(kInputBufferLinearZ); |
| 182 | ref<Texture> pMotionVectorTexture = renderData.getTexture(kInputBufferMotionVector); |
| 183 | |
| 184 | ref<Texture> pOutputTexture = renderData.getTexture(kOutputBufferFilteredImage); |
| 185 | |
| 186 | FALCOR_ASSERT( |
| 187 | mpFilteredIlluminationFbo && mpFilteredIlluminationFbo->getWidth() == pAlbedoTexture->getWidth() && |
| 188 | mpFilteredIlluminationFbo->getHeight() == pAlbedoTexture->getHeight() |
| 189 | ); |
| 190 | |
| 191 | if (mBuffersNeedClear) |
| 192 | { |
| 193 | clearBuffers(pRenderContext, renderData); |
| 194 | mBuffersNeedClear = false; |
| 195 | } |
| 196 | |
| 197 | if (mFilterEnabled) |
| 198 | { |
| 199 | // Grab linear z and its derivative and also pack the normal into |
| 200 | // the last two channels of the mpLinearZAndNormalFbo. |
| 201 | computeLinearZAndNormal(pRenderContext, pLinearZTexture, pWorldNormalTexture); |
| 202 | |
| 203 | // Demodulate input color & albedo to get illumination and lerp in |
| 204 | // reprojected filtered illumination from the previous frame. |
| 205 | // Stores the result as well as initial moments and an updated |
| 206 | // per-pixel history length in mpCurReprojFbo. |
| 207 | ref<Texture> pPrevLinearZAndNormalTexture = renderData.getTexture(kInternalBufferPreviousLinearZAndNormal); |
| 208 | computeReprojection( |
| 209 | pRenderContext, |
| 210 | pAlbedoTexture, |
| 211 | pColorTexture, |
| 212 | pEmissionTexture, |
| 213 | pMotionVectorTexture, |
| 214 | pPosNormalFwidthTexture, |
| 215 | pPrevLinearZAndNormalTexture |
| 216 | ); |
| 217 | |
| 218 | // Do a first cross-bilateral filtering of the illumination and |
| 219 | // estimate its variance, storing the result into a float4 in |
| 220 | // mpPingPongFbo[0]. Takes mpCurReprojFbo as input. |
| 221 | computeFilteredMoments(pRenderContext); |
| 222 | |
| 223 | // Filter illumination from mpCurReprojFbo[0], storing the result |
| 224 | // in mpPingPongFbo[0]. Along the way (or at the end, depending on |
| 225 | // the value of mFeedbackTap), save the filtered illumination for |
| 226 | // next time into mpFilteredPastFbo. |
| 227 | computeAtrousDecomposition(pRenderContext, pAlbedoTexture); |
| 228 | |
| 229 | // Compute albedo * filtered illumination and add emission back in. |
| 230 | auto perImageCB = mpFinalModulate->getRootVar()["PerImageCB"]; |
no test coverage detected