Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Decal
Hereda: VisualInstance3D < Node3D < Node < Object
Nodo que proyecta una textura sobre una MeshInstance3D.
Descripción
Los Decals se utilizan para project una textura sobre un Mesh en la escena. Utiliza Decals para añadir detalles a una escena sin afectar al Mesh subyacente. A menudo se utilizan para añadir desgaste a los edificios, añadir suciedad o barro al suelo, o añadir variedad a los props. Los Decals se pueden mover en cualquier momento, lo que los hace adecuados para cosas como blob shadows o laser sight dots.
Están hechos de un AABB y un grupo de Texture2Ds que especifican el Color, normal, ORM (ambient occlusion, roughness, metallic) y emisión. Los Decals se proyectan dentro de su AABB, por lo que alterar la orientación del Decal afecta la dirección en la que se proyectan. Por defecto, los Decals se proyectan hacia abajo (es decir, de Y positivo a Y negativo).
Los Texture2Ds asociados con el Decal se almacenan automáticamente en un atlas de texturas que se utiliza para dibujar los decals, de modo que todos los decals se puedan dibujar a la vez. Godot utiliza decals agrupados, lo que significa que se almacenan en datos de cluster y se dibujan cuando se dibuja el mesh; no se dibujan como un effect de post-procesamiento posterior.
Note: Los Decals no pueden afectar la transparencia de un material subyacente, independientemente de su modo de transparencia (alpha blend, alpha scissor, alpha hash, opaque pre-pass). Esto significa que las áreas translúcidas o transparentes de un material seguirán siendo translúcidas o transparentes incluso si se aplica un decal opaco sobre ellas.
Note: Los Decals solo son compatibles con los métodos de renderizado Forward+ y Mobile, no con Compatibility. Al usar el método de renderizado Mobile, solo se pueden mostrar 8 decals en cada recurso mesh. Intentar mostrar más de 8 decals en un solo recurso mesh hará que los decals parpadeen a medida que la cámara se mueve.
Note: Al usar el método de renderizado Mobile, los decals solo afectarán correctamente a las mallas cuya visibilidad AABB se intersecte con el decal's AABB. Si se usa un shader para deformar el mesh de manera que salga de su AABB, se debe aumentar GeometryInstance3D.extra_cull_margin en el mesh. De lo contrario, el decal podría no ser visible en el mesh.
Propiedades
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Métodos
get_texture(type: DecalTexture) const |
|
void |
set_texture(type: DecalTexture, texture: Texture2D) |
Enumeraciones
enum DecalTexture: 🔗
DecalTexture TEXTURE_ALBEDO = 0
Texture2D correspondiente a texture_albedo.
DecalTexture TEXTURE_NORMAL = 1
Texture2D correspondiente a texture_normal.
DecalTexture TEXTURE_ORM = 2
Texture2D correspondiente a texture_orm.
DecalTexture TEXTURE_EMISSION = 3
Texture2D correspondiente a texture_emission.
DecalTexture TEXTURE_MAX = 4
El tamaño del enum DecalTexture.
Descripciones de Propiedades
Mezcla el Color de albedo del decal con el Color de albedo del mesh subyacente. Esto se puede establecer en 0.0 para crear un decal que solo afecte a normal o ORM. En este caso, todavía se requiere una textura de albedo, ya que su canal alpha determinará dónde se sobrescribirán normal y ORM. Consulte también modulate.
Especifica en qué VisualInstance3D.layers se proyectará este decal. Por defecto, los Decals afectan a todas las capas. Esto se utiliza para poder especificar qué tipos de objetos reciben el Decal y cuáles no. Esto es especialmente útil para asegurar que los objetos dinámicos no reciban accidentalmente un Decal destinado al terreno debajo de ellos.
float distance_fade_begin = 40.0 🔗
La distancia desde la cámara a la que el Decal comienza a desvanecerse (en unidades 3D).
bool distance_fade_enabled = false 🔗
Si es true, los decals se desvanecerán suavemente cuando estén lejos de la Camera3D activa, comenzando en distance_fade_begin. El Decal se desvanecerá por completo a lo largo de distance_fade_begin + distance_fade_length, después de lo cual será descartado culled y no se enviará al shader en absoluto. Utiliza esto para reducir el número de calcos activos en una escena y así mejorar el rendimiento.
float distance_fade_length = 10.0 🔗
La distancia sobre la cual el Decal se desvanece (en unidades 3D). El Decal se vuelve lentamente mas transparente a lo largo de esta distancia y es completamente invisible al final. Los valores más altos resultan en una transición de desvanecimiento más suave, lo cual es más adecuado cuando la cámara se mueve rápido.
Multiplicador de energía para la textura de emisión. Esto hará que el decal emita luz con una intensidad mayor o menor, independientemente del color del albedo. Véase también modulate.
Establece la curva sobre la cual el Decal se desvanecerá a medida que la superficie se aleje del centro de la AABB. Solo los valores positivos son válidos (los valores negativos se limitarán a 0.0). Véase también upper_fade.
Color modulate = Color(1, 1, 1, 1) 🔗
Cambia el Color del Decal multiplicando los colores del albedo y la emisión por este valor. El componente alfa solo se tiene en cuenta al multiplicar el color del albedo, no el color de la emisión. Véase también emission_energy y albedo_mix para cambiar la intensidad de la emisión y del albedo de forma independiente.
Fades the Decal if the angle between the Decal's AABB and the target surface becomes too large. A value of 0 projects the Decal regardless of angle, a value of 1 limits the Decal to surfaces that are nearly perpendicular.
Note: Setting normal_fade to a value greater than 0.0 has a small performance cost due to the added normal angle computations.
Vector3 size = Vector3(2, 2, 2) 🔗
Sets the size of the AABB used by the decal. All dimensions must be set to a value greater than zero (they will be clamped to 0.001 if this is not the case). The AABB goes from -size/2 to size/2.
Note: To improve culling efficiency of "hard surface" decals, set their upper_fade and lower_fade to 0.0 and set the Y component of the size as low as possible. This will reduce the decals' AABB size without affecting their appearance.
void set_texture(type: DecalTexture, texture: Texture2D)
Texture2D get_texture(type: DecalTexture) const
Texture2D with the base Color of the Decal. Either this or the texture_emission must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.
Note: Unlike BaseMaterial3D whose filter mode can be adjusted on a per-material basis, the filter mode for Decal textures is set globally with ProjectSettings.rendering/textures/decals/filter.
void set_texture(type: DecalTexture, texture: Texture2D)
Texture2D get_texture(type: DecalTexture) const
Texture2D with the emission Color of the Decal. Either this or the texture_albedo must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.
Note: Unlike BaseMaterial3D whose filter mode can be adjusted on a per-material basis, the filter mode for Decal textures is set globally with ProjectSettings.rendering/textures/decals/filter.
void set_texture(type: DecalTexture, texture: Texture2D)
Texture2D get_texture(type: DecalTexture) const
Texture2D with the per-pixel normal map for the decal. Use this to add extra detail to decals.
Note: Unlike BaseMaterial3D whose filter mode can be adjusted on a per-material basis, the filter mode for Decal textures is set globally with ProjectSettings.rendering/textures/decals/filter.
Note: Setting this texture alone will not result in a visible decal, as texture_albedo must also be set. To create a normal-only decal, load an albedo texture into texture_albedo and set albedo_mix to 0.0. The albedo texture's alpha channel will be used to determine where the underlying surface's normal map should be overridden (and its intensity).
void set_texture(type: DecalTexture, texture: Texture2D)
Texture2D get_texture(type: DecalTexture) const
Texture2D storing ambient occlusion, roughness, and metallic for the decal. Use this to add extra detail to decals.
Note: Unlike BaseMaterial3D whose filter mode can be adjusted on a per-material basis, the filter mode for Decal textures is set globally with ProjectSettings.rendering/textures/decals/filter.
Note: Setting this texture alone will not result in a visible decal, as texture_albedo must also be set. To create an ORM-only decal, load an albedo texture into texture_albedo and set albedo_mix to 0.0. The albedo texture's alpha channel will be used to determine where the underlying surface's ORM map should be overridden (and its intensity).
Note: Due to technical limitations, modifying the underlying surface's roughness using texture_orm does not affect screen-space reflections (Environment.ssr_enabled), reflections from VoxelGI, and reflections from SDFGI (Environment.sdfgi_enabled). Only reflections from ReflectionProbes are affected.
Establece la curva sobre la que el Decal se desvanecerá a medida que la superficie se aleje del centro del AABB. Solo los valores positivos son válidos (los valores negativos se limitarán a 0.0). Véase también lower_fade.
Descripciones de Métodos
Texture2D get_texture(type: DecalTexture) const 🔗
Returns the Texture2D associated with the specified DecalTexture. This is a convenience method, in most cases you should access the texture directly.
For example, instead of albedo_tex = $Decal.get_texture(Decal.TEXTURE_ALBEDO), use albedo_tex = $Decal.texture_albedo.
One case where this is better than accessing the texture directly is when you want to copy one Decal's textures to another. For example:
for i in Decal.TEXTURE_MAX:
$NewDecal.set_texture(i, $OldDecal.get_texture(i))
for (int i = 0; i < (int)Decal.DecalTexture.Max; i++)
{
GetNode<Decal>("NewDecal").SetTexture(i, GetNode<Decal>("OldDecal").GetTexture(i));
}
void set_texture(type: DecalTexture, texture: Texture2D) 🔗
Sets the Texture2D associated with the specified DecalTexture. This is a convenience method, in most cases you should access the texture directly.
For example, instead of $Decal.set_texture(Decal.TEXTURE_ALBEDO, albedo_tex), use $Decal.texture_albedo = albedo_tex.
One case where this is better than accessing the texture directly is when you want to copy one Decal's textures to another. For example:
for i in Decal.TEXTURE_MAX:
$NewDecal.set_texture(i, $OldDecal.get_texture(i))
for (int i = 0; i < (int)Decal.DecalTexture.Max; i++)
{
GetNode<Decal>("NewDecal").SetTexture(i, GetNode<Decal>("OldDecal").GetTexture(i));
}