Overlapping alpha blended polygons

Hi there!

I have an issue which I don’t know how to solve.
I have two overlapping polygons which are alpha blended. The problem is that the place they overlap eachother is much darker than the rest.

Is there any way to avoid it and have the same alpha even there they overlap?

Well, the usual way color alpha-shadding is calculated is basically

FinalColor = Color1alpha1 + (1-alpha1)Color2alpha2 + [other polygons] + (1-alpha1)(1-alpha2)*BackgroundColor

This being the case, if you only have one polygon, your color values will always be lower than if there is an overlap, since you then don’t have all those other additions.

What is your blend func ?
Screenshot ?

It looks like this:

And i want it to look like this:


this is the function i use to achieve transparency.

Use the stencil buffer :

  • clear to 0
  • set stencil test to pass only when stencil value is 0
  • set 1 on draw

How do i do that?

//Sorry but i’m completly new in OpenGL

Search for opengl stencil tutorials, that should get you started.

When you ask for a stencil buffer, it will store a number for each pixel, and can test for specific values to restrict drawing to some pixels.

What you want to do is similar to :