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...
CanvasTexture
繼承: Texture2D < Texture < Resource < RefCounted < Object
用於 2D 渲染的紋理,帶有可選的法線和鏡面貼圖。
說明
CanvasTexture 是用於 2D 渲染的 ImageTexture 的替代品。它允許在任何繼承自 CanvasItem 的節點中使用法線貼圖和鏡面貼圖。CanvasTexture 還允許獨立於節點的屬性(或專案設定)覆蓋紋理的過濾模式和重複模式。
注意:CanvasTexture 不能在 3D 中使用。當套用至任何 VisualInstance3D,例如 Sprite3D 或 Decal 時,它將無法正確顯示。對於 3D 中基於物理的材質,請改用 BaseMaterial3D。
教學
屬性
resource_local_to_scene |
|
|
|
||
|
||
|
||
|
屬性說明
要使用的漫反射(顏色)紋理。這是你在大多數情況下要設定的主要紋理。
要使用的法線貼圖紋理。僅在有 Light2D 影響該 CanvasTexture 時才有可見的效果。
注意: Godot 期望使用 X+、Y+、Z+ 座標系,可參考 此頁 了解各引擎差異。
Color specular_color = Color(1, 1, 1, 1) 🔗
鏡面反射顏色的乘數。在確定反射顏色時,Light2D 的顏色也會被考慮在內。只有在 Light2D 影響到這個 CanvasTexture 時才有可見的效果。
float specular_shininess = 1.0 🔗
用於 Light2D 鏡面反射的鏡面指數。更高的值會產生更有光澤或更加“濕潤”的外觀,反射變得更區域,且整體上不太明顯。預設值為 1.0 ,將完全停用鏡面反射。只有在 Light2D 影響到這個 CanvasTexture 時才會有可見的效果。
用於 Light2D 鏡面反射的鏡面貼圖。這應該是一個灰度或彩色紋理,更亮的區域會產生更高的 specular_shininess 值。使用彩色 specular_texture 允許在每個通道的基礎上控制鏡面反射光澤度。僅當 Light2D 影響該 CanvasTexture 時才有可見的效果。
TextureFilter texture_filter = 0 🔗
void set_texture_filter(value: TextureFilter)
TextureFilter get_texture_filter()
繪製該 CanvasTexture 時所使用的紋理篩選模式。
TextureRepeat texture_repeat = 0 🔗
void set_texture_repeat(value: TextureRepeat)
TextureRepeat get_texture_repeat()
繪製該 CanvasTexture 時所使用的紋理重複模式。