Skip to main content
GameDev.net gamedev.net
🔒 Locked

Data visualization question...

Started by jcox23 Mar 16, 2010 at 3:23 PM 4 replies 950+ views
Original Post
jcox23
jcox23
Hello, I'm using OpenGL to visualize 2D arrays of data... (scientific app) A texture mapped onto a quad is quite natural for that (the actual data is mapped into the luminance channel of a 2D texture...) This part went ok, but there is also the need to see the same data in the form of regular 2D curves... if my data is 500x500 array of floats, first option is a 500x500 texture, second is 500 lines composed of 500 points... The actual array is much bigger, and the transfer of data to the GPU is a critical point... (but also the size of the VRAM) The data is there on the form of a texture, would be a shame to send it again (and costly), but I can't figure out how to reuse these data to draw lines for example on top of my quads... It would be ever nice if I could draw the lines using a Pixel Shader...(still using the texture of data), but it's even more unclear how to proceed...if somebody has a clue, or good reference, that would be appreciated! Thanks for any answer :)
V-man
V-man
You want to do what? Draw a line with some elevation in the z direction depending on the height value?
Are the values stored in the texture?
jcox23
jcox23
Yes the data is in the texture, in the alpha channel...
I would use them to offset the y's of my lines

if (u,v) are coordinates of of the array or the texture,
i would draw points of coordinates (u_i, v+ alpha_i)
v being constant for a particular lines

is that understandable?
otherwise I could provide a little schema...
V-man
V-man
What you could do is sample the texture in a vertex shader and offset the y values of your vertices. I have written about it in the Wiki
http://www.opengl.org/wiki/Vertex_Texture_Fetch
jcox23
jcox23
Ok, so if I understand correctly,
I would still to pass need to pass a bunch of vertices to the GPU
(constructing parallel lines), but thatś ok since I would do it only once...

shaping the lines would be done in the vertex shader, by moving vertices from their all-aligned positions according to what's inside the texture alpha...

right?

EDIT: it got me thinking...the next step for this would be a gemoetry shader no?
just pass the beginning and end of the lines and let the geometry shader emit the in-between vertices...
V-man
V-man
The vertices would always be in a VBO (GPU memory) and so would the texture (GPU memory) so it will be fast.
Of course, VTF is only useful if the texture data is dynamic and you will be computing it on the GPU such as the case for simulating a water surface.

Quote:
EDIT: it got me thinking...the next step for this would be a gemoetry shader no?
just pass the beginning and end of the lines and let the geometry shader emit the in-between vertices...

Yes, but there are GPU limits to how many vertices/lines you can emit per pair of incoming line.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.