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 3 of 3

Thread: Creating a fading object trail in Modern OpenGL?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2017
    Posts
    25

    Creating a fading object trail in Modern OpenGL?

    Hi, I'm looking to possibly create a trail behind a moving object that fades away over time. Right now, I'm moving bullets through a scene by setting their position equal to their moving rigid body's position. How can I create a basic trail (like a simple thick red line) that follows the object, can only be a certain length and fades away over time? I've tried looking this up can't find a good solution in modern OpenGL (rendering objects with a model * view * projection matrix).

    Are GLlines still used? Or would another approach be better?

    Thanks for any input.

  2. #2
    Member Regular Contributor
    Join Date
    May 2016
    Posts
    445
    Quote Originally Posted by eratic-magician View Post
    Hi, I'm looking to possibly create a trail behind a moving object that fades away over time. Right now, I'm moving bullets through a scene by setting their position equal to their moving rigid body's position. How can I create a basic trail (like a simple thick red line) that follows the object, can only be a certain length and fades away over time?
    use blending
    https://www.khronos.org/opengl/wiki/Blending

    use 2 framebuffers, "currentframe" and "previousframe", each frame you render your scene as you'd normally do into "currentframe". in addition to that, render a small portion of the "bullet trail" behind the bullet (how you do that is not important). next frame, previousframe becomes currentframe and currentframe will contain the scene again, but now you blend the 2 framebuffers together, using (lets say) 99% RGBA of previousframe and 1% RGBA of currentframe, the result will be displayed onto the screen

    you can change the "speed" at which the trails are fading by playing with the 99% / 1% ratio

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2017
    Posts
    25
    Great, I'll look into that, thanks.

    Is this the standard way of doing this? I thought that using GLlines would be, but maybe that's outdated.

Posting Permissions

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