Blend issue

Started by Meanz, August 09, 2011, 07:43:38

Previous topic - Next topic

Meanz



It is really hard to explain this, but as you can see, there are two different outcomes in the two squares. And I don't understand why :/
I want both to be outcomes to be the same as the green one.

Any hints?


Edit:

There is two quads, both are 1x1
And the  1,0 -> 0,1 quad is drawed first.
Thus shaping an X

I have just enabled GL_BLEND with GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
And I loaded a picture that had some transparent pixels. It was saved using photoshop.
And it's a png

spasi

You have to disable depth writes while rendering these quads. Try glDepthMask(false);

Meanz

I tried using glDepthMask(false); (Thanks for that)

I can now see that the quad, which is behind the red square is now rendered on top of the red square, making it look odd.
but also if I render them in the opposite order, I will just get the same problem when viewing my quads from another angle.


Could you think of any ways to solve this then :)?

Mickelukas

If you use blend you'll always need to render back to fourth. If you don't want to spend the time on making the engine do that and you only want to render pixels on or off (no transparency) you can use alpha test instead:
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.9f);
//Draw
GL11.glDisable(GL11.GL_ALPHA_TEST);

Kind regards,
Mike

Meanz

Thank you mike, the visual outcome is perfect by using alpha testing.

Now I just got to read up on what the pro's and con's are ;p