Decal

Inherits: VisualInstance3D < Node3D < Node < Object

Node that projects a texture onto a MeshInstance3D.

Description

Decals are used to project a texture onto a Mesh in the scene. Use Decals to add detail to a scene without affecting the underlying Mesh. They are often used to add weathering to building, add dirt or mud to the ground, or add variety to props. Decals can be moved at any time, making them suitable for things like blob shadows or laser sight dots.

They are made of an AABB and a group of Texture2Ds specifying Color, normal, ORM (ambient occlusion, roughness, metallic), and emission. Decals are projected within their AABB so altering the orientation of the Decal affects the direction in which they are projected. By default, Decals are projected down (i.e. from positive Y to negative Y).

The Texture2Ds associated with the Decal are automatically stored in a texture atlas which is used for drawing the decals so all decals can be drawn at once. Godot uses clustered decals, meaning they are stored in cluster data and drawn when the mesh is drawn, they are not drawn as a post-processing effect after.

Note: Decals cannot affect an underlying material's transparency, regardless of its transparency mode (alpha blend, alpha scissor, alpha hash, opaque pre-pass). This means translucent or transparent areas of a material will remain translucent or transparent even if an opaque decal is applied on them.

Note: Decals are only supported in the Forward+ and Mobile rendering methods, not Compatibility. When using the Mobile rendering method, only 8 decals can be displayed on each mesh resource. Attempting to display more than 8 decals on a single mesh resource will result in decals flickering in and out as the camera moves.

Note: When using the Mobile rendering method, decals will only correctly affect meshes whose visibility AABB intersects with the decal's AABB. If using a shader to deform the mesh in a way that makes it go outside its AABB, GeometryInstance3D.extra_cull_margin must be increased on the mesh. Otherwise, the decal may not be visible on the mesh.

Properties

float

albedo_mix

1.0

int

cull_mask

1048575

float

distance_fade_begin

40.0

bool

distance_fade_enabled

false

float

distance_fade_length

10.0

float

emission_energy

1.0

float

lower_fade

0.3

Color

modulate

Color(1, 1, 1, 1)

float

normal_fade

0.0

Vector3

size

Vector3(2, 2, 2)

Texture2D

texture_albedo

Texture2D

texture_emission

Texture2D

texture_normal

Texture2D

texture_orm

float

upper_fade

0.3

Methods

Texture2D

get_texture ( DecalTexture type ) const

void

set_texture ( DecalTexture type, Texture2D texture )


Enumerations

enum DecalTexture:

DecalTexture TEXTURE_ALBEDO = 0

Texture2D corresponding to texture_albedo.

DecalTexture TEXTURE_NORMAL = 1

Texture2D corresponding to texture_normal.

DecalTexture TEXTURE_ORM = 2

Texture2D corresponding to texture_orm.

DecalTexture TEXTURE_EMISSION = 3

Texture2D corresponding to texture_emission.

DecalTexture TEXTURE_MAX = 4

Max size of DecalTexture enum.


Property Descriptions

float albedo_mix = 1.0

  • void set_albedo_mix ( float value )

  • float get_albedo_mix ( )

Blends the albedo Color of the decal with albedo Color of the underlying mesh. This can be set to 0.0 to create a decal that only affects normal or ORM. In this case, an albedo texture is still required as its alpha channel will determine where the normal and ORM will be overridden. See also modulate.


int cull_mask = 1048575

  • void set_cull_mask ( int value )

  • int get_cull_mask ( )

Specifies which