Results 1 to 3 of 3

Thread: Alpha blending problem

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Arrow Alpha blending problem

    Hello all.

    Finishing off the very first 3D dual video channel model viewer, but I got into a problem. I have already managed to draw the two renders into textures, they are named dLTexture and dRTexture. Both textures are rendered correctly.

    I know how to draw these two textures in cross-eye mode by using sprites (SContainer), but now I have to draw them as anaglyph. This means, both textures with half opacity and left channel no green and right channel no red color. I have to blend these two together, so here is the code:
    Code:
                Device.RenderState.SourceBlend = Direct3D.Blend.DestinationAlpha
                Device.RenderState.DestinationBlend = Direct3D.Blend.SourceAlpha
                Device.RenderState.AlphaBlendEnable = True
                Device.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Transparent, 1, 0)
                Device.BeginScene()
                SContainer.Begin(SpriteFlags.None)
                If KeyPressed(Windows.Forms.Keys.Q) Then
                    SContainer.Draw2D(dRTexture, New Point(0, 0), 0, New Point(0, 0), Color.FromArgb(128, 0, 255, 128))
                    SContainer.Draw2D(dLTexture, New Point(0, 0), 0, New Point(0, 0), Color.FromArgb(128, 255, 0, 128))
                Else
                    SContainer.Draw2D(dLTexture, New Point(0, 0), 0, New Point(0, 0), Color.FromArgb(128, 255, 0, 128))
                    SContainer.Draw2D(dRTexture, New Point(0, 0), 0, New Point(0, 0), Color.FromArgb(128, 0, 255, 128))
                End If
                SContainer.End()
                Device.EndScene()
                Device.Present()
    But, when I press Q the screen changes, and this should NOT happen. The two textures must be blended so that they add color, so twisting the texture draw order should not make a difference. What am I doing wrong here?

    BTW: when I use "Device.RenderState.DestinationBlend = Direct3D.Blend.SourceColor" it multiplies the colors, clearing the red and green channel. I don't want this. It must "add" the color values of both textures.
    Last edited by bergerkiller; Jan 3rd, 2011 at 12:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width