Posted by
Sven Gothel on
URL: https://forum.jogamp.org/Using-float-values-for-textures-tp4025119p4025122.html
On 06/01/2012 04:44 PM, Scyla [via jogamp] wrote:
> Hi there,
>
> In my jogl application I want to use pixel data I get from OpenExr Images (16
> or 32 bit float values). I already wrote an application that stores the values
> in a java.nio.FloatBuffer in the order red, green, blue, alpha, red... and so
> on and so forth.
>
> From there on I would like to create a texture as show in this example:
>
http://http.developer.nvidia.com/GPUGems/gpugems_ch26.html>
> But It wont work properly with this jogl call:
>
> gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_FLOAT_RGBA32_NV, textureHDR.getWidth(), textureHDR.getHeight(), 0, GL2.GL_RGBA, GL2.GL_HALF_FLOAT, textureHDR.getPixels());
>
>
> I'm sorry if this is a stupid question but it seems that people rarely use
> FloatBuffer for the pixel data so I found no example how to do it correctly.
>
> Unfortunately I can't include a working example because the loading of the
> pixel data is done via a dll that I wrote to access the ILM OpenExr library
> from a java program but I will add the java files to this post.
ARB_half_float_pixel -
http://www.opengl.org/registry/specs/ARB/half_float_pixel.txt+++
The floating-point format is very similar
to the IEEE single-precision floating-point standard, except that it
has only 5 exponent bits and 10 mantissa bits.
+++
GL_HALF_FLOAT_ARB 0x140B
http://http.developer.nvidia.com/GPUGems/gpugems_ch26.html+++
The 16-bit, or "half-precision," floating-point format is modeled after the IEEE 754 single-precision and double-precision formats. A half-precision number consists of a sign bit, a 5-bit exponent, and a 10-bit mantissa. The smallest and largest possible exponent values are reserved for representing zero, denormalized numbers, infinities, and NaNs.
+++
GL_FLOAT_RGBA16_NV 0x888A
GL_FLOAT_RGBA32_NV 0x888B
I guess the OpenExr uses 16 bit half float values
as described in your links.
Both (I assume) encode a signed half float pixel value
in 16 bit ('unsigned short' in 'C', 'short' in Java):
1+5+10 (see above).
Hence you cannot use a float buffer, since short values are expected.
Use a Short NIO buffer and make sure you receive short values.
Maybe using the ARB variant of the extension helps using your code
on platform other than NV.
~Sven
>
> Greetings
>
> OpenExrTextureTest.java <
http://forum.jogamp.org/file/n4025119/testClass.java>
> JoglApp.java <
http://forum.jogamp.org/file/n4025119/JoglApp.java>
> OpenExrReaderMain.java
> <
http://forum.jogamp.org/file/n4025119/OpenExrReaderMain.java>
>