Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing a Radiance HDR image for use in a PanoramaSkyMaterial freezes the editor #61948

Closed
Calinou opened this issue Jun 11, 2022 · 15 comments · Fixed by #73715
Closed

Importing a Radiance HDR image for use in a PanoramaSkyMaterial freezes the editor #61948

Calinou opened this issue Jun 11, 2022 · 15 comments · Fixed by #73715

Comments

@Calinou
Copy link
Member

Calinou commented Jun 11, 2022

Godot version

4.0.alpha (1847094)

System information

Fedora 36, GeForce GTX 1080 (NVIDIA 510.68.02)

Issue description

Importing a Radiance HDR image for use in a PanoramaSkyMaterial freezes the editor. Note that the initial texture import doesn't freeze the editor. It only freezes when you load the texture in the PanoramaSkyMaterial's Panorama property, which detects the texture as being used in 3D and causes a reimport with different options.

This doesn't occur in 3.4.4.

As a workaround, disable automatic VRAM texture compression when 3D use is detected by setting the Detect 3D > Compress To option to Disabled:

image

Steps to reproduce

  • Create a WorldEnvironment node with a new Environment resource.
  • Edit the Environment resource to add a PanoramaSkyMaterial to its background sky property.
  • Load an .hdr image within the PanoramaSkyMaterial's Panorama property.
  • The image will be detected as being used in 3D (check console output) and editor will freeze.

Minimal reproduction project

test_hdri_use_in_3d_freeze.zip

@fire
Copy link
Member

fire commented Jun 12, 2022

Is this using the bptc code path or something else?

@Calinou
Copy link
Member Author

Calinou commented Jun 12, 2022

Is this using the bptc code path or something else?

It's using S3TC HDR texture compression if I'm not mistaken. BPTC is not used unless explicitly opted in, as it's not supported on macOS. (Even if you're on Windows or Linux, this is problematic when exporting a project to macOS.)

@fire
Copy link
Member

fire commented Jun 12, 2022 via email

@permelin
Copy link
Contributor

Even a simple 1k texture will freeze my desktop for several minutes with 100% CPU on a single core, but it does eventually finish.

Is this using the bptc code path or something else?
...
That doesn’t exist. It’s either rgbe or bc6.

I have no idea what any of those things are, but whenever I interrupt the process, it's in cvtt::Kernels::EncodeBC6HU(). Also note p_vram_compression=COMPRESS_BPTC.

