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...
ShaderMaterial
Eredita: Material < Resource < RefCounted < Object
Un materiale definito da un programma Shader personalizzato e dai valori dei relativi parametri di shader.
Descrizione
Un materiale che utilizza un programma Shader personalizzato per il rendering di elementi visivi (elementi canvas, mesh, cieli, nebbia) o per elaborare particelle. Rispetto ad altri materiali, ShaderMaterial offre un controllo più approfondito sul codice shader generato. Per ulteriori informazioni, consulta l'indice della documentazione degli shader qui sotto.
Più ShaderMaterial possono usare lo stesso shader e configurare valori diversi per le uniformi nello shader.
Nota: Per motivi di prestazioni, il segnale Resource.changed viene emesso solo quando cambia Resource.resource_name. Solo nell'editor, viene emesso anche per le modifiche di shader.
Tutorial
Proprietà
Metodi
get_shader_parameter(param: StringName) const |
|
void |
set_shader_parameter(param: StringName, value: Variant) |
Descrizioni delle proprietà
Il programma Shader utilizzato per il rendering di questo materiale.
Descrizioni dei metodi
Variant get_shader_parameter(param: StringName) const 🔗
Restituisce il valore attuale impostato per questo materiale di un'uniforme nello shader.
void set_shader_parameter(param: StringName, value: Variant) 🔗
Changes the value set for this material of a uniform in the shader.
Note: param is case-sensitive and must match the name of the uniform in the code exactly (not the capitalized name in the inspector).
Note: Changes to the shader uniform will be effective on all instances using this ShaderMaterial. To prevent this, use per-instance uniforms with CanvasItem.set_instance_shader_parameter(), GeometryInstance3D.set_instance_shader_parameter() or duplicate the ShaderMaterial resource using Resource.duplicate(). Per-instance uniforms allow for better shader reuse and are therefore faster, so they should be preferred over duplicating the ShaderMaterial when possible.