|
OpenGL Shadow Color |
Myrdos
Member #1,772
December 2001
|
I've finally got projection shadows working in OpenGL, however the only way I know to draw them is in solid black: 1 glDisable(GL_BLEND);
2 glDisable(GL_LIGHTING);
3 glColor4f(0.0, 0.0, 0.0, 0.0);
4 glPolygonMode(GL_FRONT_AND_BACK, polygonMode);
Does anyone know how to draw transparent shadows? I basically want to blend the existing color with the color black, but everything I've tried results in no shadow at all! __________________________________________________ |
gnolam
Member #2,030
March 2002
|
So what happens if you enable blending (with an appropriate glBlendFunc()) and use a > 0 alpha value? -- |
Trent Gamblin
Member #261
April 2000
|
As a start, and maybe push in the right direction, you'll need GL_BLEND on, and set glBlendFunc to something like "glBlendFunc(GL_ALPHA, GL_INVERSE_ALPHA)".
|
Myrdos
Member #1,772
December 2001
|
Hmm, I don't fully understand these blending functions... I fooled around until I found a combination that seems to work: 1 glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2 glDisable(GL_LIGHTING);
3 glColor4f(0.0, 0.0, 0.0, 0.5);
4 glPolygonMode(GL_FRONT_AND_BACK, polygonMode);
And the produced shadow (from the red cube): __________________________________________________ |
Trent Gamblin
Member #261
April 2000
|
Yeah, that makes sense. ONE_MINUS_ALPHA is what I meant, but I'm used to Allegro 5 terms which call it INVERSE_ALPHA.
|
Myrdos
Member #1,772
December 2001
|
Trent Gamblin said: Yeah, that makes sense. Even better! Cookies all around! __________________________________________________ |
gnolam
Member #2,030
March 2002
|
Normally, you'd want glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). That's the "standard" translucency blending function. -- |
Trent Gamblin
Member #261
April 2000
|
Oops, what gnolam said. I didn't catch that. :x
|
|