Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DBLENDOP Modulate?

Started by PinkFish Jun 8, 2006 at 7:39 AM 6 replies 1.9k views
Original Post
PinkFish
PinkFish
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!
jollyjeffers
jollyjeffers
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 |
S1CA
S1CA
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
PinkFish
PinkFish
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 ?
PinkFish
PinkFish
ok S1CA thank you i will.
griffin2000
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)
PinkFish
PinkFish
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.
griffin2000
griffin2000
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...).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.