Sign in to follow this  

Blend factors for multi-pass shading

This topic is 824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Edited by Husbjörn

Share this post


Link to post
Share on other sites

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" :)

Edited by vinterberg

Share this post


Link to post
Share on other sites

This topic is 824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this