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, 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 const |
|
_get_shader_rid() virtual 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 const 🔗
仅出于覆盖目的而暴露。你不能直接调用该函数。由各种编辑器工具内部使用。
RID _get_shader_rid() virtual const 🔗
仅出于覆盖目的而暴露。你不能直接调用该函数。由各种编辑器工具内部使用。用于访问 Material 的 Shader 的 RID。
Resource create_placeholder() const 🔗
创建该资源的占位符版本(PlaceholderMaterial)。
void inspect_native_shader_code() 🔗
Only available when running in the editor. Opens a popup that visualizes the generated shader code, including all variants and internal shader code. See also Shader.inspect_native_shader_code.