• Advertisement
Sign in to follow this  

blending

This topic is 4435 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

The idea of combining the pixel values that are currently being computed (source pixel) with the pixel values previously written (destination pixel) is called blending. So if I setrenderstate(D3DRS_ALPHABLENDENABLE, true) , every pixel in a frame will blend with backbuffer previously created. Am I right?

Share this post


Link to post
Share on other sites
Advertisement
You have to set the source and destination as such:

[source lang=c#]
this.device.RenderState.SourceBlend = Blend.SourceAlpha; //set the source to be the source's alpha
this.device.RenderState.DestinationBlend = Blend.InvSourceAlpha; //set the destination to be the inverse of the source's alpha
this.device.RenderState.AlphaBlendEnable = true; //enable this.texture = TextureLoader.FromFile(device, "tex.bmp");



but if the order being drawn isn't correct (ie: front to back when more than one item has alpha channel) then it tweaks for some reason, and the alpha channel most likely will appear black. I wish I understood why. Someone told me why but I still don't quite see why.

-Devin

Share this post


Link to post
Share on other sites
// compute alpha from diffuse colors during shading
Device->SetTextureStageState(0, D3DTSS ALPHAARG1, D3DTA DIFFUSE);
Device->SetTextureStageState(0, D3DTSS ALPHAOP, D3DTOP SELECTARG1);


if I need alpha component of a vertex color other than material how to set?

Share this post


Link to post
Share on other sites
I'm not sure what you mean. If your trying to use alpha from a texture than it should work as explained so long as the dds texture is made correctly. Perhaps someone else is better suited to answer the second question.

-Devin

Share this post


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

  • Advertisement