Jump to content
  • Advertisement
Sign in to follow this  
bsh_aoa

About Texture-Blending

This topic is 4634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the D3D SDK Document, it says, "You can disable a texture stage - and any subsequent texture blending stages in the cascade - by setting the color operation for that stage to D3DTOP_DISABLE. Disabling the color operation effectively disables the alpha operation as well. Alpha operations cannot be disabled when color operations are enabled. Setting the alpha operation to D3DTOP_DISABLE when color blending is enabled causes undefined behavior." But when i read the DX sample "Tutorial 5: Textures", I find these codes: //---------------------------------------------------------------------------- g_pd3dDevice->SetTexture( 0, g_pTexture ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); //---------------------------------------------------------------------------- The last line disable alpha operation when the color operation is enable in texture stage 0. Is this right? By the way, I know color operation is about texture color value(maybe RGB), but what is alpha operation about? where is alpha value in the texture?

Share this post


Link to post
Share on other sites
Advertisement
No, this is definitely wrong. The alpha should never be disabled in an active stage, and the sample should also disable stage 1 (though the code will work without this by default).

I notified Microsoft about this.

Share this post


Link to post
Share on other sites
the texture alpha is in th A of the RGBA of the 32 bit texture. you can also do the alpha with materials or vertex colors, if you're using the FFP, you just gotta tell DX where to do it's alpha calculations.

-programmer_tom

Share this post


Link to post
Share on other sites
Didn't notice the last question. :) Alpha is typically used for transparency, via alpha blending. See "Alpha Blending" in the DX docs. (It can also be used as simply another data channel in the texture. Pixel shaders offer enough flexibility that the actual use doesn't matter that much.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!