Jump to content
  • Advertisement
Sign in to follow this  
Nanoha

XNA - alpha blend not working but alpha test does

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just started on a little project, all I want for now is to draw a textured quad on top of what ever is on screen. When I use alpha blending nothing happens, I get every part of my texture visible. When I use alpha test then everything looks correct. This is all pretty simple I know so I must be over looking somehting very basic, any ideas what? My render method:
public void Render(GraphicsDevice graphicsDevice)
        {
            graphicsDevice.VertexDeclaration = m_VertexDecl;
            /*graphicsDevice.RenderState.AlphaTestEnable = true;
            graphicsDevice.RenderState.AlphaFunction = CompareFunction.GreaterEqual;
            graphicsDevice.RenderState.ReferenceAlpha = 127;*/
            graphicsDevice.RenderState.AlphaBlendEnable = true;
            graphicsDevice.RenderState.AlphaSourceBlend = Blend.SourceAlpha;
            graphicsDevice.RenderState.AlphaDestinationBlend = Blend.InverseSourceAlpha;

            m_Effect.View = ViewMatrix;
            m_Effect.Projection = ProjectionMatrix;

            m_Effect.Begin();
            foreach (EffectPass pass in m_Effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                graphicsDevice.DrawUserIndexedPrimitives
                    <VertexPositionTexture>(
                    PrimitiveType.TriangleList,
                    vertices, 0, 4,
                    indices, 0, 2);

                pass.End();
            }
            m_Effect.End();
        }
The only other thing going on is clearing the color just before calling this method. The effect is just BasicEffect. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Erik Rufelt
You should use RenderState.SourceBlend, not AlphaSourceBlend. The 'alpha' blend states are there for pre-blending of the actual alpha.


The 'alpha' blend states are there for D3DRS_SEPERATEALPHABLENDENABLE.

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
You should use RenderState.SourceBlend, not AlphaSourceBlend. The 'alpha' blend states are there for pre-blending of the actual alpha.


Worked, thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!