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 10 of 11

Thread: Alternative to vertex texture fetch (OpenGL ES)

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    2

    Alternative to vertex texture fetch (OpenGL ES)

    Hello,

    I am trying to plot scientific data using OpenGL. Typical data vectors size is in the range of 5000-16000.

    For the first draft, I used the VTF technique described in this tutorial (https://en.wikibooks.org/wiki/OpenGL...GL_Tutorial_02). This works really well, it allows me to do analysis within the vertex shader itself like keeping extreme values when the graph is displayed (required -- for example, if you display the graph in a 200px window, you do not want to let OpenGL decide if it shall discard the data point or not -- more details below). What I really like here is that this processing is done on the GPU instead of the CPU.

    Now I am porting this test program to OpenGL ES. Unfortunately, this technique won't work at all because GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS is 0 on the embedded platform (Tegra). Currently, I see 2 alternatives:

    1. Do pre-processing with the CPU in order to keep only the significant data before uploading XY coordinates to the GPU (like tutorial 1: https://en.wikibooks.org/wiki/OpenGL...GL_Tutorial_01)
    2. Upload ALL XY coordinates (like tutorial 01 above) to the GPU -- but then, how can I make sure that the rasterizer won't skip my data point?



    Typical use case: Let's say you have data 5000 points. All of them have 0 as value, except one in the middle which have 1. When displayed in a 200px window, a vertical line in the middle of the graph shall always be visible.

    Thanks for your input!

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261
    Find about a technique, called R2VB (render to vertex buffer).
    Basically, draw a fullscreen quad to a FBO texture (RGBA32F usually). If your vertices are 10000, a 100x100 texture will suffice. Use the pixel-shader to do the sampling you needed for VTF, output as colour.
    Then, use PBO (pixel buffer object) to copy data from the RGBA32F texture onto a VBO. Bind that VBO as an attribute, do your drawcall (which originally would be doing VTF).


    Btw, instead of a fullscreen quad, sometimes you'll have to render 10000 points, with their position being dependent on gl_VertexID, and send the VTF texcoord as a varying to the fragment shader.

  3. #3
    Member Regular Contributor
    Join Date
    Apr 2009
    Posts
    258
    Quote Originally Posted by Ilian Dinev View Post
    being dependent on gl_VertexID
    Just a quick thing. There is no gl_VertexID in GLES, so OP may have to work a little harder there.

  4. #4
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261
    Yeah, fortunately around R2VB that feature didn't exist yet, so he'll find tutes that can be directly ported to ES2.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    529
    Also... there are no pixel buffer objects in core OpenGL ES2..... if one is willing to use SGX, that GPU does have vertex texture fetch...

  6. #6
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261
    Damn. No way to copy pixels to VBs :S ? (vram-vram copy, that is)

Tags for this Thread

Posting Permissions

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