Alternative to vertex texture fetch (OpenGL ES)
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:
- 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)
- 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!
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.
Just a quick thing. There is no gl_VertexID in GLES, so OP may have to work a little harder there.
Originally Posted by Ilian Dinev
Yeah, fortunately around R2VB that feature didn't exist yet, so he'll find tutes that can be directly ported to ES2.
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...
Damn. No way to copy pixels to VBs :S ? (vram-vram copy, that is)
Tags for this Thread