|
15 | 15 | <description> |
16 | 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 | 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] |
18 | 51 | </description> |
19 | 52 | </method> |
20 | 53 | <method name="update_layer"> |
|
0 commit comments