Jump to content
  • Advertisement
Sign in to follow this  
acid2

[MDX] Additive Blending

This topic is 4504 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

Nearly got my deferred lighting sample done, but I can't seem to get additive blending. Here's what I'm doing:
        private void RenderToBackBuffer(Device device)
        {
            device.Transform.World = camera.WorldMatrix;
            device.Transform.View = camera.ViewMatrix;
            device.Transform.Projection = camera.ProjectionMatrix;

            effect.Technique = "Light";

            for (int i = 0; i < lights.Length; i++)
            {
                device.RenderState.ZBufferEnable = false;
                device.RenderState.ZBufferFunction = CompareFunction.Always;

                device.RenderState.AlphaBlendEnable = true;
                device.RenderState.AlphaBlendOperation = BlendOperation.Add;
                device.RenderState.AlphaSourceBlend = Blend.One;
                device.RenderState.AlphaDestinationBlend = Blend.One;

                effect.SetValue("lightPosition", lights.Position);
                effect.SetValue("lightColour", new ColorValue(lights.Color.R, lights.Color.G, lights.Color.B));

                // Render the cubes
                /*effect.Begin(EffectFlags.None);
                effect.BeginPass(0);*/

                SurfaceDescription desc = device.GetBackBuffer(0, 0).Description;
                Draw(device, new System.Drawing.RectangleF(i * 400, 0, desc.Width, desc.Height));

                /*effect.EndPass();
                effect.End();*/
            }
        }

However, I just see 2 quads overlapping, no blending at all. Any ideas? The vert format is TrasformedColouredTextured, just to test (I disabled shaders but they will come back in, only a pixel shader) - when it works it will be TransformedTextured (no colours).

Share this post


Link to post
Share on other sites
Advertisement
Use RS's like SourceBlend, DestinationBlend, etc. instead of AlphaSourceBlend. That should fix your problem.

Share this post


Link to post
Share on other sites
I can't see what's causing your problem, sorry, I don't have any experience with blending yet. But I was curious, don't you think you should take all those render state changes out of the loop? Seems pretty redundant.

-AJ

Share this post


Link to post
Share on other sites
I'd agree with cypher on this one.

Device.RenderState.SourceBlend = Blend.One;
Device.RenderState.DestinationBlend = Blend.One;
Device.RenderState.AlphaBlendEnable = true;



I hope this helps.
Take care.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!