importing_images.rst 27 KB

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