importing_images.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. .. _doc_importing_images:
  2. Importing images
  3. ================
  4. Supported image formats
  5. -----------------------
  6. Godot can import the following image formats:
  7. - BMP (``.bmp``)
  8. - No support for 16-bit per pixel images. Only 1-bit, 4-bit, 8-bit, 24-bit, and 32-bit per pixel images are supported.
  9. - DirectDraw Surface (``.dds``)
  10. - If mipmaps are present in the texture, they will be loaded directly.
  11. This can be used to achieve effects using custom mipmaps.
  12. - Khronos Texture (``.ktx``)
  13. - Decoding is done using `libktx <https://github.com/KhronosGroup/KTX-Software>`__.
  14. Only supports 2D images. Cubemaps, texture arrays and de-padding are not supported.
  15. - OpenEXR (``.exr``)
  16. - Supports HDR (highly recommended for panorama skies).
  17. - Radiance HDR (``.hdr``)
  18. - Supports HDR (highly recommended for panorama skies).
  19. - JPEG (``.jpg``, ``.jpeg``)
  20. - Doesn't support transparency per the format's limitations.
  21. - PNG (``.png``)
  22. - Precision is limited to 8 bits per channel upon importing (no HDR images).
  23. - Truevision Targa (``.tga``)
  24. - SVG (``.svg``)
  25. - SVGs are rasterized using `ThorVG <https://www.thorvg.org/>`__
  26. when importing them. `Support is limited <https://www.thorvg.org/about#:~:text=among%20the%20svg%20tiny%20specs%2C%20yet%20unsupported%20features%20in%20the%20thorvg%20are%20the%20following>`__;
  27. complex vectors may not render correctly. :ref:`Text must be converted to paths <doc_importing_images_svg_text>`;
  28. otherwise, it won't appear in the rasterized image.
  29. You can check whether ThorVG can render a certain vector correctly using its
  30. `web-based viewer <https://www.thorvg.org/viewer>`__.
  31. For complex vectors, rendering them to PNGs using `Inkscape <https://inkscape.org/>`__
  32. is often a better solution. This can be automated thanks to its
  33. `command-line interface <https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line#Export_files>`__.
  34. - WebP (``.webp``)
  35. - WebP files support transparency and can be compressed lossily or losslessly.
  36. The precision is limited to 8 bits per channel.
  37. .. note::
  38. If you've compiled the Godot editor from source with specific modules disabled,
  39. some formats may not be available.
  40. Importing textures
  41. ------------------
  42. The default action in Godot is to import images as textures. Textures are stored
  43. in video memory. Their pixel data can't be accessed directly from the CPU
  44. without converting them back to an :ref:`class_Image` in a script. This is what
  45. makes drawing them efficient.
  46. There are over a dozen import options that can be adjusted after selecting an
  47. image in the FileSystem dock:
  48. .. figure:: img/importing_images_import_dock.webp
  49. :align: center
  50. :alt: Import options in the Import dock after selecting an image in the FileSystem dock
  51. Import options in the Import dock after selecting an image in the FileSystem dock.
  52. Some of these options are only visible with certain compression modes.
  53. .. _doc_importing_images_changing_import_type:
  54. Changing import type
  55. ^^^^^^^^^^^^^^^^^^^^
  56. It is possible to choose other types of imported resources in the Import dock:
  57. - **BitMap:** 1-bit monochrome texture (intended to be used as a click mask in
  58. :ref:`class_TextureButton` and :ref:`class_TouchScreenButton`). This resource
  59. type cannot be displayed directly onto 2D or 3D nodes, but the pixel values
  60. can be queried from a script using :ref:`get_bit
  61. <class_BitMap_method_get_bit>`.
  62. - **Cubemap:** Import the texture as a 6-sided cubemap, with interpolation
  63. between the cubemap's sides (seamless cubemaps), which can be sampled in
  64. custom shaders.
  65. - **CubemapArray:** Import the texture as a collection of 6-sided cubemaps,
  66. which can be sampled in custom shaders. This resource type can only be
  67. displayed when using the Forward+ or Forward Mobile rendering methods, not
  68. Compatibility.
  69. - **Font Data (Monospace Image Font):** Import the image as a bitmap font where
  70. all characters have the same width. See :ref:`doc_gui_using_fonts`.
  71. - **Image:** Import the image as-is. This resource type cannot be displayed
  72. directly onto 2D or 3D nodes, but the pixel values can be queried from a
  73. script using :ref:`get_pixel<class_Image_method_get_pixel>`.
  74. - **Texture2D:** Import the image as a 2-dimensional texture, suited for display
  75. on 2D and 3D surfaces. This is the default import mode.
  76. - **Texture2DArray:** Import the image as a collection of 2-dimensional textures.
  77. Texture2DArray is similar to a 3-dimensional texture, but without
  78. interpolation between layers. Built-in 2D and 3D shaders cannot display
  79. texture arrays, so you must create a custom shader in :ref:`2D <doc_canvas_item_shader>`
  80. or :ref:`3D <doc_spatial_shader>` to display a texture from a texture array.
  81. - **Texture3D:** Import the image as a 3-dimensional texture. This is *not* a 2D
  82. texture applied onto a 3D surface. Texture3D is similar to a texture array, but
  83. with interpolation between layers. Texture3D is typically used for
  84. :ref:`class_FogMaterial` density maps in :ref:`volumetric fog
  85. <doc_volumetric_fog>`, :ref:`particle attractor <doc_3d_particles_attractors>`
  86. vector fields, :ref:`class_Environment` 3D LUT color correction, and custom shaders.
  87. - **TextureAtlas:** Import the image as an *atlas* of different textures. Can be
  88. used to reduce memory usage for animated 2D sprites. Only supported in 2D due
  89. to missing support in built-in 3D shaders.
  90. For **Cubemap**, the expected image order is X+, X-, Y+, Y-, Z+, Z-
  91. (in Godot's coordinate system, so Y+ is "up" and Z- is "forward").
  92. Here are templates you can use for cubemap images (right-click > **Save Link As…**):
  93. - :download:`2×3 cubemap template (default layout option) <img/cubemap_template_2x3.webp>`
  94. - :download:`3×2 cubemap template <img/cubemap_template_3x2.webp>`
  95. - :download:`1×6 cubemap template <img/cubemap_template_1x6.webp>`
  96. - :download:`6×1 cubemap template <img/cubemap_template_6x1.webp>`
  97. Detect 3D
  98. ^^^^^^^^^
  99. The default import options (no mipmaps and **Lossless** compression) are suited
  100. for 2D, but are not ideal for most 3D projects. **Detect 3D** makes Godot aware
  101. of when a texture is used in a 3D scene (such as a texture in a
  102. :ref:`class_BaseMaterial3D`). If this happens, several import options are
  103. changed so the texture flags are friendlier to 3D. Mipmaps are enabled and the
  104. compression mode is changed to **VRAM Compressed** unless
  105. :ref:`doc_importing_images_detect_3d_compress_to` is changed. The texture is
  106. also reimported automatically.
  107. A message is printed to the Output panel when a texture is detected to be used in 3D.
  108. If you run into quality issues when a texture is detected to be used in 3D (e.g.
  109. for pixel art textures), change the
  110. :ref:`doc_importing_images_detect_3d_compress_to` option before using the
  111. texture in 3D, or change :ref:`doc_importing_images_compress_mode` to
  112. **Lossless** after using the texture in 3D. This is preferable to disabling
  113. **Detect 3D**, as mipmap generation remains enabled to prevent textures from
  114. looking grainy at a distance.
  115. Import options
  116. --------------
  117. .. seealso::
  118. In Godot 4.0, changing the texture filter and repeat mode is no longer done
  119. in the import options.
  120. Instead, texture filter and repeat modes are changed in the CanvasItem
  121. properties in 2D (with a project setting acting as a default), and in a
  122. :ref:`per-material configuration in 3D <doc_standard_material_3d_sampling>`.
  123. In custom shaders, filter and repeat mode is changed on the ``sampler2D``
  124. uniform using hints described in the :ref:`doc_shading_language`
  125. documentation.
  126. .. _doc_importing_images_compress_mode:
  127. Compress > Mode
  128. ^^^^^^^^^^^^^^^
  129. Images are one of the largest assets in a game. To handle them efficiently, they
  130. need to be compressed. Godot offers several compression methods, depending on
  131. the use case.
  132. - **Lossless:** This is the default and most common compression mode for 2D assets.
  133. It shows assets without any kind of artifacting, and disk compression is
  134. decent. It will use considerably more amount of video memory than
  135. VRAM Compression, though. This is also the recommended setting for pixel art.
  136. - **Lossy:** This is a good choice for large 2D assets. It has some artifacts,
  137. but less than VRAM compression and the file size is several times lower
  138. compared to Lossless or VRAM Uncompressed. Video memory usage isn't decreased
  139. by this mode; it's the same as with Lossless or VRAM Uncompressed.
  140. - **VRAM Compressed:** This is the default and most common compression mode for
  141. 3D assets. Size on disk is reduced and video memory usage is also decreased
  142. considerably (usually by a factor between 4 and 6). This mode should be
  143. avoided for 2D as it exhibits noticeable artifacts, especially for
  144. lower-resolution textures.
  145. - **VRAM Uncompressed:** Only useful for formats that can't be compressed, such
  146. as raw floating-point images.
  147. - **Basis Universal:** This alternative VRAM compression mode encodes the
  148. texture to a format that can be transcoded to most GPU-compressed formats at
  149. load-time. This provides very small files that make use of VRAM compression,
  150. at the cost of lower quality compared to VRAM Compressed and slow compression
  151. times. VRAM usage is usually the same as VRAM Compressed. Basis Universal does
  152. not support floating-point image formats (the engine will internally fall back
  153. to VRAM Compressed instead).
  154. .. note::
  155. Even in 3D, "pixel art" textures should have VRAM compression disabled as it
  156. will negatively affect their appearance, without improving performance
  157. significantly due to their low resolution.
  158. In this table, each of the 5 options are described together with their
  159. advantages and disadvantages (|good| = best, |bad| = worst):
  160. +------------------+-------------------------------+----------------------+------------------------------------------------------+------------------------+--------------------------------------+
  161. | Compress mode | Lossless | Lossy | VRAM Compressed | VRAM Uncompressed | Basis Universal |
  162. +==================+===============================+======================+======================================================+========================+======================================+
  163. | **Description** | Stored as Lossless WebP / PNG | Stored as Lossy WebP | Stored as S3TC, BPTC or ETC2 depending on platform | Stored as raw pixels | Transcoded to VRAM Compressed format |
  164. +------------------+-------------------------------+----------------------+------------------------------------------------------+------------------------+--------------------------------------+
  165. | **Size on disk** | |regular| Small | |good| Very small | |regular| Small | |bad| Large | |good| Very small |
  166. +------------------+-------------------------------+----------------------+------------------------------------------------------+------------------------+--------------------------------------+
  167. | **Memory usage** | |bad| Large | |bad| Large | |good| Small | |bad| Large | |good| Small |
  168. +------------------+-------------------------------+----------------------+------------------------------------------------------+------------------------+--------------------------------------+
  169. | **Performance** | |regular| Normal | |regular| Normal | |good| Fast | |regular| Normal | |good| Fast |
  170. +------------------+-------------------------------+----------------------+------------------------------------------------------+------------------------+--------------------------------------+
  171. | **Quality loss** | |good| None | |regular| Slight | |bad| Moderate | |good| None | |bad| Moderate |
  172. +------------------+-------------------------------+----------------------+------------------------------------------------------+------------------------+--------------------------------------+
  173. | **Load time** | |bad| Slow | |bad| Slow | |good| Fast | |regular| Normal | |regular| Normal |
  174. +------------------+-------------------------------+----------------------+------------------------------------------------------+------------------------+--------------------------------------+
  175. .. |bad| image:: img/bad.png
  176. .. |good| image:: img/good.png
  177. .. |regular| image:: img/regular.png
  178. Estimated memory usage for a single RGBA8 texture with mipmaps enabled:
  179. +---------------+---------------------+---------------------+---------------------+---------------------+---------------------+
  180. | Texture size | Lossless | Lossy | VRAM Compressed | VRAM Uncompressed | Basis Universal |
  181. +===============+=====================+=====================+=====================+=====================+=====================+
  182. | **128×128** | |good| 85 KiB | |good| 85 KiB | |good| 21 KiB | |good| 85 KiB | |good| 21 KiB |
  183. +---------------+---------------------+---------------------+---------------------+---------------------+---------------------+
  184. | **256×256** | |good| 341 KiB | |good| 341 KiB | |good| 85 KiB | |good| 341 KiB | |good| 85 KiB |
  185. +---------------+---------------------+---------------------+---------------------+---------------------+---------------------+
  186. | **512×512** | |good| 1.33 MiB | |good| 1.33 MiB | |good| 341 KiB | |good| 1.33 MiB | |good| 341 KiB |
  187. +---------------+---------------------+---------------------+---------------------+---------------------+---------------------+
  188. | **1024×1024** | |regular| 5.33 MiB | |regular| 5.33 MiB | |good| 1.33 MiB | |regular| 5.33 MiB | |good| 1.33 MiB |
  189. +---------------+---------------------+---------------------+---------------------+---------------------+---------------------+
  190. | **2048×2048** | |bad| 21.33 MiB | |bad| 21.33 MiB | |regular| 5.33 MiB | |bad| 21.33 MiB | |regular| 5.33 MiB |
  191. +---------------+---------------------+---------------------+---------------------+---------------------+---------------------+
  192. | **4096×4096** | |bad| 85.33 MiB | |bad| 85.33 MiB | |bad| 21.33 MiB | |bad| 85.33 MiB | |bad| 21.33 MiB |
  193. +---------------+---------------------+---------------------+---------------------+---------------------+---------------------+
  194. .. note::
  195. In the above table, memory usage will be reduced by 25% for images that do
  196. not have an alpha channel (RGB8). Memory usage will be further decreased by
  197. 25% for images that have mipmaps disabled.
  198. Notice how at larger resolutions, the impact of VRAM compression is much
  199. greater. With a 4:1 compression ratio (6:1 for opaque textures with S3TC), VRAM
  200. compression effectively allows a texture to be twice as large on each axis,
  201. while using the same amount of memory on the GPU.
  202. VRAM compression also reduces the memory bandwidth required to sample the
  203. texture, which can speed up rendering in memory bandwidth-constrained scenarios
  204. (which are frequent on integrated graphics and mobile). These factors combined
  205. make VRAM compression a must-have for 3D games with high-resolution textures.
  206. You can preview how much memory a texture takes by double-clicking it in the
  207. FileSystem dock, then looking at the Inspector:
  208. .. figure:: img/importing_images_inspector_preview.webp
  209. :align: center
  210. :alt: Previewing a texture in the Inspector
  211. Previewing a texture in the Inspector. Credit: `Red Brick 03 - Poly Haven <https://polyhaven.com/a/red_brick_03>`__
  212. Compress > High Quality
  213. ^^^^^^^^^^^^^^^^^^^^^^^
  214. .. note::
  215. High-quality VRAM texture compression is only supported in the Forward+ and
  216. Forward Mobile rendering methods.
  217. When using the Compatibility rendering method, this option is always
  218. considered disabled.
  219. If enabled, uses BPTC compression on desktop platforms and :abbr:`ASTC (Adaptive
  220. Scalable Texture Compression)` compression on mobile platforms. When using BPTC,
  221. BC7 is used for SDR textures and BC6H is used for HDR textures.
  222. If disabled (default), uses the faster but lower-quality S3TC compression on
  223. desktop platforms and ETC2 on mobile/web platforms. When using S3TC, DXT1 (BC1)
  224. is used for opaque textures and DXT5 (BC3) is used for transparent or normal map
  225. (:abbr:`RGTC (Red-Green Texture Compression)`) textures.
  226. BPTC and ASTC support VRAM compression for HDR textures, but S3TC and ETC2 do
  227. not (see **HDR Compression** below).
  228. Compress > HDR Compression
  229. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  230. .. note::
  231. This option only has an effect on textures that are imported as HDR formats in Godot
  232. (``.hdr`` and ``.exr`` files).
  233. If set to **Disabled**, never uses VRAM compression for HDR textures, regardless
  234. of whether they're opaque or transparent. Instead, the texture is converted to
  235. RGBE9995 (9-bits per channel + 5-bit exponent = 32 bits per pixel) to reduce
  236. memory usage compared to a half-float or single-precision float image format.
  237. If set to **Opaque Only** (default), only uses VRAM compression for opaque HDR
  238. textures. This is due to a limitation of HDR formats, as there is no
  239. VRAM-compressed HDR format that supports transparency at the same time.
  240. If set to **Always**, will force VRAM compression even for HDR textures with an
  241. alpha channel. To perform this, the alpha channel is discarded on import.
  242. Compress > Normal Map
  243. ^^^^^^^^^^^^^^^^^^^^^
  244. When using a texture as normal map, only the red and green channels are
  245. required. Given regular texture compression algorithms produce artifacts that
  246. don't look that nice in normal maps, the :abbr:`RGTC (Red-Green Texture Compression)`
  247. compression format is the best fit for this data. Forcing this option to **Enable**
  248. will make Godot import the image as :abbr:`RGTC (Red-Green Texture Compression)` compressed.
  249. By default, it's set to **Detect**. This means that if the texture is ever detected to
  250. be used as a normal map, it will be changed to **Enable** and reimported automatically.
  251. Note that :abbr:`RGTC (Red-Green Texture Compression)` compression affects the
  252. resulting normal map image. You will have to adjust custom shaders that use the
  253. normal map's blue channel to take this into account. Built-in material shaders
  254. already ignore the blue channel in a normal map (regardless of the actual normal
  255. map's contents).
  256. In the example below, the normal map with :abbr:`RGTC (Red-Green Texture Compression)`
  257. compression is able to preserve its detail much better, while
  258. using the same amount of memory as a standard RGBA VRAM-compressed texture:
  259. .. figure:: img/importing_images_normal_map_rgtc.webp
  260. :align: center
  261. :alt: Normal map with standard VRAM compression (left) and with RGTC VRAM compression (right)
  262. Normal map with standard VRAM compression (left) and with RGTC VRAM compression (right)
  263. .. note::
  264. Godot requires the normal map to use the X+, Y+ and Z+ coordinates, which is
  265. known as an OpenGL-style normal map. If you've imported a material made to be
  266. used with another engine, it may be DirectX-style. In this case, the normal map
  267. needs to be converted by enabling the **Normal Map Invert Y** import option.
  268. More information about normal maps (including a coordinate order table for
  269. popular engines) can be found
  270. `here <http://wiki.polycount.com/wiki/Normal_Map_Technical_Details>`__.
  271. Compress > Channel Pack
  272. ^^^^^^^^^^^^^^^^^^^^^^^
  273. If set to **sRGB Friendly** (default), prevents the RG color format from being
  274. used as it does not support sRGB color.
  275. If set to **Optimized**, allows the RG color format to be used if the texture
  276. does not use the blue channel.
  277. A third option **Normal Map (RG Channels)** is *only* available in layered
  278. textures (:ref:`class_Cubemap`, :ref:`class_CubemapArray`, :ref:`class_Texture2DArray`
  279. and :ref:`class_Texture3D`). This forces all layers from the texture to be imported
  280. with the RG color format to reduce memory usage, with only the red and green
  281. channels preserved. This only has an effect on textures with the **VRAM Compressed**
  282. or **Basis Universal** compression modes.
  283. .. _doc_importing_images_mipmaps:
  284. Mipmaps > Generate
  285. ^^^^^^^^^^^^^^^^^^
  286. If enabled, smaller versions of the texture are generated on import. For
  287. example, a 64×64 texture will generate 6 mipmaps (32×32, 16×16, 8×8, 4×4, 2×2,
  288. 1×1). This has several benefits:
  289. - Textures will not become grainy in the distance (in 3D), or if scaled down due
  290. to camera zoom or CanvasItem scale (in 2D).
  291. - Performance will improve if the texture is displayed in the distance, since
  292. sampling smaller versions of the original texture is faster and requires less
  293. memory bandwidth.
  294. The downside of mipmaps is that they increase memory usage by roughly 33%.
  295. It's recommended to enable mipmaps in 3D. However, in 2D, this should only be
  296. enabled if your project visibly benefits from having mipmaps enabled. If the
  297. camera never zooms out significantly, there won't be a benefit to enabling
  298. mipmaps but memory usage will increase.
  299. Mipmaps > Limit
  300. ^^^^^^^^^^^^^^^
  301. .. UPDATE: Not implemented. When Mipmaps > Limit is implemented, remove this
  302. .. warning and remove this comment.
  303. .. warning::
  304. **Mipmaps > Limit** is currently not implemented and has no effect when changed.
  305. If set to a value greater than ``-1``, limits the maximum number of mipmaps that
  306. can be generated. This can be decreased if you don't want textures to become too
  307. low-resolution at extreme distances, at the cost of some graininess.
  308. Roughness > Mode
  309. ^^^^^^^^^^^^^^^^
  310. The color channel to consider as a roughness map in this texture. Only effective if
  311. **Roughness > Src Normal** is not empty.
  312. Roughness > Src Normal
  313. ^^^^^^^^^^^^^^^^^^^^^^
  314. The path to the texture to consider as a normal map for roughness filtering on
  315. import. Specifying this can help decrease specular aliasing slightly in 3D.
  316. Roughness filtering on import is only used in 3D rendering, not 2D.
  317. Process > Fix Alpha Border
  318. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  319. This puts pixels of the same surrounding color in transition from transparent to
  320. opaque areas. For textures displayed with bilinear filtering, this helps
  321. mitigate the outline effect when exporting images from an image editor.
  322. .. image:: img/fixedborder.png
  323. It's recommended to leave this enabled (as it is by default), unless this causes
  324. issues for a particular image.
  325. Process > Premult Alpha
  326. ^^^^^^^^^^^^^^^^^^^^^^^
  327. An alternative to fixing darkened borders with **Fix Alpha Border** is to use
  328. premultiplied alpha. By enabling this option, the texture will be converted to
  329. this format. A premultiplied alpha texture requires specific materials to be
  330. displayed correctly:
  331. - In 2D, a :ref:`class_CanvasItemMaterial` will need to be created and
  332. configured to use the **Premul Alpha** blend mode on CanvasItems that use this
  333. texture.
  334. - In 3D, there is no support for premultiplied alpha blend mode yet, so this
  335. option is only suited for 2D.
  336. Process > Normal Map Invert Y
  337. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  338. Godot requires the normal map to use the X+, Y+ and Z+ coordinates, which is
  339. known as an OpenGL-style normal map. If you've imported a material made to be
  340. used with another engine, it may be DirectX-style. In this case, the normal map
  341. needs to be converted by enabling the **Normal Map Invert Y** import option.
  342. More information about normal maps (including a coordinate order table for
  343. popular engines) can be found
  344. `here <http://wiki.polycount.com/wiki/Normal_Map_Technical_Details>`__.
  345. Process > HDR as sRGB
  346. ^^^^^^^^^^^^^^^^^^^^^
  347. Some HDR images you can find online may be broken and contain sRGB color data
  348. (instead of linear color data). It is advised not to use those files. If you
  349. absolutely have to, enabling this option on will make them look correct.
  350. .. warning::
  351. Enabling **HDR as sRGB** on well-formatted HDR images will cause the
  352. resulting image to look too dark, so leave this disabled if unsure.
  353. Process > HDR Clamp Exposure
  354. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  355. Some HDR panorama images you can find online may contain extremely bright
  356. pixels, due to being taken from real life sources without any clipping.
  357. While these HDR panorama images are accurate to real life, this can cause the
  358. radiance map generated by Godot to contain sparkles when used as a background
  359. sky. This can be seen in material reflections (even on rough materials in
  360. extreme cases). Enabling **HDR Clamp Exposure** can resolve this using a smart
  361. clamping formula that does not introduce *visible* clipping – glow will keep
  362. working when looking at the background sky.
  363. Process > Size Limit
  364. ^^^^^^^^^^^^^^^^^^^^
  365. If set to a value greater than ``0``, the size of the texture is limited on
  366. import to a value smaller than or equal to the value specified here. For
  367. non-square textures, the size limit affects the longer dimension, with the
  368. shorter dimension scaled to preserve aspect ratio. Resizing is performed using
  369. cubic interpolation.
  370. This can be used to reduce memory usage without affecting the source images, or
  371. avoid issues with textures not displaying on mobile/web platforms (as these
  372. usually can't display textures larger than 4096×4096).
  373. .. _doc_importing_images_detect_3d_compress_to:
  374. Detect 3D > Compress To
  375. ^^^^^^^^^^^^^^^^^^^^^^^
  376. This changes the :ref:`doc_importing_images_compress_mode` option that is used
  377. when a texture is detected as being used in 3D.
  378. Changing this import option only has an effect if a texture is detected as being
  379. used in 3D. Changing this to **Disabled** then reimporting will not change the
  380. existing compress mode on a texture (if it's detected to be used in 3D), but
  381. choosing **VRAM Compressed** or **Basis Universal** will.
  382. SVG > Scale
  383. ^^^^^^^^^^^
  384. *This is only available for SVG images.*
  385. The scale the SVG should be rendered at, with ``1.0`` being the original design
  386. size. Higher values result in a larger image. Note that unlike font
  387. oversampling, this affects the physical size the SVG is rendered at in 2D. See
  388. also **Editor > Scale With Editor Scale** below.
  389. .. _doc_importing_images_editor_import_options:
  390. Editor > Scale With Editor Scale
  391. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  392. *This is only available for SVG images.*
  393. If true, scales the imported image to match the editor's display scale factor.
  394. This should be enabled for editor plugin icons and custom class icons, but
  395. should be left disabled otherwise.
  396. Editor > Convert Colors With Editor Theme
  397. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  398. *This is only available for SVG images.*
  399. If checked, converts the imported image's colors to match the editor's icon and
  400. font color palette. This assumes the image uses the exact same colors as
  401. :ref:`Godot's own color palette for editor icons <doc_editor_icons>`, with the
  402. source file designed for a dark editor theme. This should be enabled for editor
  403. plugin icons and custom class icons, but should be left disabled otherwise.
  404. .. _doc_importing_images_svg_text:
  405. Importing SVG images with text
  406. ------------------------------
  407. As the SVG library used in Godot doesn't support rasterizing text found in SVG
  408. images, text must be converted to a path first. Otherwise, text won't appear in
  409. the rasterized image.
  410. There are two ways to achieve this in a non-destructive manner, so you can keep
  411. editing the original text afterwards:
  412. - Select your text object in Inkscape, then duplicate it in place by pressing
  413. :kbd:`Ctrl + D` and use **Path > Object to Path**. Hide the original text
  414. object afterwards using the **Layers and Objects** dock.
  415. - Use the Inkscape command line to export an SVG from another SVG file with text
  416. converted to paths:
  417. ::
  418. inkscape --export-text-to-path --export-filename svg_with_text_converted_to_path.svg svg_with_text.svg
  419. Best practices
  420. --------------
  421. Supporting high-resolution texture sizes in 2D without artifacts
  422. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  423. To support :ref:`multiple resolutions <doc_multiple_resolutions>` with crisp
  424. visuals at high resolutions, you will need to use high-resolution source images
  425. (suited for the highest resolution you wish to support without blurriness, which
  426. is typically 4K in modern desktop games).
  427. There are 2 ways to proceed:
  428. - Use a high base resolution in the project settings (such as 4K), then use the
  429. textures at original scale. This is an easier approach.
  430. - Use a low base resolution in the project settings (such as 1080p), then
  431. downscale textures when using them. This is often more difficult and can make
  432. various calculations in script tedious, so the approach described above is
  433. recommended instead.
  434. After doing this, you may notice that textures become grainy at lower viewport
  435. resolutions. To resolve this, enable **Mipmaps** on textures used in 2D in the
  436. Import dock. This will increase memory usage.
  437. Enabling mipmaps can also make textures appear blurrier, but you can choose
  438. to make textures sharper (at the cost of some graininess) by setting
  439. **Rendering > Textures > Default Filters > Texture Mipmap Bias** to a
  440. negative value.
  441. Use appropriate texture sizes in 3D
  442. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  443. While there's no "one size fits all" recommendation, here are some general
  444. recommendations for choosing texture sizes in 3D:
  445. - The size of a texture should be adjusted to have a consistent texel density
  446. compared to surrounding objects. While this cannot be ensured perfectly when
  447. sticking to power-of-two texture sizes, it's usually possible to keep texture
  448. detail fairly consistent throughout a 3D scene.
  449. - The smaller the object appears on screen, the smaller its texture should be.
  450. For example, a tree that only appears in the background doesn't need a texture
  451. resolution as high as other objects the player may be able to walk close to.
  452. - Using power-of-two texture sizes is recommended, but is not required. Textures
  453. don't have to be square – sizes such as 1024×512 are acceptable.
  454. - There are diminishing returns to using large texture sizes, despite the
  455. increased memory usage and loading times. Most modern 3D games not using a
  456. pixel art style stick to 2048×2048 textures on average, with 1024×1024 and
  457. 512×512 for textures spanning smaller surfaces.
  458. - When working with physically-based materials in 3D, you can reduce memory
  459. usage and file size without affecting quality too much by using a lower
  460. resolution for certain texture maps. This works especially well for textures
  461. that only feature low-frequency detail (such as a normal map for a snow
  462. texture).
  463. If you have control over how the 3D models are created, these tips are also
  464. worth exploring:
  465. - When working with 3D models that are mostly symmetrical, you may be able to
  466. use mirrored UVs to double the effective texel density. This may look
  467. unnatural when used on human faces though.
  468. - When working with 3D models using a low-poly style and plain colors, you can
  469. rely on vertex colors instead of textures to represent colors on the model's
  470. surfaces.
  471. .. seealso::
  472. Images can be loaded and saved at runtime using
  473. :ref:`runtime file loading and saving <doc_runtime_file_loading_and_saving_images>`,
  474. including from an exported project.