Skip to content

Commit 051b6f3

Browse files
committed
Document generating mipmaps in Runtime file loading and saving
This is often needed when displaying loaded images on a 3D surface.
1 parent 66b59c1 commit 051b6f3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tutorials/io/runtime_file_loading_and_saving.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,24 @@ instead of the filesystem. This is useful to send the image over the network or
105105
into a ZIP archive without having to write it on the filesystem. This can
106106
increase performance by reducing I/O utilization.
107107

108+
.. note::
109+
110+
If displaying the loaded image on a 3D surface, make sure to call
111+
:ref:`Image.generate_mipmaps <class_Image_method_generate_mipmaps>`
112+
so that the texture doesn't look grainy when viewed at a distance.
113+
This is also useful in 2D when following instructions on
114+
:ref:`reducing aliasing when downsampling <doc_multiple_resolutions_reducing_aliasing_on_downsampling>`.
115+
108116
Example of loading an image and displaying it in a :ref:`class_TextureRect` node
109117
(which requires conversion to :ref:`class_ImageTexture`):
110118

111119
::
112120

113121
# Load an image of any format supported by Godot from the filesystem.
114122
var image = Image.load_from_file(path)
123+
# Optionally, generate mipmaps if displaying the texture on a 3D surface
124+
# so that the texture doesn't look grainy when viewed at a distance.
125+
#image.generate_mipmaps()
115126
$TextureRect.texture = ImageTexture.create_from_image(image)
116127

117128
# Save the loaded Image to a PNG image.

0 commit comments

Comments
 (0)