Sign in to follow this  
PinkFish

D3DBLENDOP Modulate?

Recommended Posts

Hello, why isnt there a D3DBLENDOP_MODUALTE? I would like to modulate while blending, how do i achieve that? will i have to use some 'dummy texture' and use D3DTOP_MODULATE? or is there a better way? thx alot!

Share this post


Link to post
Share on other sites
I don't think I follow... there is a D3DTOP_MODULATE (and 2x/4x versions)??

Structuring complex blending effects with the old style FF pipeline can be non-trivial. Drawing it out on paper always helped me...

Depending on what you're trying to do you might have to insert/add an additional texture stage that modulates and feeds the result down.

Some more details on what you're trying to do might be useful.

Alternatively, just make things simpler and use shaders [grin]

hth
Jack

Share this post


Link to post
Share on other sites
If you mean for frame buffer blending using D3DRS_SRCBLEND/D3DRS_DESTBLEND, then take a closer look at the available frame buffer blending equation:


RESULTrgb = (SOURCErgb * SOURCEfactor) + (DESTrgb * DESTfactor)

where SOURCEfactor is controlled by D3DRS_SRCBLEND and DESTfactor by D3DRS_DESTBLEND

Then take a look at the things you can specify for SOURCEfactor and DESTfactor, of interest for a straight modulate are:

D3DBLEND_ZERO
D3DBLEND_SRCCOLOR
D3DBLEND_DESTCOLOR


Consider for example:

RESULTrgb = (SOURCErgb * D3DBLEND_DESTCOLOR) + (DESTrgb * D3DBLEND_ZERO)

or

RESULTrgb = (SOURCErgb * D3DBLEND_ZERO) + (DESTrgb * D3DBLEND_SRCCOLOR)

Share this post


Link to post
Share on other sites
thx jack,

what i am doing now is alpha blending wihout any textures just by using a D3DMATERIAL (i just need to blend a fixed color) , i was using the material alpha to do the blending,
but now i need to make modulative blending and not additive one, so i looked at the options i have in D3DBLENDOP there is additive substractive, and some other options but no D3DBLENDOP_MODULATE.

so i guess to make modulative blending i ll either have to use a texture and use texture blending op's or a shader ?

Share this post


Link to post
Share on other sites
To do a modulate blend mode you need to set your blendop to D3DBLENDOP_ADD, your SrcBlend to D3DBLEND_INVSRCALPHA and your DestBlend D3DBLEND_INVSRCALPHA. This will modulate between src and dest color based on src alpba (so result==srcColor if srcAlpha=1.0 and result==destColor if srcAlpha==0.0)

Share this post


Link to post
Share on other sites
Quote:
Original post by griffin2000
To do a modulate blend mode you need to set your blendop to D3DBLENDOP_ADD, your SrcBlend to D3DBLEND_INVSRCALPHA and your DestBlend D3DBLEND_INVSRCALPHA. This will modulate between src and dest color based on src alpba (so result==srcColor if srcAlpha=1.0 and result==destColor if srcAlpha==0.0)


this is what i was using before, i would call this additive blending no?

what S1CA suggested:

RESULTrgb = (SOURCErgb * D3DBLEND_ZERO) + (DESTrgb * D3DBLEND_SRCCOLOR)

seems to be what i need.

Share this post


Link to post
Share on other sites
Its what I'd call a modulate (I'd say Additive was a having DestBlend of ONE). But your right, what S1CA describes is the equivalent of D3DTOP_MODULATE (what I desribe is the equivalent of D3DTOP_BLEND...).

Share this post


Link to post
Share on other sites

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