* thread #1, name = 'godot', stop reason = signal SIGSTOP
  * frame #0: 0x0000560f5347ae85 godot.linuxbsd.tools.64`cvtt::ParallelMath::ToUInt16(v=0x00007ffc90f29390) at ConvectionKernels_ParallelMath.h:1138:69
    frame #1: 0x0000560f53483d0e godot.linuxbsd.tools.64`cvtt::Internal::IndexSelectorHDR<3>::ReconstructHDRUnsignedUninverted(this=0x00007ffc90f29e70, index=0x00007ffc90f29580, pixel=0x00007ffc90f29540) const at ConvectionKernels_IndexSelectorHDR.h:64:121
    frame #2: 0x0000560f5347f1a2 godot.linuxbsd.tools.64`cvtt::Internal::IndexSelectorHDR<3>::InitHDR(this=0x00007ffc90f29e70, range=8, isSigned=false, fastIndexing=false, channelWeights=0x00007ffc90f307c0) at ConvectionKernels_IndexSelectorHDR.h:102:61
    frame #3: 0x0000560f53475aba godot.linuxbsd.tools.64`cvtt::Internal::BC6HComputer::QuantizeEndpointsUnsigned(endPoints=0x00007ffc90f29890, floatPixelsColorSpace=0x00007ffc90f2fa80, floatPixelsLinearWeighted=0x00007ffc90f2f480, quantizedEndPoints=0x00007ffc90f2ab70, indexes=0x00007ffc90f2b5d0, indexSelector=0x00007ffc90f29e70, fixupIndex=15, precision=7, indexRange=8, channelWeights=0x00007ffc90f307c0, fastIndexing=false, rtn=0x00007ffc90f30380) [3], cvtt::ParallelMath::Float const (*) [3], cvtt::ParallelMath::Float const (*) [3], cvtt::ParallelMath::VInt16<3> (*) [3], cvtt::ParallelMath::VInt16<2>*, cvtt::Internal::IndexSelectorHDR<3>&, int, int, int, float const*, bool, cvtt::ParallelMath::RoundTowardNearestForScope const*) at ConvectionKernels_BC67.cpp:2570:26
    frame #4: 0x0000560f53477252 godot.linuxbsd.tools.64`cvtt::Internal::BC6HComputer::Pack(flags=296, inputs=0x00007ffc90f30880, packedBlocks="\"\U0000000eJ\x88!\n", channelWeights=0x00007ffc90f307c0, isSigned=false, numTweakRounds=4, numRefineRounds=3) at ConvectionKernels_BC67.cpp:2851:58
    frame #5: 0x0000560f53456cd0 godot.linuxbsd.tools.64`cvtt::Kernels::EncodeBC6HU(pBC="\"\U0000000eJ\x88!\n", pBlocks=0x00007ffc90f30880, options=0x00007ffc90f31260) at ConvectionKernels_API.cpp:66:45
    frame #6: 0x0000560f53455a93 godot.linuxbsd.tools.64`::_digest_row_task(p_job_params=0x00007ffc90f30f30, p_row_task=0x00007ffc90f30f00) at image_compress_cvtt.cpp:116:31
    frame #7: 0x0000560f5345601b godot.linuxbsd.tools.64`image_compress_cvtt(p_image=0x0000560f7a628ce0, p_lossy_quality=0.699999988, p_channels=USED_CHANNELS_RGB) at image_compress_cvtt.cpp:223:20
    frame #8: 0x0000560f571a5019 godot.linuxbsd.tools.64`Image::compress_from_channels(this=0x0000560f7a628ce0, p_mode=COMPRESS_BPTC, p_channels=USED_CHANNELS_RGB, p_lossy_quality=0.699999988) at image.cpp:2546:29
    frame #9: 0x0000560f54ba6b44 godot.linuxbsd.tools.64`ResourceImporterTexture::save_to_ctex_format(f=Ref<FileAccess> @ 0x00007ffc90f315c8, p_image=0x00007ffc90f315b0, p_compress_mode=COMPRESS_VRAM_COMPRESSED, p_channels=USED_CHANNELS_RGB, p_compress_format=COMPRESS_BPTC, p_lossy_quality=0.699999988) at resource_importer_texture.cpp:285:33
    frame #10: 0x0000560f54ba7752 godot.linuxbsd.tools.64`ResourceImporterTexture::_save_ctex(this=0x0000560f61c95410, p_image=0x00007ffc90f316d8, p_to_path=0x00007ffc90f31838, p_compress_mode=COMPRESS_VRAM_COMPRESSED, p_lossy_quality=0.699999988, p_vram_compression=COMPRESS_BPTC, p_mipmaps=true, p_streamable=false, p_detect_3d=false, p_detect_roughness=true, p_detect_normal=true, p_force_normal=false, p_srgb_friendly=true, p_force_po2_for_compressed=false, p_limit_mipmap=4294967295, p_normal=0x00007ffc90f316e0, p_roughness_channel=ROUGHNESS_CHANNEL_R) at resource_importer_texture.cpp:408:21
    frame #11: 0x0000560f54ba8986 godot.linuxbsd.tools.64`ResourceImporterTexture::import(this=0x0000560f61c95410, p_source_file=0x0000560f777d3ea0, p_save_path=0x00007ffc90f31cb0, p_options=0x00007ffc90f31cd0, r_platform_variants=0x00007ffc90f31ca8, r_gen_files=0x00007ffc90f31ca0, r_metadata=0x00007ffc90f31c80) at resource_importer_texture.cpp:582:14
    frame #12: 0x0000560f54608b49 godot.linuxbsd.tools.64`EditorFileSystem::_reimport_file(this=0x0000560f61cb75c0, p_file=0x0000560f777d3ea0, p_custom_options=0x0000000000000000, p_custom_importer=0x00007ffc90f324e0) at editor_file_system.cpp:1916:30
    frame #13: 0x0000560f5460c0e5 godot.linuxbsd.tools.64`EditorFileSystem::reimport_files(this=0x0000560f61cb75c0, p_files=0x00007ffc90f326a0) at editor_file_system.cpp:2130:20
    frame #14: 0x0000560f545fd6e8 godot.linuxbsd.tools.64`EditorFileSystem::_update_scan_actions(this=0x0000560f61cb75c0) at editor_file_system.cpp:661:17
    frame #15: 0x0000560f54601c28 godot.linuxbsd.tools.64`EditorFileSystem::_notification(this=0x0000560f61cb75c0, p_what=17) at editor_file_system.cpp:1248:26
    frame #16: 0x0000560f54610a84 godot.linuxbsd.tools.64`EditorFileSystem::_notificationv(this=0x0000560f61cb75c0, p_notification=17, p_reversed=false) at editor_file_system.h:143:2
    frame #17: 0x0000560f575f70ff godot.linuxbsd.tools.64`Object::notification(this=0x0000560f61cb75c0, p_notification=17, p_reversed=false) at object.cpp:735:16
    frame #18: 0x0000560f55757c9f godot.linuxbsd.tools.64`SceneTree::_notify_group_pause(this=0x0000560f60d1b750, p_group=0x0000560f5b34fe18, p_notification=17) at scene_tree.cpp:904:18
    frame #19: 0x0000560f55755e8e godot.linuxbsd.tools.64`SceneTree::process(this=0x0000560f60d1b750, p_time=0.017084000000000002) at scene_tree.cpp:454:21
    frame #20: 0x0000560f532b7701 godot.linuxbsd.tools.64`Main::iteration() at main.cpp:2885:51
    frame #21: 0x0000560f532681f3 godot.linuxbsd.tools.64`OS_LinuxBSD::run(this=0x00007ffc90f32d20) at os_linuxbsd.cpp:540:22
    frame #22: 0x0000560f53262c43 godot.linuxbsd.tools.64`main(argc=4, argv=0x00007ffc90f33268) at godot_linuxbsd.cpp:72:9
    frame #23: 0x00007f469b82920a libc.so.6`___lldb_unnamed_symbol3133 + 122
    frame #24: 0x00007f469b8292bc libc.so.6`__libc_start_main + 124
    frame #25: 0x0000560f53262a21 godot.linuxbsd.tools.64`_start + 33

