Full range alpha blending
Full range alpha blending
Full range alpha blending
Full range alpha blending
Full range alpha blending
Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending
Full range alpha blending Full range alpha blending
Full range alpha blending
Go Back  Xtreme Visual Basic Talk > > > > Full range alpha blending


Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2007, 03:10 AM
dadevil's Avatar
dadevil dadevil is offline
Freshman
 
Join Date: Oct 2004
Location: Michigan
Posts: 27
Default Full range alpha blending


What I'm trying to do is basically alpha blend where the alpha channel on a pixel is 0 through 255, not just with a colorkey. This is kind of confusing for me to explain so here are some pictures.

I have an image consisting of a transparent background and the only color is white, just different transparences ranging from 0 to 255.The first picture is the effect I want to achieve in directx, notice the white button is blending with both the red bar and the black background. This was rendered in Photoshop.

The middle one was rendered in directx with a black background and black colorkey. This doesn't blend with the red bar as only the pure black is seen as alpha.

The last picture used a 32bit png without a colorkey and was closer to the effect I want but it seemed to take the white pixels at any alpha level and produce pure white. Then almost anti-aliasing the outside of the object itself with its own alpha mask.

This is what i've been using to get these effects.
Code:
Private mTexture As Texture = Nothing Private mRectangle As Rectangle Public Sub New() 'Where i load the texture mTexture = TextureLoader.FromFile(mDevice, File, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.Point, Filter.Point, &HFF000000) 'mTexture = TextureLoader.FromFile(mDevice, File) 'Used when no colorkey is wanted Dim s As Surface = mTexture.GetSurfaceLevel(0) Try Dim mSurfaceDescription As SurfaceDescription = s.Description mRectangle = New Rectangle(1, 0, mSurfaceDescription.Width - 1, mSurfaceDescription.Height) Finally s.Dispose() End Try End Sub Public Sub Render() 'My render area mDevice.RenderState.AlphaBlendEnable = True mSprite.Draw(mTexture, mRectangle, Center, Position, Color.White) mDevice.RenderState.SourceBlend = Blend.SourceAlpha mDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha mDevice.RenderState.AlphaBlendEnable = False End Sub
I've tried using every combination of blend's for the source and destination blend's that I can think of but if that's all I have to correct please tell me the right ones. I've tried other file types but most, including the direct3d extension(*.dds), are displayed without any alpha blending. Any help would be appreciated.
Attached Images
File Type: jpg button - proper.jpg (34.3 KB, 4 views)
File Type: jpg button - colorkey.jpg (34.1 KB, 3 views)
File Type: jpg button - png.jpg (35.3 KB, 3 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Full range alpha blending
Full range alpha blending
Full range alpha blending Full range alpha blending
Full range alpha blending
Full range alpha blending
Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending Full range alpha blending
Full range alpha blending
Full range alpha blending
 
Full range alpha blending
Full range alpha blending
 
-->