blending

Started by
2 comments, last by devronious 18 years, 3 months ago
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?
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
// 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?
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

This topic is closed to new replies.

Advertisement