The HDR files I'm testing with have this header:

#?RADIANCE
# Made with Adobe Photoshop
GAMMA=1
PRIMARIES=0 0 0 0 0 0 0 0
FORMAT=32-bit_rle_rgbe

-Y 512 +X 1024

The console shows these warnings:

WARNING: Ignoring unsupported header information in HDR: GAMMA=1.
     at: load_image (modules/hdr/image_loader_hdr.cpp:50)
WARNING: Ignoring unsupported header information in HDR: PRIMARIES=0 0 0 0 0 0 0 0.
     at: load_image (modules/hdr/image_loader_hdr.cpp:50)

@Calinou
Copy link
Member Author

Calinou commented Aug 17, 2022

The console shows these warnings:

These warnings are expected, but I wonder if they should be moved to print_verbose() instead. Most HDR images you'll find online have this header information, so it gets pretty spammy.

@cybereality
Copy link
Contributor

cybereality commented Sep 16, 2022

This is still an issue on the beta (v4.0.beta1.official [20d6672]). It appears to happen with every HDR and EXR image I have tried. Here is an example if you want to test or debug.

https://polyhaven.com/a/peppermint_powerplant_2

@viksl
Copy link
Contributor

viksl commented Sep 17, 2022

I've also encounter this but it only happens when trying to use newly added hdr. if I close godot and start again I can use the hdr in the panorama ok. Since it gets stuck on reimporting asset for the first use before restart I wonder what changes when starting godot anew?

