We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
opengl "glow"? (Read 4851 times)
opengl "glow"?
Apr 14th, 2008, 3:24pm
 
hi all

i'm doing some 3d stuff, getting to grips with open gl.

what is the most efficient way to get something to appear to "glow"?

one thought was to have a color gradient outline to mimic a glow.

but it occurred to me there might be a built in open gl renderer that could help with this...

i'm constructing my 3d forms in this format:

Quote:


       gl.glBegin( GL.GL_QUAD_STRIP );

           color temp = color(myColour[i], 255,255);

           gl.glColor3f( red(temp),green(temp),blue(temp));
           gl.glVertex3f( x, y, z );
           gl.glVertex3f( x1, y1, z1 );
 
       gl.glEnd();




thanks for pointers...
Re: opengl "glow"?
Reply #1 - Apr 14th, 2008, 4:10pm
 
here is a link to a discourse topic which goes into drawing a gradient onto an ellipse in openGL.

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1186336072

another way would be to create a glow in photoshop and using it as a texture.
not a hundred percent on the code here, going from memory..

// do this in setup.
PImage glowTexture = loadImage( "glowTexture.png" );

// do this in draw.
pgl.beginGL();

gl.glEnable( GL.GL_TEXTURE_2D );
pgl.bindTexture( glowTexture );

gl.glBegin(GL.GL_POLYGON);
gl.glTexCoord2f(0, 0);
gl.glVertex2f(-0.5f, -0.5f);
gl.glTexCoord2f(1, 0);    
gl.glVertex2f( 0.5f, -0.5f);
gl.glTexCoord2f(1, 1);    
gl.glVertex2f( 0.5f,  0.5f);
gl.glTexCoord2f(0, 1);    
gl.glVertex2f(-0.5f, 0.5f);
gl.glEnd();

pgl.endGL();

hope that makes sense.
Re: opengl "glow"?
Reply #2 - Apr 14th, 2008, 4:41pm
 
thanks for the link.

in terms of making a gradient i know roughly how to do that.

but i guess i'm wondering more about open gl modes, is there one that might be suitable to make everything look "glowy"...
Re: opengl "glow"?
Reply #3 - Apr 14th, 2008, 5:43pm
 
There is no "glow" mode. There's no way to draw outside a polygon directly, you can only post-process the image to get the glow effect.
Re: opengl "glow"?
Reply #4 - Apr 14th, 2008, 5:46pm
 
As has been said, I create a gradient in Photoshop (say a sphere with a gradient edge) and apply it as a texture to a vertex shape. This in conjunction with additive blending in Processing looks quite smart I think.
Re: opengl "glow"?
Reply #5 - Apr 16th, 2008, 9:10am
 
i'll give it a go, thanks for the pointer.
Re: opengl "glow"?
Reply #6 - Apr 17th, 2008, 4:56pm
 
So I'm new to processing so YMMV, but how this technique is done in most realtime graphics is to take the current screen buffer, render to a texture at a smaller size (downsample) perform a guassian blur on the texture and add that backinto the scene as a full sized polygonal overlay, using an additive blend mode. At this point most of this is usually handled in a pixel shader, but you can do it without shaders.
Re: opengl "glow"?
Reply #7 - Feb 22nd, 2010, 7:43am
 
Page Index Toggle Pages: 1