D3D9 How To Combine vert alpha with texture alpha
cbxThe D3D9 managed "How to" docs has a "Blend a texture with vertex color" example. But, what I think many people want is to apply a texture to there mesh and use the vertex color for setting the ammount of transparency. I am posting this because from the fourm posts that I have read, many people are having trouble doing this. 1: To do this make sure you load your texture with a color key. For example ... Public Function Add(ByVal Dev As Direct3D.Device, _ ByVal Filename As String, ByVal ColorKey As Color) As Integer Dim Tex As Direct3D.Texture Tex = Direct3D.TextureLoader.FromFile(Dev, Filename, _ 0, 0, 1, 0, Direct3D.Format.Unknown, _ Direct3D.Pool.Managed, Direct3D.Filter.Linear, _ Direct3D.Filter.Linear, ColorKey.ToArgb) Return Add(Tex) End Function 2: Then spesify these texture states when you render your verts ... ' Blend a Texture with Vertex Color .TextureState(0).ColorOperation = _ Direct3D.TextureOperation.Modulate TextureState(0).ColorArgument1 = _ Direct3D.TextureArgument.TextureColor .TextureState(0).ColorArgument2 = _ Direct3D.TextureArgument.Diffuse .TextureState(0).AlphaOperation = _ Direct3D.TextureOperation.Modulate ... These are the same texture states that you find in the how to example but with one difference. The last line of code ... .TextureState(0).AlphaOperation = _ Direct3D.TextureOperation.Modulate ... specifies modulate instead of disable.