pyalot / webgl-heatmap

A high performance WebGL/JS heatmap display library
906 stars 149 forks source link

Method to get value at a point X, Y #10

Open rubenjusto opened 9 years ago

rubenjusto commented 9 years ago

First of all thank you for the work you have done with WebGL-HeatMap library. I am using your library for a personal project. I encounter a major barrier because the library does not have any method to obtain the intensity of a given point.

Is there any way to get it?

rvosa commented 9 years ago

I second this request: how would I get the pixel data at x,y?

pyalot commented 9 years ago

The points are splats onto the floating point framebuffer. The intensity only exists at a specific x/y position of a pixel in that framebuffer, is that what you want?

rvosa commented 9 years ago

Yes, that is exactly what I want: I'd like to be able to sample specific x,y coordinates and use them to decide whether to move towards that location. This is for a hill-climbing demo. Could you give me a brief pointer which buffer to query?

Op Tue, 3 Nov 2015 om 11:31 schreef Florian Bösch notifications@github.com

The points are splats onto the floating point framebuffer. The intensity only exists at a specific x/y position of a pixel in that framebuffer, is that what you want?

— Reply to this email directly or view it on GitHub https://github.com/pyalot/webgl-heatmap/issues/10#issuecomment-153310086 .

pyalot commented 9 years ago

It's possible (sometimes) to read back floating point textures. However not always. To cover those cases as well, a readback needs to perform an on-GPU conversion and read back a byte texture. This is somewhat complicated by the fact that both 32-bit and 16-bit floating point textures are supported. Furthermore there's two buffers (the front and back one) and you'd have to read the front one, they're encapsulated in node classes, and each has a texture, you can see the texture you'll want to read here: https://github.com/pyalot/webgl-heatmap/blob/master/webgl-heatmap.coffee#L627

rvosa commented 9 years ago

So in JavaScript that would be heatmap.heights.nodeFront.texture, correct?

On Tue, Nov 3, 2015 at 4:54 PM, Florian Bösch notifications@github.com wrote:

It's possible (sometimes) to read back floating point textures. However not always. To cover those cases as well, a readback needs to perform an on-GPU conversion and read back a byte texture. This is somewhat complicated by the fact that both 32-bit and 16-bit floating point textures are supported. Furthermore there's two buffers (the front and back one) and you'd have to read the front one, they're encapsulated in node classes, and each has a texture, you can see the texture you'll want to read here: https://github.com/pyalot/webgl-heatmap/blob/master/webgl-heatmap.coffee#L627

— Reply to this email directly or view it on GitHub https://github.com/pyalot/webgl-heatmap/issues/10#issuecomment-153396478 .

pyalot commented 9 years ago

I think so, yeah.