From 051b6f33c63d147099f547df6ae9f09681fd2c05 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 10 Nov 2023 10:59:31 +0100 Subject: [PATCH] Document generating mipmaps in Runtime file loading and saving This is often needed when displaying loaded images on a 3D surface. --- tutorials/io/runtime_file_loading_and_saving.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tutorials/io/runtime_file_loading_and_saving.rst b/tutorials/io/runtime_file_loading_and_saving.rst index 7495a89155d..84df8200559 100644 --- a/tutorials/io/runtime_file_loading_and_saving.rst +++ b/tutorials/io/runtime_file_loading_and_saving.rst @@ -105,6 +105,14 @@ instead of the filesystem. This is useful to send the image over the network or into a ZIP archive without having to write it on the filesystem. This can increase performance by reducing I/O utilization. +.. note:: + + If displaying the loaded image on a 3D surface, make sure to call + :ref:`Image.generate_mipmaps ` + so that the texture doesn't look grainy when viewed at a distance. + This is also useful in 2D when following instructions on + :ref:`reducing aliasing when downsampling `. + Example of loading an image and displaying it in a :ref:`class_TextureRect` node (which requires conversion to :ref:`class_ImageTexture`): @@ -112,6 +120,9 @@ Example of loading an image and displaying it in a :ref:`class_TextureRect` node # Load an image of any format supported by Godot from the filesystem. var image = Image.load_from_file(path) + # Optionally, generate mipmaps if displaying the texture on a 3D surface + # so that the texture doesn't look grainy when viewed at a distance. + #image.generate_mipmaps() $TextureRect.texture = ImageTexture.create_from_image(image) # Save the loaded Image to a PNG image.