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...
Shader
繼承: Resource < RefCounted < Object
被繼承: VisualShader
用 Godot 著色語言實作的著色器。
說明
用 Godot 著色語言實作的自訂著色器程式,使用 .gdshader 副檔名保存。
這個類由 ShaderMaterial 使用,能夠讓你編寫渲染可視專案或更新粒子資訊時的自訂行為。詳細解釋和用法請參考下列教學連結。
教學
屬性
|
方法
get_default_texture_parameter(name: StringName, index: int = 0) const |
|
get_mode() const |
|
get_shader_uniform_list(get_groups: bool = false) |
|
void |
|
void |
set_default_texture_parameter(name: StringName, texture: Texture, index: int = 0) |
void |
set_include_path(path: String) |
列舉
enum Mode: 🔗
Mode MODE_SPATIAL = 0
用於繪製所有 3D 物件的模式。
Mode MODE_CANVAS_ITEM = 1
用於繪製所有 2D 物件的模式。
Mode MODE_PARTICLES = 2
用於基於每個粒子計算粒子資訊的模式。不用於繪圖。
Mode MODE_SKY = 3
用於繪製天空的模式。僅適用於附加到 Sky 對象的著色器。
Mode MODE_FOG = 4
用於設定體積霧效果的顏色和密度的模式。
Mode MODE_TEXTURE_BLIT = 5
用於通過位塊傳輸(blit)呼叫繪製到 DrawableTexture 資源的模式。
屬性說明
返回使用者編寫的著色器程式碼,而不是內部使用的完整生成程式碼。
方法說明
Texture get_default_texture_parameter(name: StringName, index: int = 0) const 🔗
返回被設定為指定參數的預設值的紋理。
注意:name 必須與程式碼中的 uniform 名稱完全配對。
注意:如果使用取樣器陣列,則使用 index 存取指定的紋理。
返回著色器的著色器模式。
Array get_shader_uniform_list(get_groups: bool = false) 🔗
回傳可以賦值給 ShaderMaterial 的著色器 uniform 清單,可用於 ShaderMaterial.set_shader_parameter() 和 ShaderMaterial.get_shader_parameter()。回傳的參數包含在字典內,與 Object.get_property_list() 回傳的格式類似。
如果參數 get_groups 為 true,則清單中還會包含參數分組提示。
void inspect_native_shader_code() 🔗
僅在編輯器中執行時可用。打開一個彈出視窗,其中視覺化生成的著色器程式碼,包括所有變體和內部著色器程式碼。另見 Material.inspect_native_shader_code()。
void set_default_texture_parameter(name: StringName, texture: Texture, index: int = 0) 🔗
設定要與紋理 uniform 一起使用的預設紋理。如果未在 ShaderMaterial 中設定紋理,則使用該預設值。
注意:name 必須與程式碼中的 uniform 名稱完全配對。
注意:如果使用取樣器陣列,則使用 index 存取指定的紋理。
void set_include_path(path: String) 🔗
Sets the include path for this shader. Used only if the shader does not have a resource path set, for example when created by code.