0.2.0-dev Download ZIP
65 lines ·3.2 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="ImageTextureLayered" inherits="TextureLayered" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Base class for texture types which contain the data of multiple [ImageTexture]s. Each image is of the same size and format. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | Base class for [Texture2DArray], [Cubemap] and [CubemapArray]. Cannot be used directly, but contains all the functions necessary for accessing the derived resource types. See also [Texture3D]. |
| 8 | </description> |
| 9 | <tutorials> |
| 10 | </tutorials> |
| 11 | <methods> |
| 12 | <method name="create_from_images"> |
| 13 | <return type="int" enum="Error" /> |
| 14 | <param index="0" name="images" type="Image[]" /> |
| 15 | <description> |
| 16 | Creates an [ImageTextureLayered] from an array of [Image]s. See [method Image.create] for the expected data format. The first image decides the width, height, image format and mipmapping setting. The other images [i]must[/i] have the same width, height, image format and mipmapping setting. |
| 17 | Each [Image] represents one [code]layer[/code]. |
| 18 | [codeblock] |
| 19 | # Fill in an array of Images with different colors. |
| 20 | var images = [] |
| 21 | const LAYERS = 6 |
| 22 | for i in LAYERS: |
| 23 | var image = Image.create_empty(128, 128, false, Image.FORMAT_RGB8) |
| 24 | if i % 3 == 0: |
| 25 | image.fill(Color.RED) |
| 26 | elif i % 3 == 1: |
| 27 | image.fill(Color.GREEN) |
| 28 | else: |
| 29 | image.fill(Color.BLUE) |
| 30 | images.push_back(image) |
| 31 | |
| 32 | # Create and save a 2D texture array. The array of images must have at least 1 Image. |
| 33 | var texture_2d_array = Texture2DArray.new() |
| 34 | texture_2d_array.create_from_images(images) |
| 35 | ResourceSaver.save(texture_2d_array, "res://texture_2d_array.res", ResourceSaver.FLAG_COMPRESS) |
| 36 | |
| 37 | # Create and save a cubemap. The array of images must have exactly 6 Images. |
| 38 | # The cubemap's images are specified in this order: X+, X-, Y+, Y-, Z+, Z- |
| 39 | # (in Godot's coordinate system, so Y+ is "up" and Z- is "forward"). |
| 40 | var cubemap = Cubemap.new() |
| 41 | cubemap.create_from_images(images) |
| 42 | ResourceSaver.save(cubemap, "res://cubemap.res", ResourceSaver.FLAG_COMPRESS) |
| 43 | |
| 44 | # Create and save a cubemap array. The array of images must have a multiple of 6 Images. |
| 45 | # Each cubemap's images are specified in this order: X+, X-, Y+, Y-, Z+, Z- |
| 46 | # (in Godot's coordinate system, so Y+ is "up" and Z- is "forward"). |
| 47 | var cubemap_array = CubemapArray.new() |
| 48 | cubemap_array.create_from_images(images) |
| 49 | ResourceSaver.save(cubemap_array, "res://cubemap_array.res", ResourceSaver.FLAG_COMPRESS) |
| 50 | [/codeblock] |
| 51 | </description> |
| 52 | </method> |
| 53 | <method name="update_layer"> |
| 54 | <return type="void" /> |
| 55 | <param index="0" name="image" type="Image" /> |
| 56 | <param index="1" name="layer" type="int" /> |
| 57 | <description> |
| 58 | Replaces the existing [Image] data at the given [param layer] with this new image. |
| 59 | The given [Image] must have the same width, height, image format, and mipmapping flag as the rest of the referenced images. |
| 60 | If the image format is unsupported, it will be decompressed and converted to a similar and supported [enum Image.Format]. |
| 61 | The update is immediate: it's synchronized with drawing. |
| 62 | </description> |
| 63 | </method> |
| 64 | </methods> |
| 65 | </class> |