Skrevet av Emne: OpenGL: How to render a glowing point/particle  (Lest 4450 ganger)

ATC

  • Gjest
OpenGL: How to render a glowing point/particle
« på: 27. ſeptember 2008, 18:24 pm »
  • [applaud]0
  • [smite]0
  • Rendering a point or particle that appears to glow in the dark is not as straight-forward as it sounds.



    ATC

    • Gjest
    [Solved] OpenGL: How to render a glowing point/particle
    « Svar #1 på: 27. ſeptember 2008, 18:24 pm »
  • [applaud]0
  • [smite]0
  • 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.