Commit Graph

128 Commits

Author SHA1 Message Date
aaronp64 f81e0fcbf4 Improve memory usage for image import and PortableCompressedTexture2D
When importing images, we store a compressed version of the image to a .ctex file with ResourceImporterTexture::save_to_ctex_format.  When importing many large images at once, this can use a large amount of memory, especially when the .ctex file uses WebP format.

This change is for ResourceImporterTexture::save_to_ctex_format to use the original Image object instead of p_image->get_image_from_mipmap(0), to avoid creating a copy of the full uncompressed image when looping through the base Image and mipmaps.  This reduces the import memory usage for large images by around 10% when using WebP, and 35-40% when Project Settings/Rendering/Textures/Lossless Compression/Force PNG is enabled, may vary depending on the image and number of import threads running.  Same change applied to PortableCompressedTexture2D::create_from_image, which has similar logic.

This helps with #92084, but does not fully resolve the issue on its own, as compressing with WebP on many threads can still use a large amount of memory - this just lowers that amount, and makes it more likely that enabling "Force PNG" will reduce memory usage enough to import the files.
2024-05-20 19:40:39 -04:00
Yuri Sizov 45eedba1fa Improve editor theme generation after the refactor 2024-01-17 15:16:53 +01:00
Yuri Sizov 95b27fe8c7 Reorganize code related to editor theming
This change introduces a new EditorThemeManager class
to abstract theme generatio and its subroutines.

Logic related to EditorTheme, EditorColorMap, and editor
icons has been extracted into their respective files with
includes cleaned up.

All related files have been moved to a separate folder to
better scope them in the project. This includes relevant
generated files as well.
2024-01-16 11:57:45 +01:00
Marius Hanl 4b8b0803eb Return false when no '.editor.ctex' file exists so that the file will be reimported after and no error is printed 2023-12-14 20:35:49 +01:00
Rakka Rage 35444b28e3 Add toaster notifications for import warning. 2023-12-05 16:25:04 -05:00
Rémi Verschelde fa259a77cd
Codestyle: Fix some comment issues 2023-11-21 15:26:53 +01:00
Yuri Sizov 237515d0ed Register and cleanup resource importer singletons in a predictable way 2023-08-07 17:49:33 +02:00
Spencer Chang 57d9e3bb0e Added path to output of missing import texture metadata 2023-08-01 01:28:36 -07:00
Pedro J. Estébanez abd0dcac88 Fix life cycle of ResourceImporterTexture better 2023-07-28 11:52:09 +02:00
Pedro J. Estébanez 79c798fa0b Fix life cycle of ResourceImporterTexture not tracked properly 2023-07-27 13:54:30 +02:00
Hendrik Brucker 7e21eb7e00 Extract and reorganize texture resource classes 2023-07-14 20:04:21 +02:00
Aaron Franke 1a70d82606
Check if the required texture format is imported in the export dialog 2023-06-20 10:58:34 -05:00
Yuri Sizov b856188904 Split editor-specific import metadata for textures 2023-05-26 18:48:23 +02:00
Juan Linietsky 28f51ba547 Refactor high quality texture import
* Only two texture import modes for low/high quality now:
  * S3TC/BPTC
  * ETC2/ASTC
* Makes sense given this is the general preferred and most compatible combination in most platforms.
* Removed lossy_quality from VRAM texture compression options. It was unused everywhere.
* Added a new "high_quality" option to texture import. When enabled, it uses BPTC/ASTC (BC7/ASTC4x4) instead of S3TC/ETC2 (DXT1-5/ETC2,ETCA).
* Changed MacOS export settings so required texture formats depend on the architecture selected.

This solves the following problems:

* Makes it simpler to import textures as high quality, without having to worry about the specific format used.
* As the editor can now run on platforms such as web, Mac OS with Apple Silicion and Android, it should no longer be assumed that S3TC/BPTC is available by default for it.
2023-01-30 15:53:23 +01:00
K. S. Ernest (iFire) Lee 39922d7167 Handle gltf binary
[ Ignore and Warn | Extract Textures (default) | Optimize Loading Embedded as Basisu ]

Enable compressed mip maps from Basis Universal for faster compressions.

Increase the quality of Basis to avoid corruption.

To keep compatibility use the first mip of the previous internal Godot format.

Because texture names may have invalid filename characters, adds String::validate_filename to sanitize filenames for import pipeline use.
2023-01-27 02:02:02 -08:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
kobewi e48c5daddf Unify usage of GLOBAL/EDITOR_GET 2022-10-18 19:01:48 +02:00
HolonProduction e87c9fc48c Show svg import options in default settings.
Fixes: #63840

Importers can export options conditional based on the resource path.
If an empty path is passed (as by the editor settings) filtering should not be done.
2022-10-08 16:01:00 +02:00
bruvzg 0103af1ddd
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. 2022-10-07 11:32:33 +03:00
Yuri Sizov 817d4db21f Allow images to be imported "for editor use" and respect editor settings 2022-09-07 23:31:31 +03:00
Yuri Sizov 672e9d6868 Make `ImageLoader` take bit field flags 2022-08-23 14:39:01 +03:00
Rémi Verschelde 8f033f1d19
Merge pull request #60299 from Calinou/editor-vram-compress-pc-improve-warning 2022-08-06 23:43:06 +02:00
Juan Linietsky 15837ec191
Revert "Disable VRAM compression by default for small textures in Detect 3D" 2022-06-20 15:30:19 +02:00
Hugo Locurcio 04d5626bc0
Disable VRAM compression by default for small textures in Detect 3D
This is done to prevent reducing texture quality when it doesn't save
much video memory, especially for pixel art.

