Problem of transparent.object (overlapping part)

I added a shadow effect for 3D Object. When the shadow of the two objects overlap with each others it will create a different color at the overlapping part but what I want is the overlapping part to dispay the same color. The shadow for both of the objects render in the same color and same alpha value so I expect the overlapping part also display with the same color. This is the Snippet code that I set up the blending effect before I draw the object.

internal virtual void StartTransparentColor(float[] color)
    {
        Gl.glDisable(Gl.GL_LIGHTING);
        Gl.glEnable(Gl.GL_BLEND);		// Turn Blending On
        Gl.glDepthMask(Gl.GL_FALSE);
        Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
        Gl.glColor4f(color[0], color[1], color[2], color[3]);            
    }

Please show me how to do it. Thanks in advance!!!

You are apparently drawing projective shadow textures and don’t understand how blending works.

Take an example. If you blend black on white at 50% alpha, you get 50% grey. If you blend black on top of that again, you should expect to get an even darker grey.

That’s just one of the disadvantages of using this shadow technique. It’s called double-counting.

Sometimes instead of blending these projected shadows on directly, you can use them to set the stencil buffer, and then do a full-screen “dim” pass to dim out only those areas where the stencil buffer is set so you don’t get double counting. But it’s a hack.

Hi Dark Photon,

Other than using this method to display the shadow. Can you suggest any other method(Better than this)? Thanks in advance!!

Well, better is relative. Which one is best depends on your application’s specific requirements. Projective shadow texturing is simple and may be all that you need.

Shadow mapping is a very common general method, with numerous bolt-on techniques depending on what you need (roughly classified in the categories of warping, partitioning, and filtering).

Shadow volumes is another technique, but with high fill requirements for general scenes and trouble supporting alpha casters. There are a bunch of other shadow methods as well, each with their own limitations.

Thank! I will give them a try.