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...
Material
繼承: Resource < RefCounted < Object
被繼承: BaseMaterial3D, BlitMaterial, CanvasItemMaterial, FogMaterial, PanoramaSkyMaterial, ParticleProcessMaterial, PhysicalSkyMaterial, PlaceholderMaterial, ProceduralSkyMaterial, ShaderMaterial
用於將如顏色、粗糙度等視覺屬性套用至物件的虛擬基底類別。
說明
Material 即材質,是一種基礎資源,能夠為幾何體著色。所有的材質都繼承自它,幾乎所有從 VisualInstance3D 派生的節點都帶有 Material。有一些標誌和參數是在所有材質型別之間共享的,可以在這裡進行設定。
重要的是,你可以繼承 Material 以在腳本或 GDExtension 中建立你自己的自訂材質型別。
教學
屬性
方法
_can_do_next_pass() virtual const |
|
_can_use_render_priority() virtual const |
|
_get_shader_mode() virtual required const |
|
_get_shader_rid() virtual required const |
|
create_placeholder() const |
|
void |
常數
RENDER_PRIORITY_MAX = 127 🔗
render_priority 參數的最大值。
RENDER_PRIORITY_MIN = -128 🔗
render_priority 參數的最小值。
屬性說明
設定下一階段使用的 Material。這將使用不同的材質再次渲染物件。
注意:next_pass 材質不一定是緊接在源 Material 之後繪製的。繪製順序由材質屬性、render_priority 和到相機的距離決定。
注意:僅適用於 StandardMaterial3D 和“Spatial”型別的 ShaderMaterial。
設定 3D 場景中物體的渲染優先級。優先級高的物體將被排序在優先級低的物體前面。換句話說,所有具有 render_priority 1 的物件,將在所有具有 render_priority 0 的物件之上渲染。
注意:僅適用於 StandardMaterial3D 和“Spatial”型別的 ShaderMaterial。
注意:這不會影響透明物件相對於不透明物件的排序方式,或動態網格體相對於其他不透明網格體的排序方式。這是因為所有透明物件都是在所有不透明物件之後繪製的,並且所有動態不透明網格都是在其他不透明網格之前繪製的。
方法說明
bool _can_do_next_pass() virtual const 🔗
僅出於覆蓋目的而暴露。你不能直接呼叫該函式。在內部用於確定 next_pass 是否應顯示在編輯器中。
bool _can_use_render_priority() virtual const 🔗
僅出於覆蓋目的而暴露。你不能直接呼叫該函式。在內部用於確定 render_priority 是否應顯示在編輯器中。
Mode _get_shader_mode() virtual required const 🔗
僅出於覆蓋目的而暴露。你不能直接呼叫該函式。由各種編輯器工具內部使用。
RID _get_shader_rid() virtual required const 🔗
僅出於覆蓋目的而暴露。你不能直接呼叫該函式。由各種編輯器工具內部使用。用於存取 Material 的 Shader 的 RID。
Resource create_placeholder() const 🔗
建立該資源的預留位置版本(PlaceholderMaterial)。
void inspect_native_shader_code() 🔗
僅在編輯器中執行時可用。打開一個彈出視窗顯示生成的著色器程式碼,包括所有變體和內部著色器程式碼。另見 Shader.inspect_native_shader_code()。