importing_images.rst 28 KB

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