Sign in to follow this  

Alpha blending and Effects combined

Recommended Posts

Hi, I´m trying to draw a cheap disc with controlled color values, by using a texture containing a circle (also in the alpha channel), alpha blending using the texture alpha channel and a shader to write a color value that differ from that of the texture. I imagine this would be a cheap way of drawing a disc in space, with color values that differ from the texture, since om using two triangles and dont have to edit the texture. However it does not alpha blend properly when the effect is added to the mix. Does anyone know why this is so ? And possibly how this can be done ? A snip of the c# code looks like this, where "MeshColor" is the color I would like to write on a disc in space. (Sorry for the straight paste of the code, dont know the syntax.. will look into it :D ) ------------------------------------------------------------------------ device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.SourceAlpha; device.RenderState.Lighting = false; device.VertexFormat = CustomVertex.PositionTextured.Format; device.SetTexture(0,circle); device.SetStreamSource(0, disc_vb, 0); device.Indices = disc_ib; effect_meshcolor.SetValue("MeshColor",new Vector4(pdist/100,radius,0,1.0f)); int passes = effect_meshcolor.Begin(0); for (int pass = 0; pass < passes; pass++) { effect_meshcolor.BeginPass(pass); effect_meshcolor.CommitChanges(); device.DrawIndexedPrimitives(PrimitiveType.TriangleList,0,0,4,0,2); effect_meshcolor.EndPass(); } effect_meshcolor.End(); ------------------------------------------------------------------------

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this