Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Afterglow simulation

  1. #1
    Junior Member Newbie
    Join Date
    May 2003
    Posts
    1

    Afterglow simulation

    I am trying to implement an afterglow effect for a radar simulator application using OpenGL. The screen is continuously updated with the contents of new radial scans and "older" scans need to leave a fading trail as time passes and eventually disappear, i.e the
    luminocity of the screen contents needs to be continuously reduced by a constant value.
    The application needs to run at 16-bit color
    depth because of graphics card performance issues.

    I've used a texture object to accumulate radial scans so that I only need to render one radial at a time, and then try to "fade" the entire texture to achieve the afterglow effect. My rendering loop involves
    the following steps:

    1) render texture to screen,
    2) render new radial to screen,
    3) blend a quad over screen to reduce its brightness,
    4) copy contents of screen to texture using glCopyTexImage()

    What should the blending function be for this sequence to behave correctly?
    I've tried using

    glBlendFunc(GL_ONE, GL_ONE);
    glBlendEquationEXT(GL_FUNC_SUBTRACT);
    glColor3f(reduction, reduction, reduction);

    but I don't get the expected results (the blend_subtract extension is present on my system).

    What other alternative solutions are there to achieve this effect? Would for instance multitexturing with a separate alpha texture possibly do the trick?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: Afterglow simulation

    Use render to a text and not lower color but using the alpha channel to create a simi-transparent overlay.

    pass 1 radar's current position
    pass 2 texture applied simi-transparent of prevous radar position.
    copy radar screen to a texture for next redraw of screen.

    This will create a fading out of the radar line as it rotates.


    Originally posted by emilts:
    I am trying to implement an afterglow effect for a radar simulator application using OpenGL. The screen is continuously updated with the contents of new radial scans and "older" scans need to leave a fading trail as time passes and eventually disappear, i.e the
    luminocity of the screen contents needs to be continuously reduced by a constant value.
    The application needs to run at 16-bit color
    depth because of graphics card performance issues.

    I've used a texture object to accumulate radial scans so that I only need to render one radial at a time, and then try to "fade" the entire texture to achieve the afterglow effect. My rendering loop involves
    the following steps:

    1) render texture to screen,
    2) render new radial to screen,
    3) blend a quad over screen to reduce its brightness,
    4) copy contents of screen to texture using glCopyTexImage()

    What should the blending function be for this sequence to behave correctly?
    I've tried using

    glBlendFunc(GL_ONE, GL_ONE);
    glBlendEquationEXT(GL_FUNC_SUBTRACT);
    glColor3f(reduction, reduction, reduction);

    but I don't get the expected results (the blend_subtract extension is present on my system).

    What other alternative solutions are there to achieve this effect? Would for instance multitexturing with a separate alpha texture possibly do the trick?

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    680

    Re: Afterglow simulation

    If I had to implement this, I would try to get along without any multipass/render-to-texture/blending stuff, but simply put the radar point position values (I guess there are such!?) in a FIFO list, and then for each frame render the list as points (or quads or point sprites or whatever) and fade color from node to node when traversing the list. Also should be rather faster than slower.

    Jan

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: Afterglow simulation

    Now that I think of it you can just use a texture and rotate the texture.
    The texture will be drawn with an alpha channel that has a varing degree of transparency as the image trials off.

    Does this make sense???

    Originally posted by JanHH:
    If I had to implement this, I would try to get along without any multipass/render-to-texture/blending stuff, but simply put the radar point position values (I guess there are such!?) in a FIFO list, and then for each frame render the list as points (or quads or point sprites or whatever) and fade color from node to node when traversing the list. Also should be rather faster than slower.

    Jan

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2003
    Posts
    10

    Re: Afterglow simulation

    I think if you change the alpha on the whole texture,
    you won't really get that 'radar' effect.

    I did it one time under libvga(-gl)
    I simply took my current angle, and drew
    their relative x,y positions with different colors depending on how many degrees 'ago'
    they were.

    This worked pretty swell, even under normal vga. So I suppose it will work pretty fast.

    Addendum : Another advantage is that you can add an extra 3D effect later,
    like drawing the 'latest' lines a little higher and
    rotate the radar a little
    (I love 3D and it's expandability ;-)

    Originally posted by nexusone:
    Now that I think of it you can just use a texture and rotate the texture.
    The texture will be drawn with an alpha channel that has a varing degree of transparency as the image trials off.

    Does this make sense???

    -- PIPE GREP MORE --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •