Hi,
I've been trying to implement a gaussian blur recently, it would seem the best way to achieve this is by running a bur on one axis, then another blur on the other axis.
I think I have successfully implemented the blur part per axis, but now I have to blend both calls with a proper BlendState, at least I think this is where my problem is.
Here are my passes:
RasterizerState DisableCulling
{
CullMode = BACK;
};
BlendState AdditiveBlend
{
BlendEnable[0] = TRUE;
BlendEnable[1] = TRUE;
SrcBlend[0] = SRC_COLOR;
BlendOp[0] = ADD;
BlendOp[1] = ADD;
SrcBlend[1] = SRC_COLOR;
};
technique11 BlockTech
{
pass P0
{
SetVertexShader(CompileShader(vs_5_0, VS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_5_0, PS_BlurV()));
SetRasterizerState(DisableCulling);
SetBlendState(AdditiveBlend, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
}
pass P1
{
SetVertexShader(CompileShader(vs_5_0, VS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_5_0, PS_BlurH()));
SetRasterizerState(DisableCulling);
}
}
D3DX11_TECHNIQUE_DESC techDesc;
mBlockEffect->mTech->GetDesc( &techDesc );
for(UINT p = 0; p < techDesc.Passes; ++p)
{
deviceContext->IASetVertexBuffers(0, 2, bufferPointers, stride, offset);
deviceContext->IASetIndexBuffer(mIB, DXGI_FORMAT_R32_UINT, 0);
mBlockEffect->mTech->GetPassByIndex(p)->Apply(0, deviceContext);
deviceContext->DrawIndexedInstanced(36, mNumberOfActiveCubes, 0, 0, 0);
}
No blur
PS_BlurV
PS_BlurH
P0 + P1
As you can see, it does not work at all.
I think the issue is in my BlendState, but I am not sure.
I've seen many articles going with the render to texture approach, but I've also seen articles where both shaders were called in succession, and it worked just fine, I'd like to go with that second approach. Unfortunately, the code was in OpenGL where the syntax for running multiple passes is quite different (http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/). So I need some help doing the same in HLSL :-)
Thanks!