Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
When Microsoft® Direct3D® Mobile renders a primitive, it generates a color for the primitive based on the primitive's material, or the colors of its vertices, and lighting information. For details, see Introduction to Lighting and Materials. If an application enables texture blending, Direct3D Mobile must then combine the color value of the processed polygon pixel with the pixel already stored in the frame buffer. Direct3D Mobile uses the following formula to determine the final color for each pixel in the primitive's image.
FinalColor = TexelColor × SourceBlendFactor + PixelColor × DestBlendFactor
In this formula, FinalColoris the final pixel color that is output to the target rendering surface. TexelColorrepresents the incoming color value, after texture filtering, that corresponds to the current pixel. For details on how Direct3D Mobile maps texels to pixels, see Texture Filtering. SourceBlendFactoris a calculated value that Direct3D Mobile uses to determine the percentage of the incoming color value to apply to the final color. PixelColoris the color of the pixel currently stored in the primitive's image. DestBlendFactorrepresents the percentage of the current pixel's color that will be used in the final rendered pixel. The values of SourceBlendFactorand DestBlendFactorrange from 0.0 to 1.0 inclusive.
As you can see from the preceding formula, the final rendered pixel is not rendered as transparent if the SourceBlendFactoris D3DMBLEND_ONE and the DestBlendFactoris D3DMBLEND_ZERO (see D3DMBLEND). It is completely transparent if the SourceBlendFactoris D3DMBLEND_ZERO and the DestBlendFactoris D3DMBLEND_ONE. If an application sets these factors to any other values, the resulting final rendered pixel is blended with some degree of transparency.
After texture filtering, every pixel color value has red, green, and blue color values. By default, Direct3D Mobile uses D3DMBLEND_SRCALPHA as the SourceBlendFactorand D3DMBLEND_INVSRCALPHA as the DestBlendFactor. Therefore, applications can control the transparency of processed pixels by setting the alpha values in textures.
An application controls the blending factors with the D3DMRS_SRCBLEND and D3DRS_DESTBLEND render states (see D3DMRENDERSTATETYPE). Invoke the IDirect3DMobileDevice::SetRenderStatemethod and pass either render state value as the value of the first parameter. The second parameter must be a member of the D3DBLENDenumerated type.