Jump to content
  • Advertisement
Sign in to follow this  

[MDX] Additive Blending

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

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


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
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.


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!