texture: degrees of transparency

Started by
2 comments, last by JohnyCage 12 years, 3 months ago
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.
Advertisement
attached better picture.
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.

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.

This topic is closed to new replies.

Advertisement