Shader
继承: Resource < RefCounted < Object
派生: VisualShader
A shader implemented in the Godot shading language.
描述
A custom shader program implemented in the Godot shading language, saved with the .gdshader extension.
This class is used by a ShaderMaterial and allows you to write your own custom behavior for rendering visual items or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.
属性
方法
Texture | get_default_texture_parameter ( name: StringName, index: int = 0 ) const1 |
| Mode | get_mode ( ) const1 |
Array | get_shader_uniform_list ( get_groups: bool = false ) |
void | inspect_native_shader_code ( ) |
void | set_default_texture_parameter ( name: StringName, texture: Texture, index: int = 0 ) |
枚举
enum Mode:
Mode MODE_SPATIAL = 0
Mode used to draw all 3D objects.
Mode MODE_CANVAS_ITEM = 1
Mode used to draw all 2D objects.
Mode MODE_PARTICLES = 2
Mode used to calculate particle information on a per-particle basis. Not used for drawing.
Mode MODE_SKY = 3
Mode used for drawing skies. Only works with shaders attached to Sky objects.
Mode MODE_FOG = 4
Mode used for setting the color and density of volumetric fog effect.
属性说明
String code = ""
Returns the shader's code as the user has written it, not the full generated code used internally.
方法说明
Texture get_default_texture_parameter ( name: StringName, index: int = 0 ) const1
Returns the texture that is set as default for the specified parameter.
Note: name must match the name of the uniform in the code exactly.
Note: If the sampler array is used use index to access the specified texture.
Returns the shader mode for the shader.
Array get_shader_uniform_list ( get_groups: bool = false )
Get the list of shader uniforms that can be assigned to a ShaderMaterial, for use with ShaderMaterial.set_shader_parameter and ShaderMaterial.get_shader_parameter. The parameters returned are contained in dictionaries in a similar format to the ones returned by Object.get_property_list.
If argument get_groups is true, parameter grouping hints will be provided.
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 Material.inspect_native_shader_code.
void set_default_texture_parameter ( name: StringName, texture: Texture, index: int = 0 )
Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the ShaderMaterial.
Note: name must match the name of the uniform in the code exactly.
Note: If the sampler array is used use index to access the specified texture.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。