sotangochips
sotangochips

Reputation: 2788

iOS (iPhone) High Precision Texture Output

I'm trying to create a histogram of luminosity values from a large image (on the order of 2048 x 2048) to do so, I'm following this method for calculating the histogram on the GPU.

Essentially, it boils down to creating a point for every pixel and texture sampling through the vertex shader at that point, then outputting a value of 1 / (number pixels) to a 1-dimensional texture (256 x 1). If you set the blend mode to glBlendFunc(GL_ONE, GL_ONE) this will mean your 1-dimensional texture will eventually accumulate the effective histogram.

However, in my experience the output texture doesn't have enough precision to increment by 1/number of pixels when the # of pixels is something reasonable.

Is there a way of increasing the precision of the texture on the iPhone to something that will accommodate increases of this precision?

Upvotes: 1

Views: 712

Answers (1)

Taylor
Taylor

Reputation: 6410

Currently, the OpenGL ES on iOS doesn't support rendering to a texture of precision higher than one byte per color channel. See render to floating point texture under iOS. You'll want to increment each bin by 1, which means your shader would output 1/256.

To prevent saturation, it seems you could use the technique described in Section 2.2 ("Precision Considerations for Bin Content Accumulation") of the paper you referenced. That is to distribute pixels among local histograms and then do a gather at the end.

Upvotes: 2

Related Questions