Ming_Lei Posted May 7, 2004 Posted May 7, 2004 I am trying to do transparency in DirectX with C# in MS VS. How do you set up RenderState and Alpha values for Mesh textures to achieve this? :-\ Quote
LDV Posted May 8, 2004 Posted May 8, 2004 I am trying to do transparency in DirectX with C# in MS VS. How do you set up RenderState and Alpha values for Mesh textures to achieve this? :-\ I don't know about meshes ... but i use Sprite class for viewing textures. I initiate the sprite.begin function with SpriteFlags.AlphaBlend LDV Quote
rifter1818 Posted May 9, 2004 Posted May 9, 2004 Hm Im not sure of an easy way to do it But you could use a pixel shader and a mapping texture (use the texture to store the alpha values using a grayscale) then add the transparancy in the pixel shader but this is probably a much more complicated method than your looking for. Quote
Kavan Posted May 9, 2004 Posted May 9, 2004 With device.TextureState(0) .ColorOperation = TextureOperation.Modulate .ColorArgument1 = TextureArgument.TextureColor .ColorArgument2 = TextureArgument.Diffuse .AlphaOperation = TextureOperation.Modulate .AlphaArgument1 = TextureArgument.TextureColor .AlphaArgument2 = TextureArgument.Diffuse End With With device.RenderState .AlphaBlendEnable = True .SourceBlend = Blend.SourceAlpha .DestinationBlend = Blend.InvSourceAlpha .AlphaTestEnable = True .ReferenceAlpha = &H8 .AlphaFunction = Compare.GreaterEqual End With If you set the states like this then if the texture has an alpha value stored in it, you'll get transparency. Sorry it's in VB.NET, but I guess you can manage. Quote
Ming_Lei Posted May 9, 2004 Author Posted May 9, 2004 ....[/Quote] Thanks for the information. I will see if I can use it. Another question I like to ask is that what do I do to divide a large texture image (BMP) into small textures so I can map to different rectangular objects? Which functions I should use to divide the bitmap? - Thanks. :rolleyes: Quote
DrunkenHyena Posted May 9, 2004 Posted May 9, 2004 Thanks for the information. I will see if I can use it. Another question I like to ask is that what do I do to divide a large texture image (BMP) into small textures so I can map to different rectangular objects? Which functions I should use to divide the bitmap? Device.StretchRectangle should do what you want. Load the main image into a surface. Create your smaller textures and then get their surfaces by calling GetSurfaceLevel. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.