Skip to content

Commit

Permalink
Re-enabled depth clamping to fix CSM pass (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snosixtyboo authored Oct 5, 2021
1 parent 24b5d8a commit 9c859ce
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/RenderPasses/CSM/CSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ void CSM::createShadowPassResources()
mShadowPass.pState->setProgram(mShadowPass.pProgram);
mShadowPass.pState->setDepthStencilState(nullptr);
mShadowPass.pState->setFbo(mShadowPass.pFbo);

RasterizerState::Desc rsDesc;
rsDesc.setDepthClamp(true);
RasterizerState::SharedPtr rsState = RasterizerState::create(rsDesc);
mShadowPass.pState->setRasterizerState(rsState);
}

CSM::CSM()
Expand Down Expand Up @@ -407,7 +412,7 @@ RenderPassReflection CSM::reflect(const CompileData& compileData)
RenderPassReflection reflector;
reflector.addOutput(kVisibility, "Visibility map. Values are [0,1] where 0 means the pixel is completely shadowed and 1 means it's not shadowed at all")
.format(getVisBufferFormat(mVisibilityPassData.mapBitsPerChannel, mVisibilityPassData.shouldVisualizeCascades))
.texture2D(mVisibilityPassData.screenDim.x, mVisibilityPassData.screenDim.y);
.texture2D(0, 0);
reflector.addInput(kDepth, "Pre-initialized scene depth buffer used for SDSM.\nIf not provided, the pass will run a depth-pass internally").flags(RenderPassReflection::Field::Flags::Optional);
return reflector;
}
Expand Down Expand Up @@ -616,7 +621,7 @@ void CSM::renderScene(RenderContext* pCtx)

pCB->setBlob(&mCsmData, 0, sizeof(mCsmData));
mpLightCamera->setProjectionMatrix(mCsmData.globalMat);
mpScene->rasterize(pCtx, mShadowPass.pState.get(), mShadowPass.pVars.get());
mpScene->rasterize(pCtx, mShadowPass.pState.get(), mShadowPass.pVars.get(), mControls.depthClamp ? Scene::RenderFlags::UserRasterizerState : Scene::RenderFlags::None);
// mpCsmSceneRenderer->renderScene(pCtx, mShadowPass.pState.get(), mShadowPass.pVars.get(), mpLightCamera.get());
}

Expand Down

0 comments on commit 9c859ce

Please sign in to comment.