Load OpenEXR as PF_FLOAT16_RGBA

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75
Contact:

Load OpenEXR as PF_FLOAT16_RGBA

Post by TaaTT4 »

I'd like to load an OpenEXR image as PF_FLOAT16_RGBA (since it gets loaded as PF_FLOAT32_RGBA by default). I've tried to following this old thread without success.

Doing so

Code: Select all

texture_unit 0
{
	texture Curve.exr 2d 0 PF_FLOAT16_RGBA

	tex_address_mode clamp
}
I can see with RenderDoc that texture takes R16G16B16A16_FLOAT format, but it's content is garbage.

Here you can find the OpenEXR image I'm using. I'm pretty sure its format is correctly floating point with 16 bits of precision.

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Load OpenEXR as PF_FLOAT16_RGBA

Post by dark_sylinc »

I have little experience in this area.

It sounds like either a problem with the EXR codec (if using our EXR codec), which at a quick glance only supports Float32 formats, or a problem with FreeImage codec (if using FreeImage's)

Looking at FreeImage's source code, they convert half to floats. And there is no half/float16 datatype in FreeImage headers either, so it's quite clear they do not support it.

You may have better luck with our built in EXR codec, and modify it slightly to load the raw half format. A quick google reveals that our code in EXRCodec::decode instead of doing this:

Code: Select all

frameBuffer.insert("R",             // name
                    Slice (FLOAT
it should do this:

Code: Select all

frameBuffer.insert("R",             // name
                    Slice (IMF::HALF
And modify the base & stride accordingly (and modify the pixel format we return!!!).

Cheers
Matias
Post Reply