Bagikan melalui


RenderState.DestinationBlend Property

Gets or sets the color blending factor. This factor represents a value by which to multiply the destination pixel color before adding it to the source pixel to produce a color that is a blend of the two. The default is Blend.Zero.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public Blend DestinationBlend { get; set; }

Property Value

A Blend factor to set or get for the destination pixel.

Remarks

The alpha value of a color controls its transparency. Enabling alpha blending with AlphaBlendEnable allows colors, materials, and textures on a surface to be blended with transparency onto another surface.

Alpha blending is determined by the SourceBlend and DestinationBlend properties. With the default BlendFunction, the source pixel times the SourceBlend is added to the destination pixel (the pixel on the back buffer) times the DestinationBlend to produce a color that is a blend of the two pixel colors. The BlendFunction determines the operation used on the outcome of the source blend and destination blend components.

Example

The following short code snippet sets the render state to use additive alpha blending prior to a draw call.

graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true;
graphics.GraphicsDevice.RenderState.SourceBlend = Blend.One;
graphics.GraphicsDevice.RenderState.DestinationBlend = Blend.One;
graphics.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add;

// TODO: Place the drawing calls that should be alpha blended here.

See Also

Reference

AlphaBlendEnable
SourceBlend
BlendFunction
RenderState Class
RenderState Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista