godotengine/godot

Import of 32 bits RGB EXR file broken

Opened this issue · 5 comments

Godot version

3.5.1

System information

Windows 10

Issue description

I'm using 32bits RGB EXR files for heightmaps. This is how this file is displayed in photoshop :
image

and in godot 3.5.1 :
image

Steps to reproduce

Simply import the EXR file in the project and open the preview.

Minimal reproduction project

test.zip

Related to #23723. For reference, Godot uses the TinyEXR library.

Still reproducible as of 4.0.rc1:

In Godot

image

In external editor

image

Interestingly, opening the EXR image in GIMP then saving it makes it display correctly. I added some red lines here in editing, but it works if you don't make any changes too:

image

GIMP was configured to edit image data as RGB color 32-bit linear floating-point, GIMP built-in Linear sRGB (as is the case by default when opening the EXR image).

$ identify *.exr
# Original file from the MRP
wgen0_x0_y0.exr EXR 256x256 256x256+0+0 16-bit RGB 787270B 0.000u 0:00.000

# Modified version with GIMP
wgen0_x0_y0_mod.exr EXR 256x256 256x256+0+0 16-bit RGB 341281B 0.000u 0:00.000

I'm not sure, but perhaps this problem is related to my. Any way, this is another reason to mention that the import of OpenEXR is broken. (simply because everything worked fine in 4.0-12a)

In 5 and 6 release candidates, import of my height maps works correctly. However, I use 4 channels and this is a large image (who knows it can be important). However, 16-bit is imported as 32Float =)
Снимок экрана от 2023-03-01 10-46-40

UPDATE: ok, now my EXR file works again, and Godot can read it properly... I generated the file using Blender 4.2 instead of 3.3 and it worked (I swear it was working with 3.3 a year ago...). So my issue is resolved. And exrheader is happy as well. I feel tired…


In my case, Godot won't even load the EXR file (32-bit float, with values > 1):
heightmap_32.exr.zip

Not sure if it's because my values are > 1. Or because I only write to the red channel. Or sth. entirely else? Can't really find any specs in TinyEXR...

gimp doesn't mind the file; preview:
gimp-preview

in Godot 4.2.2 (and 4.3) I get

  core/io/image_loader.cpp:101 - Error loading image: res://heightmap_32.exr
  Error importing 'res://heightmap_32.exr'.
  editor/editor_node.cpp:1227 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN

The error message is not helpful.

in Godot 3.5.2 I also get file open errors. Here, I can change the import settings and re-import, but nothing seems to make a difference.

Environment

  • Ubuntu 20.04.6 LTS (Focal Fossa) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970 (nvidia; 535.183.01) - Intel(R) Core(TM) i7-10700KF CPU @ 3.80GHz (16 Threads)

EDIT: re-exporting in GIMP makes it readable for Godot (but clamps at 1.0):

image

# before touching it in GIMP
$ identify '/home/user/Desktop/heightmap_32.exr' 
PNG 513x513 513x513+0+0 16-bit sRGB 1582150B 0.000u 0:00.000

# after re-exporting
$ identify '/home/user/Desktop/heightmap_32_mod.exr' 
EXR 513x513 513x513+0+0 16-bit RGB 96524B 0.000u 0:00.000

image

EXR file was created using blender: https://docs.blender.org/api/current/bpy.types.BlendDataImages.html

# float_buffer: Float Buffer, Create an image with floating-point color
# is_data: Is Data, Create image with non-color data color space
heightmap_img = bpy.data.images.new("heightmap", 513, 513, float_buffer=True, is_data=True)
heightmap_img.file_format = 'OPEN_EXR'

What I find worrisome is: Both gimp and identify recognize the file as 16-bit sRGB, which it should not be because of is_data and because Image.use_half_precision is by default false :/ Maybe that's their fallback? exrheader returns for the file Cannot read image file "heightmap_32.exr". File is not an image file....

Just in case someone is looking into my case: It's "resolved" (at least not Godot's fault), see beginning of my previous/main comment...