Alpha Blending

AndreRyan

Well-known member
Joined
Jan 23, 2002
Messages
366
Ive been trying to figure this out but Im not getting anywhere. How do you set up AlphaBlending AND specify the alpha values to use?

So far Ive got:
Code:
Dev.RenderState.AlphaSourceBlend = Blend.SourceAlpha
        Dev.RenderState.AlphaDestinationBlend = Blend.InvSourceAlpha
        Dev.RenderState.AlphaBlendEnable = True
But I have no idea where to set the alpha property, or whether the declaration is correct anyway, so that the geometry is rendered translucently. Im using PositionColored primitive squares.
 
I figured it out finally, I found BlendFactor does what I want:
Code:
        Dev.RenderState.AlphaBlendEnable = True
        Dev.RenderState.SourceBlend = Blend.BlendFactor
        Dev.RenderState.DestinationBlend = Blend.InvBlendFactor
        Dev.RenderState.BlendOperation = BlendOperation.Add

        Dev.RenderState.BlendFactor = Color.FromArgb(127, 255, 255, 255)
This caused the textures to develop a white "distortion" which was countered with:
Code:
Dev.TextureState(0).AlphaArgument0 = TextureArgument.TextureColor
 
Back
Top