Terrain3DMeshAsset
Inherits: Resource
Description
This class manages meshes used for instancing. There are two broad types of meshes it can host.
Generated Texture Card - this class will generate a QuadMesh. The typical use for this is to create a material in the override material, place a 2D grass texture in the albedo texture slot, and enable alpha scissor. This will generate low poly grass.
Scene File - you can provide your own mesh in a scene file, which is specifically a PackedScene (.tscn, .scn, .glb, .fbx, etc). You can override the material if desired. MultiMeshes only support one mesh object, so complex objects like tree trunks and leaves, or a door frame and door either need to be combined into one object with multiple materials, or placed by another method. The system will look for MeshInstance3D nodes in the file to use as Levels of Detail (LODs). Ideally they have suffixes like LOD0, LOD1. We support up to 10 LODs, but recommend no more than 4.
Read More:
Tutorial: Foliage Instancing
Godot Reference: MultiMesh, MultiMeshInstance3D
Properties
GeometryInstance3D.ShadowCastingSetting |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
||
|
|
|
|
||
|
|
Methods
void |
clear() |
|
get_lod_range(lod: |
|
get_mesh(lod: |
|
get_thumbnail() const |
void |
set_lod_range(lod: |
Signals
file_changed() 🔗
Emitted when scene_file is changed, or if the generated mesh is toggled.
id_changed() 🔗
Emitted when id is changed.
instancer_setting_changed() 🔗
Emitted when instancer specific settings are changed on this mesh asset, such as cast_shadows, and triggers an instancer rebuild.
setting_changed() 🔗
Emitted when settings are changed, other than those tracked by other signals.
Enumerations
enum GenType: 🔗
GenType TYPE_NONE = 0
No generated mesh is in use, likely because a scene file is used.
GenType TYPE_TEXTURE_CARD = 1
Generates a QuadMesh to be used as a texture card.
GenType TYPE_MAX = 2
Maximum value for this enum.
Property Descriptions
GeometryInstance3D.ShadowCastingSetting cast_shadows = 1
🔗
void set_cast_shadows(value: GeometryInstance3D.ShadowCastingSetting)
GeometryInstance3D.ShadowCastingSetting get_cast_shadows()
Tells the renderer how to cast shadows from this mesh asset onto the terrain and other objects. This sets GeometryInstance3D.cast_shadow
on all MultiMeshInstances used by this mesh.
float
density = 10.0
🔗
void set_density(value:
float
)float
get_density()
Density is used to set the approximate default spacing between instances based on the size of the mesh. When painting meshes on the terrain, mesh density is multiplied by brush strength.
This value is not tied to any real world unit. It is calculated as 10.f / mesh->get_aabb().get_volume()
, then clamped to a sane range. If the calculated amount is inappropriate, increase or decrease it here.
bool
enabled = true
🔗
void set_enabled(value:
bool
)bool
is_enabled()
If enabled, MultiMeshInstance3Ds will be generated for this mesh asset.
float
fade_margin = 0.0
🔗
void set_fade_margin(value:
float
)float
get_fade_margin()
If > 0, sets GeometryInstance3D.fade_mode = self
, sets this margin in GeometryInstance3D.visibility_range_begin_margin
and GeometryInstance3D.visibility_range_end_margin
and adjusts the ranges to allow fading between lods.
Limited to the smaller of half the distance between LOD0 and LOD1, or 64m.
Currently broken and hidden in the inspector until Godot issue #102799 is fixed.
int
generated_faces = 2
🔗
void set_generated_faces(value:
int
)int
get_generated_faces()
Select if you want the generated texture card to have a single QuadMesh, 2 meshes rotated 90° in a cross, or 3 rotated at 60°.
Vector2
generated_size = Vector2(1, 1)
🔗
void set_generated_size(value:
Vector2
)Vector2
get_generated_size()
Sets the base size of the QuadMesh texture card. Increasing this size will expand from bottom, not the middle.
If enabled, this mesh asset will be set to a generated QuadMesh to be used as a texture card.
float
height_offset = 0.0
🔗
void set_height_offset(value:
float
)float
get_height_offset()
Vertically offsets the origin point of the mesh asset. For example, if you have a 2 meter diameter rock with the mesh origin point in the center, but you want all rocks to be sitting on the ground, you could enter 1 or 0.9 here and it will be placed near its edge. You can also adjust this when painting using the tool settings bar; both options are cummulative.
int
id = 0
🔗
void set_id(value:
int
)int
get_id()
The user settable ID of the mesh. You can change this to reorder meshes in the list.
int
last_lod = 9
🔗
void set_last_lod(value:
int
)int
get_last_lod()
Sets the farthest Level of Detail (LOD) that will be rendered. Farther LODs (greater than this number) will be ignored.
int
last_shadow_lod = 9
🔗
void set_last_shadow_lod(value:
int
)int
get_last_shadow_lod()
Sets the farthest Level of Detail (LOD) that will cast shadows. Farther LODs (greater than this number) won’t cast shadows. If shadow_impostor is greater than this number, the shadow impostor will still cast shadows.
float
lod0_range = 32.0
🔗
void set_lod0_range(value:
float
)float
get_lod0_range()
Sets GeometryInstance3D.visibility_range_end
on all MultiMeshInstances used by this mesh at the closest Level of Detail (LOD), the most detailed.
Allows the renderer to cull MMIs beyond this distance. The next LOD level will use this value for its GeometryInstance3D.visibility_range_begin
.
Set to 0 to disable culling and see this LOD at any distance.
float
lod1_range = 64.0
🔗
void set_lod1_range(value:
float
)float
get_lod1_range()
Sets the end visible range for LOD1. See lod0_range.
float
lod2_range = 96.0
🔗
void set_lod2_range(value:
float
)float
get_lod2_range()
Sets the end visible range for LOD2. See lod0_range.
float
lod3_range = 128.0
🔗
void set_lod3_range(value:
float
)float
get_lod3_range()
Sets the end visible range for LOD3. See lod0_range.
float
lod4_range = 160.0
🔗
void set_lod4_range(value:
float
)float
get_lod4_range()
Sets the end visible range for LOD4. See lod0_range.
float
lod5_range = 192.0
🔗
void set_lod5_range(value:
float
)float
get_lod5_range()
Sets the end visible range for LOD5. See lod0_range.
float
lod6_range = 224.0
🔗
void set_lod6_range(value:
float
)float
get_lod6_range()
Sets the end visible range for LOD6. See lod0_range.
float
lod7_range = 256.0
🔗
void set_lod7_range(value:
float
)float
get_lod7_range()
Sets the end visible range for LOD7. See lod0_range.
float
lod8_range = 288.0
🔗
void set_lod8_range(value:
float
)float
get_lod8_range()
Sets the end visible range for LOD8. See lod0_range.
float
lod9_range = 320.0
🔗
void set_lod9_range(value:
float
)float
get_lod9_range()
Sets the end visible range for LOD9. See lod0_range.
int
lod_count = 0
🔗
int
get_lod_count()
Provides the detected number of Levels of Detail (LODs) found in the provided scene file or generated mesh. Read only.
Material
material_overlay 🔗
void set_material_overlay(value:
Material
)Material
get_material_overlay()
This sets GeometryInstance3D.material_overlay
, which applies an overriding material using next_pass
that overlays the base material.
Material
material_override 🔗
void set_material_override(value:
Material
)Material
get_material_override()
This sets GeometryInstance3D.material_override
, which replaces the rendered mesh material with this one.
String
name = "New Mesh"
🔗
void set_name(value:
String
)String
get_name()
The user specified name for this asset.
PackedScene
scene_file 🔗
void set_scene_file(value:
PackedScene
)PackedScene
get_scene_file()
Specifies the PackedScene (.tscn, .scn, .glb, .fbx, etc) to load the mesh from. See the top description.
int
shadow_impostor = 0
🔗
void set_shadow_impostor(value:
int
)int
get_shadow_impostor()
Uses this lower quality Level of Detail (LOD) to calculate shadows (as an impostor) instead of the visible mesh.
e.g. Normally each LOD casts its own shadows. Given LOD0-3, if shadow_impostor = 2
then when LOD0-1 are visible, they are set to no shadows and LOD2 is set to cast shadows only. When LOD2-3 are visible, each casts their own shadow as normal.
Increase to improve performance by lowering shadow quality.
Shadow impostors are disabled if this is set to 0 or if cast_shadows is set to shadows only.
Method Descriptions
void clear() 🔗
Resets this resource to default settings.
float
get_lod_range(lod: int
) const 🔗
Returns the far visible distance for the specified Level of Detail (LOD). The near visible distance is the LOD range for the next closest LOD.
Mesh
get_mesh(lod: int
= 0) const 🔗
Returns the Mesh
resource for the specified Level of Detail (LOD).
Texture2D
get_thumbnail() const 🔗
Returns the thumbnail generated by Terrain3DAssets.
void set_lod_range(lod: int
, distance: float
) 🔗
Sets the far visible distance for the specified Level of Detail (LOD).