Forums.ATC.no

Teknisk => Generelt teknisk => Emne startet av: ATC på 27. ſeptember 2008, 18:24 pm

Tittel: OpenGL: How to render a glowing point/particle
Skrevet av: ATC27. ſeptember 2008, 18:24 pm
Rendering a point or particle that appears to glow in the dark is not as straight-forward as it sounds.
Tittel: [Solved] OpenGL: How to render a glowing point/particle
Skrevet av: ATC27. ſeptember 2008, 18:24 pm
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.