Integrated Technology
This technology enables us to combine the color of the currently raster pixel with the color of the previously raster pixel at the same position. This technology is mainly transparent.
Integration steps:
1. Set the fusion factors D3DRS_SRCBLEND and D3DRS_DESTBLEND.
2 If the Alpha component is used, you also need to specify its source (material or Alpha channel ).
3. Enable Alpha Fusion rendering.
Fusion Equation
OutputPixel = SourcePixel * SourceBlendFactor + DestPixel * DestBlendFactor
Color after fusion = source pixel color * Source Integration factor + background cache pixel color * target fusion factor.
· The color value calculated by SorcePixel for fusion with the corresponding pixels in the background cache.
· SourceBlendFActor: Source fusion factor. Specifies the proportion of the color value of the source pixel in the integration. The value ranges from 0 to 1.
· DestPixel is currently in the background cache for pixel color values.
· DestBlendFactor: target fusion factor. Specify the proportion of the target pixel value in the fusion. The value range is within [0, 1.
In Dirct3D, the integrated operation is disabled by default. Set D3DRS_ALPHABLENDENABLE to true. Fusion operation is enabled.
Device-> SetRenderState (D3DRS_ALPHABLENDENABLE, true );
Fusion factor:
By setting the source and target fusion factors, we can create a series of different fusion effects.
Device-> SetRenderState (D3DRS_SRCBLEND, source); // source Resource
Device-> SetRenderState (D3DRS_DESTBLEND, source); // target resource
Transparency
The Alpha component in each vertex color is similar to the color value and gradient along the surface of the triangle unit. However, it is not used to determine the color value of a certain pixel, but to determine the Alpha component of the pixel. The Alpha component is mainly used to specify the transparency of pixels.
If the Alpha value of the vertex is 0, it is transparent, 128 is translucent, and 255 is opaque. [0,255] transparency [0%, 100%].
1. Alpha channel;
We do not directly use the calculated Alpha component, the Alpha channel is often used to obtain Alpha information from the Alpha Channel of the texture. The Alpha channel is an additional bit set (bits set) that stores the Alpha component ).
2. Specify the Alpha Source
By default, if the current texture has an Alpha channel, the Alpha value is taken from the Alpha Channel. If there is no Alpha channel, the Alpha value is taken from the color of the vertex.
Device-> SetTextureStageState (0, d3dtss_alph1_g1, D3DTA_DIFFUSE );
Device-> SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTA_SELECTARG1 );
Device-> SetTextureStageState (0, d3dtss_alph1_g1, D3DTA_TEXTURE );
Device-> SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTA_SELECTARG1 );
DirectX9.0 3D game development and programming Basics
Jiangxi University of Technology FangSH 2010-4-1