Jump to content
  • Advertisement
Sign in to follow this  
JohnyCage

texture: degrees of transparency

This topic is 2523 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi dudes.,

how can i start to use 256 degrees of transparency on my textured objects? I use following lines of code:


texture512 = Texture.FromFile(d, "1.png", 512, 512, 1, Usage.None, Format.A8R8G8B8, Pool.Managed, Filter.Triangle, Filter.Triangle, Color.FromArgb(255, 255, 0, 0).ToArgb());
.
.
device.SetRenderState(RenderState.AlphaBlendEnable, true);
device.SetRenderState(RenderState.SourceBlend, SlimDX.Direct3D9.Blend.SourceAlpha);

device.SetRenderState(RenderState.AlphaTestEnable, true);
device.SetRenderState(RenderState.AlphaRef, 0x01);
device.SetRenderState(RenderState.AlphaFunc, SlimDX.Direct3D9.Compare.Always);


Attached picture can describe better my problem. Black places are not mixed by yellow background.

Share this post


Link to post
Share on other sites
Advertisement
You need to set the destination blend type too. Something like:

device.SetRenderState(RenderState.DestBlend, SlimDX.Direct3D9.Blend.InvSourceAlpha);

I'm not sure what the SlimDX state names are, but you want to set the destination blend to inverse source alpha.

Share this post


Link to post
Share on other sites

You need to set the destination blend type too. Something like:

device.SetRenderState(RenderState.DestBlend, SlimDX.Direct3D9.Blend.InvSourceAlpha);

I'm not sure what the SlimDX state names are, but you want to set the destination blend to inverse source alpha.


y, its right answer, thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!