Can't use simple material alpha blending ?
I want to make a simple quad (custom vertexs) fading in and out (work as a fade in/out background).
I see there are some method to changing alpha , like vertex alpha , texture alpha , material alpha. But I want a simple changing alpha method by setting the material alpha , but somehow , I do not work. Below is my code :
(DirectX 9.0 SDK 2004 Summer update + Visual Studio 2003)
device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
device.RenderState.AlphaBlendEnable = true;
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
backgroundColor = Color.FromArgb((int)backgroundAlpha * 0xff, 255, 255, 255);
backgroundMaterial.Diffuse = backgroundColor;
device.TextureState[0].AlphaArgument1 = TextureArgument.Diffuse;
device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
device.Material = backgroundMaterial;
device.SetStreamSource( 0, backgroundVertexBuffer, 0 );
device.DrawPrimitives( PrimitiveType.TriangleStrip, 0, 2 );
device.RenderState.AlphaBlendEnable = false;
The alpha is control by backgroundAlpha ( 0 <= a <= 1).
Anyone help ?