The size threshold can be adjusted in the project settings.
To get the previous behavior where textures detected to be used in 3D
had their compression mode always set to VRAM, set this to the lowest value
(16).
2022-06-14 13:08:20 +02:00
Hugo Locurcio 8f235bdbbe
Add internationalization for Detect 3D texture import messages
These messages are only printed in the editor and can be seen
in the editor Output panel, so these should be localizable.
2022-06-13 20:16:41 +02:00
Hugo Locurcio f06ad0374e
Print messages when textures are detected as used in 3D/normal/roughness
This detection automatically changes some import options, so it's
important that users are aware of this.
2022-05-28 15:34:35 +02:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
Rémi Verschelde 1b5d943fbb
Merge pull request #60549 from timothyqiu/import-preset-i18n 2022-04-27 10:33:33 +02:00
Rémi Verschelde 6e67dc0881
Merge pull request #58164 from Calinou/import-hdr-add-clamp-exposure-option
Add an option to clamp HDR exposure to reduce environment fireflies
2022-04-27 08:01:34 +02:00
Haoyu Qiu 3b9095253c Make more import preset name translatable 2022-04-27 13:50:54 +08:00
Hugo Locurcio 2694138060
Add an option to clamp HDR exposure to reduce environment fireflies
HDRI panoramas designed for realistic lighting can have extremely
bright suns, causing fireflies to appear in the environment reflection
(in addition to making environment lighting too bright when a
DirectionalLight3D is used).

This uses the Filament tonemapping formula.
2022-04-27 01:28:43 +02:00
Hugo Locurcio f2a0a526ef
Improve warning message for invalid desktop VRAM compression settings
- Display the source file path.
- Display the valid compression algorithms on desktop platforms.
- Use "desktop platforms" instead of "PC" to avoid ambiguity.
- Use "may" instead of "will", as desktop platforms can still sometimes
  display ETC1/ETC2 textures depending on the GPU and drivers.
2022-04-16 13:10:52 +02:00
bruvzg 9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
Nicholas Huelin 01ca9d3eec Hide "Normal Map" import option when using lossless compression on Texture
This pull request resolves an issue where images being imported with lossless compression allowed you to select a normal map, but the normal map only applies if you're using VRAM compression. Thereby making it redundant to appear when using lossless compression. This pull request hides the normal map option when lossless compression is selected.

Resolves: #59435
2022-03-28 11:36:52 +02:00
Hugo Locurcio f269300a7d
Remove unused Streamed option for textures in the Import dock
Godot does not support texture streaming yet (and is only planned
for a future 4.x release), so displaying an option can be misleading.
2022-03-15 18:34:47 +01:00
Rémi Verschelde af9a60d5b3
Merge pull request #58965 from TechnoPorg/remove-stex-occurrences
Remove more occurrences of "stex"
2022-03-11 08:00:52 +01:00
TechnoPorg f4bc9f5821 Remove more occurrences of "stex" 2022-03-10 18:31:48 -07:00
Haoyu Qiu 25d93200c8 Add missing i18n to various strings 2022-03-07 21:50:49 +08:00
reduz ccd4cdfd8b Rename StreamTexture* to CompressedTexture*
* Its not and will not be used for streaming.
* Streaming will be implemented in 4.1 and it will work different.
* It makes more sense to be called CompressedTexture since it imports and compresses texture files.
2022-03-05 16:43:38 +01:00
Rémi Verschelde 3f759f03c3
Merge pull request #57997 from Calinou/texture-import-rename-hdr-as-srgb 2022-02-12 10:22:06 +01:00
Hendrik Brucker b396fd4eef Improve compilation speed (forward declarations/includes cleanup) 2022-02-12 02:46:22 +01:00
Hugo Locurcio 1737b4a946
Rename Hdr as Srgb texture import option to be lowercase
Unlike all other import options, Hdr As Srgb was internally spelled
out with uppercase characters.
2022-02-12 02:39:10 +01:00
K. S. Ernest (iFire) Lee 419b342a9a Faster CVTT by reducing quality.
Make BC6 and BC7 CVTT faster while still having better quality than DXT5.
2022-02-04 15:15:26 -08:00
Anilforextra fc27636999 Vectors: Use clear() and has().
Use clear() instead of resize(0).

Use has() instead of "find(p_val) != -1".
2022-02-02 00:11:09 +05:45
Rémi Verschelde 7176a43260
Remove property hints referencing unsupported svgz extension
The wrongly claimed support for it was removed in #49645.
See also #56862.
2022-01-17 12:40:43 +01:00
kobewi a7f743039d Hide SVG scale for non-SVG textures 2022-01-16 21:18:00 +01:00
Hugo Locurcio 40be15920f
Remove support for PVRTC texture encoding and decoding
On the only platform where PVRTC is supported (iOS),
ETC2 generally supersedes PVRTC in every possible way. The increased
memory usage is not really a problem thanks to modern iOS' devices
processing power being higher than its Android counterparts.
2022-01-14 21:08:22 +01:00
Rémi Verschelde fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
Marc Gilleron 5c3b92e94f Don't crash when texture param is null 2021-12-17 15:56:41 +00:00
reduz cd2a499084 Add path to functions that return iporter options
-Allows displaying custom options for specific file format variants
-Added support for scene format import to retrieve custom options

This PR is necessary for #54886 to be implemented properly.
2021-11-14 14:06:10 -03:00