This topic is now archived and is closed to further replies.


Combining alphaargs

Recommended Posts

I''m telling the texture to use a D3DTA_TEXTURE alpha op for alpha blending, but now I want to specify that I want to use D3DTA_TEXTURE AND D3DTA_DIFFUSE... I''ve tried some combinations but I can''t figure it out... Thanks! PS: I''ve already tried: SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);

Share this post

Link to post
Share on other sites
First you have to understand what the texture stage states actually do. They will take color sources and blend them together to get a final color for rendering. You specify the color sources in the alpha and color arguments. So for example, if you wanted to blend the current diffuse color and the current texture for that stage, then you would use the following(using default operator):

//set the first color source to the diffuse. the alpha and colors are blended seperatly
//set the second color source to the texture (D3DTS_TEXTURE) for that stage

Once you set the sources for that stage, you need to specify an operator. There are only two operators per stage. They are the alpha and color operator. If you wanted to blend the alpha values using modulation and you want to add the color values, then you would use the following:


And that would add the color values of the sources together and multiply the alpha values. With me so far? The reason I just wanted to cover this real quick is because you are trying to set two alpha operators. There is only one alpha operation in a stage. I''m a bit confused over your question so if you understand what I just said, then can you explain what you mean a little more?

My Site
Come join us on IRC in #directxdev @

Share this post

Link to post
Share on other sites
What you are doing doesn''t really make much sense. First you set the alpha operation to D3DTOP_SELECTARG1 and after that you set it to D3DTOP_SELECTARG2. This means that the alphaoperation will use alpha argument 2 and ignore argument 1. If you want to use both argument you probably want to you D3DTOP_MODULATE like this:

SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);

This will modulate the alpha value from the texture with the alpha argument from the diffuse color.


Real programmers don''t document, if it was hard to write it should be hard to understand

Share this post

Link to post
Share on other sites