Blending alphachannels..
Blending alphachannels..
Blending alphachannels..
Blending alphachannels..
Blending alphachannels..
Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels..
Blending alphachannels.. Blending alphachannels..
Blending alphachannels..
Go Back  Xtreme Visual Basic Talk > > > > Blending alphachannels..


Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2007, 10:23 AM
afwasborstel afwasborstel is offline
Centurion
 
Join Date: Apr 2003
Posts: 142
Default Blending alphachannels..


I want to take an alphachannel from on texture and put in another texture...
Sofar I have the following code converted from C++

Code:
m_Device.SetTexture(0, Texture1) 'has the alpha I want m_Device.SetTexture(1, Texture2) 'gets the alpha from texture1 '// Alphamap: take the alpha from the alphamap, we don't care about the color m_Device.SetTextureStageState(0, TextureStageStates.AlphaOperation, TextureOperation.SelectArg1) 'D3DTSS_ALPHAOP, D3DTOP_SELECTARG1) m_Device.SetTextureStageState(0, TextureStageStates.AlphaArgument1, TextureArgument.TextureColor) 'D3DTSS_ALPHAARG1, D3DTA_TEXTURE) '// Texture: take the color from the texture, take the alpha from the previous stage m_Device.SetTextureStageState(1, TextureStageStates.ColorOperation, TextureOperation.SelectArg1) 'D3DTSS_COLOROP, D3DTOP_SELECTARG1) m_Device.SetTextureStageState(1, TextureStageStates.ColorArgument1, TextureArgument.TextureColor) 'D3DTSS_COLORARG1, D3DTA_TEXTURE) m_Device.SetTextureStageState(1, TextureStageStates.AlphaOperation, TextureOperation.SelectArg1) 'D3DTSS_ALPHAOP, D3DTOP_SELECTARG1) m_Device.SetTextureStageState(1, TextureStageStates.AlphaArgument1, TextureArgument.Current) 'D3DTSS_ALPHAARG1, D3DTA_CURRENT) 'We have to set the blending render states as well in order to get the multiple splats to combine 'together correctly. D3DRS_SRCBLEND is the alpha coming from the splat being rendered, 'so we set it to D3DBLEND_SRCALPHA. The final equation we want is 'FinalColor = Alpha * Texture + (1 – Alpha) * PreviousColor. ' This is done by setting D3DRS_DESTBLEND to D3DBLEND_INVSRCALPHA. m_Device.SetRenderState(RenderStates.AlphaBlendEnable, True) 'D3DRS_ALPHABLENDENABLE, True) m_Device.SetRenderState(RenderStates.SourceBlend, Blend.SourceAlpha) 'D3DRS_SRCBLEND, D3DBLEND_SRCALPHA) m_Device.SetRenderState(RenderStates.DestinationBlend, Blend.InvSourceAlpha) 'D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)

Altough this code works a little bit in the direction I want...it's not the code I need...any thoughts on this idea?
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
Blending alphachannels..
Blending alphachannels..
Blending alphachannels.. Blending alphachannels..
Blending alphachannels..
Blending alphachannels..
Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels.. Blending alphachannels..
Blending alphachannels..
Blending alphachannels..
 
Blending alphachannels..
Blending alphachannels..
 
-->