@Anutrix
Copy link
Contributor

Anutrix commented Oct 7, 2022

Same issue is seen when trying to open https://github.com/Calinou/godot-rendering-tests.git project.
It happens on hdrihaven_lilienstein_2k.hdr.
So I tried deleting hdrihaven_lilienstein_2k.hdr.import file and crash was not seen.

OS: Windows 10 Pro 22H2
Godot Build: v4.0.beta.custom_build. 1817782

@fire
Copy link
Member

fire commented Oct 7, 2022

Lines of testing:

  1. is this using the bptc pipeline
  2. is this using rgbe pipeline
  3. Is this related to decoding hdr or encoding bc6 / rgbe

@clayjohn
Copy link
Member

It sounds like this issue is a result of using the BPTC format for HDR textures. So the editor isn't really freezing, it just takes a long time to load because the BPTC compression is so slow. We have two broad options here:

  1. Reduce the default quality of BPTC to increase speed.
  2. Replace our BPTC compressor with a faster one.

@marcinn
Copy link
Contributor

marcinn commented Feb 9, 2023

In my case, AFAIR a lightmap generated by LightmapGI, takes long time to import. It uses only 1 core of my cpu at 100% (4.0 rc1):

exrinfo returns:

File 'test_trench_broom.exr':
  compression: 'piz'
  displayWindow: [ 0, 0 - 4095 4095 ] 4096 x 4096
  dataWindow: [ 0, 0 - 4095 4095 ] 4096 x 4096
  channels: 3 channels
   'B': half samp 1 1
   'G': half samp 1 1
   'R': half samp 1 1

exrheader:

file test_trench_broom.exr:

file format version: 2, flags 0x0
channels (type chlist):
    B, 16-bit floating-point, sampling 1 1
    G, 16-bit floating-point, sampling 1 1
    R, 16-bit floating-point, sampling 1 1
compression (type compression): piz
dataWindow (type box2i): (0 0) - (4095 4095)
displayWindow (type box2i): (0 0) - (4095 4095)
lineOrder (type lineOrder): increasing y
pixelAspectRatio (type float): 1
screenWindowCenter (type v2f): (0 0)
screenWindowWidth (type float): 1
type (type string): "scanlineimage"

@Calinou
Copy link
Member Author

Calinou commented Feb 9, 2023

In my case, AFAIR a lightmap generated by LightmapGI, takes long time to import. It uses only 1 core of my cpu at 100%.

This is a separate issue which is a more recent regression: #46442

@clayjohn
Copy link
Member

clayjohn commented Feb 9, 2023

Well, its related, .exr import was slow, now it is exceedingly slow

@Calinou
Copy link
Member Author

Calinou commented Feb 9, 2023

Well, its related, .exr import was slow, now it is exceedingly slow

This issue is for Radiance HDR import, not OpenEXR import. Also, last time I checked in earlier betas, the import never finished even after waiting for 10+ minutes with a 2048×1024 texture.

@marcinn
Copy link
Contributor

marcinn commented Feb 9, 2023

Note that the initial texture import doesn't freeze the editor. It only freezes when you load the texture in the PanoramaSkyMaterial's Panorama property

I've copied the mentioned exr file to a new project (without .import). First import was quick, but editor "freezed" when I tried to drop it to the LightmapGI's Data texture. This behavior was similar, so I thought that it may be related.

This issue is for Radiance HDR import, not OpenEXR import.

I downloaded two random exr panoramas from Poly Haven, they were imported quickly, and I was able to assign them to PanoramaSky texture. So I'm a bit confused. Sorry for making a buzz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants