importing_images.rst 30 KB

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