D3DBLENDOP Modulate?

Started by
6 comments, last by griffin2000 17 years, 10 months ago
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!
Advertisement
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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)

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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 ?
ok S1CA thank you i will.
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)
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.
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...).

This topic is closed to new replies.

Advertisement