View Full Version : Overlapping alpha blended polygons
10-03-2011, 01:17 AM
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?
10-03-2011, 03:07 AM
Well, the usual way color alpha-shadding is calculated is basically
FinalColor = Color1*alpha1 + (1-alpha1)*Color2*alpha2 + [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.
10-03-2011, 04:28 AM
What is your blend func ?
10-03-2011, 04:37 AM
It looks like this:
And i want it to look like this:
GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA this is the function i use to achieve transparency.
10-03-2011, 04:43 AM
Use the stencil buffer :
- clear to 0
- set stencil test to pass only when stencil value is 0
- set 1 on draw
10-03-2011, 05:13 AM
How do i do that?
//Sorry but i'm completly new in OpenGL
10-05-2011, 01:09 AM
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 :
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.