Class reference
WorldScape3DMeshAsset
Inherits WorldScape3DAssetResource
Description
This class manages meshes used for instancing. There are two broad types of meshes it can host. 1. 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. 2. 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: MultiMesh, MultiMeshInstance3D
Properties
int cast_shadows = 1
int cast_shadows = 1Tells the renderer how to cast shadows from this mesh asset onto the terrain and other objects. This sets [code skip-lint]GeometryInstance3D.cast_shadow[/code] on all MultiMeshInstances used by this mesh.
float density = 10.0
float density = 10.0Density 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 [code skip-lint]10.f / mesh->get_aabb().get_volume()[/code], then clamped to a sane range. If the calculated amount is inappropriate, increase or decrease it here.
bool enabled = true
bool enabled = trueIf enabled, MultiMeshInstance3Ds will be generated for this mesh asset.
float fade_margin = 0.0
float fade_margin = 0.0If > 0, sets [code skip-lint]GeometryInstance3D.fade_mode = self[/code], sets this margin in [code skip-lint]GeometryInstance3D.visibility_range_begin_margin[/code] and [code skip-lint]GeometryInstance3D.visibility_range_end_margin[/code] 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 Redot issue #102799 is fixed.
int generated_faces = 2
int generated_faces = 2Select 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)
Vector2 generated_size = Vector2(1, 1)Sets the base size of the QuadMesh texture card. Increasing this size will expand from bottom, not the middle.
int generated_type = 0
int generated_type = 0If enabled, this mesh asset will be set to a generated QuadMesh to be used as a texture card.
float height_offset = 0.0
float height_offset = 0.0Vertically 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 cumulative.
int id = 0
int id = 0The user settable ID of the mesh. You can change this to reorder meshes in the list.
int last_lod = 9
int last_lod = 9Sets the farthest Level of Detail (LOD) that will be rendered. Farther LODs (greater than this number) will be ignored.
int last_shadow_lod = 9
int last_shadow_lod = 9Sets 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
float lod0_range = 32.0Sets [code skip-lint]GeometryInstance3D.visibility_range_end[/code] 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 [code skip-lint]GeometryInstance3D.visibility_range_begin[/code]. Set to 0 to disable culling and see this LOD at any distance.
float lod1_range = 64.0
float lod1_range = 64.0Sets the end visible range for LOD1. See lod0_range.
float lod2_range = 96.0
float lod2_range = 96.0Sets the end visible range for LOD2. See lod0_range.
float lod3_range = 128.0
float lod3_range = 128.0Sets the end visible range for LOD3. See lod0_range.
float lod4_range = 160.0
float lod4_range = 160.0Sets the end visible range for LOD4. See lod0_range.
float lod5_range = 192.0
float lod5_range = 192.0Sets the end visible range for LOD5. See lod0_range.
float lod6_range = 224.0
float lod6_range = 224.0Sets the end visible range for LOD6. See lod0_range.
float lod7_range = 256.0
float lod7_range = 256.0Sets the end visible range for LOD7. See lod0_range.
float lod8_range = 288.0
float lod8_range = 288.0Sets the end visible range for LOD8. See lod0_range.
float lod9_range = 320.0
float lod9_range = 320.0Sets the end visible range for LOD9. See lod0_range.
int lod_count = 0
int lod_count = 0Provides the detected number of Levels of Detail (LODs) found in the provided scene file or generated mesh. Read only.
Material material_overlay
Material material_overlayThis sets [code skip-lint]GeometryInstance3D.material_overlay[/code], which applies an overriding material using [code skip-lint]next_pass[/code] that overlays the base material.
Material material_override
Material material_overrideThis sets [code skip-lint]GeometryInstance3D.material_override[/code], which replaces the rendered mesh material with this one.
String name = ""
String name = ""The user specified name for this asset.
PackedScene scene_file
PackedScene scene_fileSpecifies the PackedScene (.tscn, .scn, .glb, .fbx, etc) to load the mesh from. See the top description.
int shadow_impostor = 0
int shadow_impostor = 0Uses 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 [code skip-lint]shadow_impostor = 2[/code] 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.
Methods
void clear()
Resets this resource to default settings.
float get_lod_range(int lod) const
float get_lod_range(int lod) constReturns 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(int lod = 0) const
Mesh get_mesh(int lod = 0) constReturns the [code skip-lint]Mesh[/code] resource for the specified Level of Detail (LOD).
Texture2D get_thumbnail() const
Texture2D get_thumbnail() constReturns the thumbnail generated by WorldScape3DAssets.
void set_lod_range(int lod, float distance)
int lod, float distance)Sets the far visible distance for the specified Level of Detail (LOD).
Signals
file_changed()
Emitted when scene_file is changed, or if the generated mesh is toggled.
id_changed(int type, int old_id, int new_id)
int type, int old_id, int new_id)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.
Constants
TYPE_NONE = 0
No generated mesh is in use, likely because a scene file is used.
TYPE_TEXTURE_CARD = 1
Generates a QuadMesh to be used as a texture card.
TYPE_MAX = 2
Maximum value for this enum.