2
\$\begingroup\$

I find that my procedural simplex noise in my fragment shader hurts performance, so I thought I would just use a stored noise texture instead.

I would like my noise values to have better than 8 bits precision, preferably 16 bits.

What would be a good format to store this texture in?

According to Khronos, GL_LUMINANCE16 is deprecated.

Should I use GL_R16I for this? What worries me is that it is listed as not texture filterable. That makes the format not useful for this purpose, I think? The man-page does not explain what the term means, but I gather it means that you are force to do NEAREST filtering.

I am looking for something that would work on both OpenGLES3 mobile hardware and on OpenGL desktop hardware.

\$\endgroup\$
3
\$\begingroup\$

The choice of formats for OpenGL ES is very limited, so you have to choose between GL_R16F and GL_R8. Both formats are available for desktop.

GL_R16F is probably enough for your purposes.. or is it? Values won't be normalized and it will require you to generate data on the CPU. The reason behind CPU-only restriction is because GL_R16F is not a color-renderable format, so you can't attach it to the framebuffer. But at least it will let you to use filtering.

Personally I think that 8 bits wouldn't be a bad choice, because it is filterable and for simplex noise you don't really need too much precision when in the end results are being interpolated in the shader. And it's an unsigned normalized integer format, meaning you won't have to deal with conversions to utilize full precision. And you can attach it to the framebuffer to use shader for noise computation.

\$\endgroup\$
  • 3
    \$\begingroup\$ You could also combine two decorrelated taps from an R8 texture, one for coarse detail and the second for fine variation, to get an effect similar to using a higher-precision source. You can also tile the two taps at different frequencies to disguise the tiling of the noise, allowing you to use a smaller swatch without obvious exact repeats. \$\endgroup\$ – DMGregory Jul 15 at 23:08
  • \$\begingroup\$ Thanks, I went with GL_R16F which works well for me. \$\endgroup\$ – Bram Jul 16 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.