2

I would like to generate a heat map style histogram using GLSL shaders. Specifically, I have a vector of 2D values that I want to bin into a 2D grid, where each cell is a bin for a specific range of (x,y) values, and it's color is determined by how many values are binned into it.

I can easily assign values to cells in the vertex shader, or compute shader. How can I also write to a 2D buffer the frequencies in each bin/cell and then assign color and render to texture accordingly?

MVTC
  • 845
  • 11
  • 28
  • I assume you mean something like [this](http://www.statmethods.net/graphs/density.html) but in realtime? Maybe use additive blending and write to a floating point texture with an FBO. You could draw points, so each only affects one pixel, or splat smoother particles (e.g. with a texture or generated falloff in the fragment shader). – jozxyqk Jun 16 '15 at 10:09
  • If you have enough calculations per transferred bytes for the GPU, it will run faster: http://stackoverflow.com/a/39839788/895245 But that shouldn't be the case for the simple operation of taking averages, which uses about only 1 sum + 1/N divisions per memory access. – Ciro Santilli OurBigBook.com Oct 03 '16 at 20:25

0 Answers0