How to clip the texture in rounded shape
I need to display texture of image with the rounded shape,my code as follow
texture = Texture.FromBitmap(device,myBitmap, Usage.RenderTarget, Pool.Default);
_sprite.Begin(SpriteFlags.SortTexture | Sprit开发者_如何学运维eFlags.DoNotModifyRenderState); _sprite.Draw(_allocator.Texture, Vector3.Empty, new Vector3(_objectLocation.X, _objectLocation.Y, 0), RenderingColor); _sprite.End();
But it always show rectangle texture, how can clip this texture in rounded shape.
Use the alpha channel of the texture (255 is opaque, 0 is transparent and anything between the 2) and set alpha blending and alpha testing to not draw the transparent pixels.
Edit: (Try these alpha settings once you have your 4 channel texture set up).
ALPHABLENDENABLE = TRUE
SRCBLEND = SRCALPHA
DESTBLEND = INVSRCALPHA
ALPHATESTENABLE = TRUE
ALPHAREF = 192
ALPHAFUNC = GREATER
精彩评论