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: Draw a portion of a transform feedback buffer

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    17

    Draw a portion of a transform feedback buffer

    Hello everyone.

    I am using TF buffers to render precipitations.
    I'd like to render more or less particles depending on precipitations intensity.

    What is the best way to do that ?

    Thank you.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,370
    The question you asked in your subject line is different than the one asked by your post.

    To answer the former, you can chose which elements you are processing via Transform Feedback to emit with EmitStreamVertex(). You don't have to emit them all.

    To the latter, it depends on how you're implementing it. Could be that selective emission is a good option. But it's worth asking, why are you passing down elements that might not be rendered, and is there a way to avoid doing that altogether.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    17
    I think I know where my problem is coming from.

    I implemented TF following that tutorial : http://ogldev.atspace.co.uk/www/tuto...utorial28.html

    In this example, glDrawArrays is called only once at the first update so that the number of particles that are processed depends on the previous frame.

    Code :
    if (m_isFirst) {
            glDrawArrays(GL_POINTS, 0, 1);
            m_isFirst = false;
        }
        else {
            glDrawTransformFeedback(GL_POINTS, m_transformFeedback[m_currVB]);
        }

    If I want to update and draw only a part of my total amount of particles, I just have to call glDrawArrays() in my update function with the number of particles I want, right ?

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,370
    Quote Originally Posted by Vylsain View Post
    I think I know where my problem is coming from.

    I implemented TF following that tutorial : http://ogldev.atspace.co.uk/www/tuto...utorial28.html

    In this example, ...the number of particles that are processed depends on the previous frame.
    Right. He's drawing the m_currVB TF, which is the TF result from the previous frame.

    If I want to update and draw only a part of my total amount of particles, I just have to call glDrawArrays() in my update function with the number of particles I want, right ?
    Possibly. There are a number of ways to do it. One way is to do what he's doing and have this frame's TF result be derived from last frame's TF result, selectively emitting vertices (EmitVertex) as they are processed. Another option is to always throw them all down the pipe, and compute your in/out set from scratch using selective emission. There are other ways to do this too. Just depends on what maps best for your algorithm.

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    17
    Ok !

    The way I implemented it now seems appropriate.

    Thank you Dark Photon.

Posting Permissions

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