Blend factors for multi-pass shading

Started by
1 comment, last by Husbj 8 years, 7 months ago

This is probably one of those dead-simple things but I've been unable to figure it out, so I thought I'd ask: what are the appropriate blend factors to use for blending the colour output from one draw call ("pass 1") with another one ("pass 2")?

As I've understood it, multi-pass shading is really just a matter of drawing the same geometry more than once with different shaders and states, so the way I figure it to be supposed to work is that my first set of shaders (or rather the pixel shader) draws something to the back buffer / render target, then the second set of shaders again draw to the render target, and this time I want to blend what is being output in this shader pass with what is already on the render target from the last one.

I've been trying all kinds of different blend factor combinations but most of them seem to only end up either overwriting the first pixel shader's output with the last one, or it all blends to black. I always assumed this was where you wanted to use D3D11_BLEND_SRC_COLOR but now I'm not so sure anymore... would someone perhaps be able to shed some light on this?

On a side note, I'm also disabling depth writing for all but the last draw pass so that the latter passes won't be clipped since they end up having the same Z-coordinates.

Thanks for any information,

Husbjörn

Advertisement

I think this is what I use for deferred shading, which should simply add colors:

D3D11_BLEND_DESC BlendStateDesc_Add = {FALSE, FALSE, {TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_ADD, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL}};

this means "multiply src+dest color by ONE, and ADD them together" :)

.:vinterberg:.

Ah, thank you, that does indeed work :)

I was not aware that that was how the ONE/ZERO factors were supposed to work. Cheers!

This topic is closed to new replies.

Advertisement