Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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

Posted

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.

Posted

        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.

Posted
....[/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:

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...