glow effect with textures

I can get a decent “glow” effect by drawing slightly larger, slightly more translucent copies of an object at the same position as the actual object.

glScalef(1,1,1);
glColor4f(1.0f, 0.0f, 0.0f, 1);
DrawSphere();
glScalef(1.1, 1.1, 1.1);
glColor4f(1.0f, 0.0f, 0.0f, .5);
DrawSphere();
glScalef(1.2, 1.2, 1.2);
glColor4f(1.0f, 0.0f, 0.0f, .2);
DrawSphere();

where DrawSphere() is
GLUquadricObj *quadratic;
quadratic = gluNewQuadric();
gluQuadricNormals(quadratic, GLU_SMOOTH);
gluSphere(quadratic, 1.0f, 32, 32);

However, if I want to do this with a textured object

glBindTexture(GL_TEXTURE_2D, ColorId_);
glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

gluQuadricTexture(quadratic, GL_TRUE);

Then where can I set the alpha parameter??

Thanks,

Dave

do you enable alpha blending?

I do enable alpha blending with

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

but the question is how do I specify the alpha of a textured object?

it’s the same just use glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
Though you may have to enable GL_COLOR_MATERIAL first

ok so then the next thing drawn will just use that alpha value but not the color (since the colors are determined by the texture instead)?

by default (GL_MODULATE) it is color * texture.
So a white color is like 1 * texture == texture.

Ok, well that seems to work as far as enabling the transparency, however it looks just like a blur instead of a glow. Is there a way to make it “brighter” as well as transparent?

glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

Since the texture is drawn in a different position (ie. a larger object) you can see the shifted textures.


See how the sun spot appears multiple times?

Is there a way to get the glow without seeing multiple textures?

Thanks,

Dave

The idea is to blur the added image.
Typically :

  1. render the scene,
  2. then copy it to texture,
    3a) then blur the texture,
    3b) then draw a fullscreen quad with this texture.

Depending on your opengl knowledge, there are multiple ways to do this. For example steps 3 a and a can be done at the same time through a proper shader.

I addition to what Zbuffer said, you can blur your picture more, copying the scene rendering in a texture twice smaller, blurring it with a gaussian filter for example and then blending it with the original scene rendering. This way you benefit from the hardware bilinear filtering that cheaply blur your texture before blending.

In addition you could also put steps 1 and 2 in the same step by using FBOs.