Terrain3DAssets

Inherits: Resource

Description

This class contains arrays of Terrain3DTextureAsset and Terrain3DMeshAsset resources. It is a savable resource, so you can save it to disk and use the same asset list in multiple scenes that use Terrain3D. The amount of data is small, so it can be saved as a git-friendly, text based .tres file or left within the scene file.

Properties

Array[Terrain3DMeshAsset]

mesh_list

[]

Array[Terrain3DTextureAsset]

texture_list

[]

Methods

void

clear_textures(update: bool = false)

void

create_mesh_thumbnails(id: int = -1, size: Vector2i = Vector2i(128, 128))

RID

get_albedo_array_rid() const

Terrain3DMeshAsset

get_mesh_asset(id: int) const

int

get_mesh_count() const

RID

get_normal_array_rid() const

Terrain3DTextureAsset

get_texture(id: int) const

PackedFloat32Array

get_texture_ao_strengths() const

PackedColorArray

get_texture_colors() const

int

get_texture_count() const

PackedVector2Array

get_texture_detiles() const

PackedFloat32Array

get_texture_normal_depths() const

PackedFloat32Array

get_texture_roughness_mods() const

PackedFloat32Array

get_texture_uv_scales() const

Error

save(path: String = “”)

void

set_mesh_asset(id: int, mesh: Terrain3DMeshAsset)

void

set_texture(id: int, texture: Terrain3DTextureAsset)

void

update_mesh_list()

void

update_texture_list()


Signals

meshes_changed() 🔗

Emitted when the mesh list is updated, which happens as a result of a Terrain3DMeshAsset changing.


textures_changed() 🔗

Emitted when this list is updated due to changes in the texture slots, or the files or settings of any Terrain3DTextureAsset.


Enumerations

enum AssetType: 🔗

AssetType TYPE_TEXTURE = 0

Asset is type Terrain3DTextureAsset.

AssetType TYPE_MESH = 1

Asset is type Terrain3DMeshAsset.


Constants

MAX_TEXTURES = 32 🔗

Hard coded maximum number of textures, with IDs in the range of 0-31. Cannot easily be expanded.

MAX_MESHES = 256 🔗

Limit of the maximum number of meshes. Arbitrary, easily expanded.


Property Descriptions

Array[Terrain3DMeshAsset] mesh_list = [] 🔗

The list of mesh assets.


Array[Terrain3DTextureAsset] texture_list = [] 🔗

The list of texture assets.


Method Descriptions

void clear_textures(update: bool = false) 🔗

After textures are loaded, they are combined into a TextureArray. The originals remain in VRAM and are only used if the Terrain3DTextureAsset settings are changed and regenerating the TextureArrays are necessary. Use this function to clear the originals if not needed. It removes all textures from the asset list, freeing them if they are not referenced by other objects.

Update will regenerate the texture arrays housing the textures drawn on the terrain. This will remove all textures and turn the terrain checkerboard.

A similar clear_meshes is less useful so hasn’t been included. However you can do the same thing with get_mesh_list().clear().


void create_mesh_thumbnails(id: int = -1, size: Vector2i = Vector2i(128, 128)) 🔗

Generates mesh asset preview thumbnails for the asset dock, stored within each mesh asset. Specify id -1 to generate all.


RID get_albedo_array_rid() const 🔗

Returns the resource ID of the TextureArray generated from combining all albedo and height textures.


Terrain3DMeshAsset get_mesh_asset(id: int) const 🔗

Returns the specified Terrain3DMeshAsset resource.


int get_mesh_count() const 🔗

Returns the number of mesh assets in the list.


RID get_normal_array_rid() const 🔗

Returns the resource ID of the TextureArray generated from combining all normal and roughness textures.


Terrain3DTextureAsset get_texture(id: int) const 🔗

Returns the Terrain3DTextureAsset with the requested ID.


PackedFloat32Array get_texture_ao_strengths() const 🔗

Returns the array of AO strengths for each texture asset, indexed by asset id.


PackedColorArray get_texture_colors() const 🔗

Returns the array of albedo tints for each texture asset, indexed by asset id.


int get_texture_count() const 🔗

Returns the number of texture slots used.


PackedVector2Array get_texture_detiles() const 🔗

Returns the array of detiling values for each texture asset, indexed by asset id.


PackedFloat32Array get_texture_normal_depths() const 🔗

Returns the array of normal strengths for each texture asset, indexed by asset id.


PackedFloat32Array get_texture_roughness_mods() const 🔗

Returns the array of roughness modification values for each texture asset, indexed by asset id.


PackedFloat32Array get_texture_uv_scales() const 🔗

Returns the array of uv scale values for each texture asset, indexed by asset id.


Error save(path: String = “”) 🔗

Saves this texture list resource to disk, if saved as an external .tres or .res resource file.

path - specifies a directory and file name to use from now on.


void set_mesh_asset(id: int, mesh: Terrain3DMeshAsset) 🔗

Assigns the Terrain3DMeshAsset to the specified ID slot. It can be null to clear the slot. See set_texture().


void set_texture(id: int, texture: Terrain3DTextureAsset) 🔗

Adds a Terrain3DTextureAsset at the specified ID slot. The texture can be null to clear the slot, or remove it if its the last in the list. If the specified slot is full, it will be swapped with the source texture ID, or will find the next available ID.


void update_mesh_list() 🔗

Updates the internal list of meshes used by the instancer.


void update_texture_list() 🔗

Regenerates the texture arrays from the list of texture assets, which is sent to the shader.