I want to achieve a distortion effect which distorts the full screen. For that I spawn a couple of images with normal maps. I render their normal map part on some camera facing quads onto a rendertarget which is cleared with the color (127,127,255,255). This color means that there is no distortion whatsoever. Then I want to render some images like this one onto it:
If I draw one somewhere on the screen, then it looks correct because it blends in seamlessly with the background (which is the same color that appears on the edges of this image). If I draw another one on top of it then it will no longer be a seamless transition. For this I created a blendstate in directX 11 that keeps the maximum of two colors, so it is now a seamless transition, but this way, the colors lower than 127 (0.5f normalized) will not contribute. I am not making a simulation and the effect looks quite convincing and nice for a game, but in my spare time I am thinking how I could achieve a nicer or a more correct effect with a blend state, maybe averaging the colors somehow? I I did it with a shader, I would add the colors and then I would normalize them, but I need to combine arbitrary number of images onto a rendertarget. This is my blend state now which blends them seamlessly but not correctly:
D3D11_BLEND_DESC bd; bd.RenderTarget.BlendEnable=true; bd.RenderTarget.SrcBlend = D3D11_BLEND_SRC_ALPHA; bd.RenderTarget.DestBlend = D3D11_BLEND_INV_SRC_ALPHA; bd.RenderTarget.BlendOp = D3D11_BLEND_OP_MAX; bd.RenderTarget.SrcBlendAlpha = D3D11_BLEND_ONE; bd.RenderTarget.DestBlendAlpha = D3D11_BLEND_ZERO; bd.RenderTarget.BlendOpAlpha = D3D11_BLEND_OP_MAX; bd.RenderTarget.RenderTargetWriteMask = 0x0f;
Is there any way of improving upon this?
(PS. I considered rendering each one with a separate shader incementally on top of each other but that would consume a lot of render targets which is unacceptable)