Separate alpha blend enable states for MRT

Started by
12 comments, last by eigers 15 years, 5 months ago
Hello everyone, My application uses D3D9. I have a main render target into which the scene is rendered, and an additional render target used for writing some data which I'm using later. My problem is that when the scene is rendered with alpha blending enabled, my second RT gets blended as well, which produces meaningless values. Is there a way in D3D9 to enable alpha blending only for a specific RT? The D3D docs don't mention such an option, but I know that in OpenGL it's possible with some extension (DrawBuffers2 I think), so it's not a hardware limitation. Thanks.
Advertisement
Unfortunately you're stuck in D3D9. Seperate blending states for MRT's was a feature added for D3D10.

[Edited by - MJP on November 7, 2008 10:56:29 AM]
D3D10 you mean I guess...
That's the answer I was afraid of... I can't move to D3D10. Isn't there some hack to do this in D3D9, like a secret format or something (even NV-only will be fine)? I know there are formats which don't undergo any post pixel shader operations, but for some reason I couldn't get them to work properly.
Whoops, definitely meant to put "D3D10" there. :P

Anyway I don't know of any hacks or vendor-specific stuff to get around this. You could do the blending yourself in the shader by ping-ponging between render targets, but that's not exactly cheap...
I think that though alpha blending is enabled for all render targets, the alpha of a specific target will be used for that target's rendering. In that case, just setting the alpha to 1 for the second RT will solve the problem. You're losing one output component, but that shouldn't be an insurmountable problem.
How about when the second RT is a float target (say R32F)? What would be considered as alpha here?
Quote:Original post by eigers
How about when the second RT is a float target (say R32F)? What would be considered as alpha here?


It will still use the alpha value of the output, even if that alpha component isn't being stored anywhere.
For the source it's understood, because the pixel shader always outputs a 4-component vector, but what about the destination, which doesn't store the alpha component at all? Is it always expanded to 1?
AFAIK it should be 1. Are you using dest alpha?
Actually no, I don't really have a problem there. But I do have a problem with blending modes which use the destination color (e.g. D3DRS_DESTBLEND = D3DBLEND_ONE), as I don't want the second RT blended at all.
It seems that there really is no way around this in D3D9...

This topic is closed to new replies.

Advertisement