Constant Alpha

Hi,

I am doing shadows (which work well) but I have some artifacts which I would like to remove.

Essentially, I would like the alpha to be constant - so if one shadow draws on top of another I would like the alpha to NOT be additive - ie, if lots of shadows get rendered the overall shadow should still have a perceived alpha of 0.5.

I have tried glAlphaFunc(GL_EQUAL, 0.5); but this doesn’t seem to work (the shadows are only drawn in certain places) - I’m assuming this not doing what I think it is doing.

Here is some sample code:

// ---------------------------

glDisable ( GL_LIGHTING );
glDisable ( GL_SMOOTH );
glDisable (GL_TEXTURE_2D);

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

glColor4f(0.1,0.1,0.1,0.5);

DrawShadow();

// reset the states above for normal rendering.
// ---------------------------

Any ideas?

Thanks

OpenGL 1.4 introduced the concept of separate blend states for Alpha - so you can do extactly that - specify a different SRC and DST blend mode for the alpha.
I think you want glBlendFuncSeparate.

Thanks. I’ll take a look - I’m using OpenGL ES though so I’m not sure if I’ll have that functionality.