Ano-Tech Computers
Enter keyword:

OpenGL: How to render a glowing point/particle
Problem:
Rendering a point or particle that appears to glow in the dark is not as straight-forward as it sounds.
 
Solution:
Draw several points on top of each other, adjusting the PointSize and alpha component for each one.

my ($r,$g,$b) = @color;
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
for my $n (1 .. 10) {
glPointSize(20/$n);
glColor($r,$g,$b,$n/10);
$size = $size / 2;
glBegin(GL_POINTS);
glVertex(4,4,4);
glEnd;
}

Remember that in a scene containing solid objects, the glowing points should be rendered AFTER the solid objects are done. Otherwise the background color will "shine through" solid objects that the points overlap.
 
Discuss this solution
Did this article solve your problem? Yes No Did not apply

We welcome anyone who is willing to contribute to this public knowledge base, contact siteadmin@atc.no if you have information you would like to share. The idea is not to replace the commercial support sites, but to publish those hard-to-find solutions you've found yourself looking for over and over again.

Show all articles