Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / Alpha blending non-textured polygons in D3D... Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Justin Wilder

August 05, 1999, 04:16 AM

How is it done in D3D? The mechanism I'm currently using works for textured polygons, but just leaves non-textured polygons completely opaque. I'm not doing anything complicated, I just use the following device settings:

SetRenderState(D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD);
SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCCOLOR);
SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTCOLOR);

Thanks in advance for any help.

Justin


 
Chris Egerter

August 05, 1999, 10:44 AM

>>SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCCOLOR);
>>SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTCOLOR);

Try using this:

D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)


 
Justin Wilder

August 05, 1999, 07:39 PM

Chris Egerter wrote:
>>>>SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCCOLOR);
>>>>SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTCOLOR);
>>
>>Try using this:
>>
>>D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
>>D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)
>>
>>

I'm sorry, I wasn't very clear in my first post. The non-textured polygons are being drawn without an alpha channel. All I really want is some sort of average or additive blend between the diffuse color of the polygon and the background. Any sort of blend involving an alpha value will thus not work. I tried the blend you gave me anyways, though, just to make sure. It just causes the entire polygon to disappear. But thanks anyways. Anybody have any other ideas?

Justin

 
Chris Egerter

August 06, 1999, 11:24 AM

You need to set the alpha values in the vertices you're drawing too. If you left them at 0 of course it won't show the poly.

If you want additive, use

D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)


 
Justin Wilder

August 07, 1999, 01:24 AM

Thank you, that actually makes a lot of sense. But... I still can't get it to work. Are there extra render options required to set this up correctly? I set the alpha value of all vertices to .5, and tried both blend methods you gave me, but it still draws opaquely (both in software and hardware). Other than the blend mode and the vertex alpha, all of my device settings are the same as was listed in my first post. Is there anything wrong with those? And please forgive my ignorance on this matter, I'm not very D3D-literate.

Justin

Chris Egerter wrote:
>>You need to set the alpha values in the vertices you're drawing too. If you left them at 0 of course it won't show the poly.
>>
>>If you want additive, use
>>
>>D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
>>D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)
>>
>>

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.