andrés
andrés

Reputation: 412

blend overlapping triangles in opengl

I'm building a thick line from triangles. The problem i'm having is that when the curve is semi transparent and some triangles overlap i get the effect in the picture. I would like for the triangles alphas to not get added.

I'm using this blend function:

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_CONSTANT_ALPHA);

what i see

Upvotes: 0

Views: 793

Answers (2)

Majid Max
Majid Max

Reputation: 517

you can use stencil test for blocking the drawing of already drawn fragments (which prevent blending from the first place)

Upvotes: 1

brigadir
brigadir

Reputation: 6942

You may render the curve to separate render target with full opacity and then draw that target with custom alpha. Otherwise you should avoid overlapping.

Upvotes: 1

Related Questions