I would like my shader to create a histogram at a mid-stage of the shader. ( The final gl_FragColor is not part of the histogram. ) The obvious way would be to have the histogram as a uniform array that the shader can update. However, at least on my nvidia hw, array indexing using computed values is not allowed. So…
“The obvious way would be to have the histogram as a uniform array that the shader can update.”
Shaders can not write into uniforms.
And you can also not write to arbitrary pixel locations inside a fragment shader, which means you can’t store the histogramm into a color buffer (e.g. 256 * 1 pixels FP32) in one pass.
One way to create a histogram is to use occlusion queries and do as many fullscreen passes as you have buckets, and simply discard fragments in the fragment shader that doesn’t fall into the current bucket.
Originally posted by Relic:
[b] “The obvious way would be to have the histogram as a uniform array that the shader can update.”
Shaders can not write into uniforms.
And you can also not write to arbitrary pixel locations inside a fragment shader, which means you can’t store the histogramm into a color buffer (e.g. 256 * 1 pixels FP32) in one pass. [/b]
Well there you go. Not just SOL but SOB (brains) too!