Writing custom shaders tutorial in Game::PostProcess() scene and RT1 are reversed
cyberjaxx opened this issue · comments
Referring to the tutorial "Writing custom shaders" https://github.com/Microsoft/DirectXTK/wiki/Writing-custom-shaders
In Game.cpp, in the method PostProcess, the final rendering has m_rt1SRV on shader resource slot 0 and m_sceneSRV on slot 1. These correspond to BaseTexture : register(t0) and BloomTexture:register(t1) in Bloom.hlsl, which is reversed from what it should be. Since I assume that the tutorial didn't change someone must have messed with Bloom.hlsl. I leave it up to you how to fix the issue. Thanks.
Actually, I think the code is flipped. This looks right:
m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), nullptr);
m_spriteBatch->Begin(SpriteSortMode_Immediate, nullptr, nullptr, nullptr, nullptr,
[=](){
m_d3dContext->PSSetShader(m_bloomCombinePS.Get(), nullptr, 0);
m_d3dContext->PSSetShaderResources(1, 1, m_rt1SRV.GetAddressOf());
m_d3dContext->PSSetConstantBuffers(0, 1, m_bloomParams.GetAddressOf());
});
m_spriteBatch->Draw(m_sceneSRV.Get(), m_fullscreenRect);
m_spriteBatch->End();