# [MDX] Blend to zero predefined color on textured object

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

## Recommended Posts

Hello! I need to place the signs near the roads. I have the images of all the signs. The signs may differ by their form. I need the fast productive method to modeling signs and i think that it's a hard way to calculate geometry and uv-coords for each sign-form (e.g. rounded triangle or more complex forms). Also I think that easier not to use alpha channel for each sign image. Instead I want to texture a rectangle-form with a sign image. To visualize needed sign-form I intend to blend predefined border texture color to zero. How can i blend to zero predefined color on textured object? From morning I write the code, than blend all textured rectangle:


ADevice.RenderState.TextureFactor = System.Drawing.Color.FromArgb( 100, System.Drawing.Color.White).ToArgb() ;


Hope hearing from you soon!

##### Share on other sites
You stated that you didn't want to use the alpha channel of the image, and at first I thought you meant that because you didn't want to perform alpha blending. However, you code is alpha blending (which you must do). It would indeed be easier to just save alpha to the texture.

Do you want to blend TO 0 as in a gradient blend, or do you want all one color to be set to 0 alpha? The second can be done when you load the texture. Your code is using TFactor which will apply the alpha value to the whole sign. You just need to use the alpha values from the texture. When you call LoadTextureFromFileEx(...), you can provide the color to replace with an alpha value of 0. Then, set your render states to use the texture alpha value. Then enable alpha blending, and render.

EDIT: I just re-read and understood what you're looking for. You want the rounded corners of a sign. I just removed some code I put in. See my comments above.

Chris

##### Share on other sites
Thx, Supernat02!

I want one color to be set to 0 alpha.

The code:

texture = TextureLoader.FromFile( ADevice, @".\Textures\leftTurn2.bmp", D3DX.Default,D3DX.Default,D3DX.Default,0,					Format.A8R8G8B8, Pool.Managed,Filter.Triangle|Filter.Mirror, Filter.Triangle|Filter.Mirror,					System.Drawing.Color.FromArgb(255,0,255).ToArgb() );ADevice.RenderState.SourceBlend = Blend.SourceAlpha;ADevice.RenderState.DestinationBlend = Blend.InvSourceAlpha;ADevice.RenderState.AlphaBlendEnable = true;			ADevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);		ADevice.RenderState.AlphaBlendEnable = false;

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 14
• ### Forum Statistics

• Total Topics
632155
• Total Posts
3004477

×