Correct Parameter For glBlendFunc Function

Hi!!!

I’ve got a question about the glBlendFunc. How do i have to choose the parameters to get this result:

Image1
Image2
Blending

greetz

I dont see any blending being done in that picture. You just draw image2 on top of image1.

Is this not blending, where alpha = 0?

Ist that not possible with glBlendFunc in general?

My idea was to do this overlay by using glBlendFunc. The Image2 should be a texture with alpha channel.

Usually, these two lines should do the trick:


	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

And yes, this is blending because otherwise, the white background would cover all the stars, which it does not due to alpha=0.

What you want is probably disabled blending with an Alpha-Test.
Alpha-Test will cull all fragments where the alpha value does not satisfy the test.

That seems to work. Thank you Brokenmind :angel:.

[QUOTE=Cornix;1258518]What you want is probably disabled blending with an Alpha-Test.
Alpha-Test will cull all fragments where the alpha value does not satisfy the test.[/QUOTE]

How can i implement this? Or is this only possible with a fragment shader?

With the blending provided by Brokenmind it will work too. If you want to do it without blending (because you really dont need blending if you only use alpha values of 1 and 0) then you can do:


glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_EQUAL, 1);

This will make it so that only those fragments with an alpha value of exactly 1 will be drawn. All other fragments will be discarded.