Particle shaders

Particle shaders are a special type of vertex shader that runs before the object is drawn. They are used for calculating material properties such as color, position, and rotation. They are drawn with any regular material for CanvasItem or Spatial, depending on whether they are 2D or 3D.




Particle shaders are only available in the GLES3 backend. If you need particles in GLES2, use CPUParticles.

Render modes

Render mode 描述
keep_data 不要在重启时清除以前的数据。
disable_force 禁用吸引力。(目前在3.1版本中未实现)
disable_velocity 忽略**VELOCITY**值。


Values marked as "in" are read-only. Values marked as "out" are for optional writing and will not necessarily contain sensible values. Values marked as "inout" provide a sensible default value, and can optionally be written to. Samplers are not subjects of writing and they are not marked.

Global built-ins

Global built-ins are available everywhere, including custom functions.

内建的 描述
in float TIME 全球时间,以秒为单位。

Vertex built-ins


内建的 描述
inout vec4 COLOR Particle color, can be written to and accessed in mesh's vertex function.
inout vec3 VELOCITY 粒子速度,可以修改。
out float MASS Particle mass, use for attractors (not implemented in 3.1).
inout bool ACTIVE true when Particle is active, can be set to false.
in bool RESTART true when particle must restart (lifetime cycled).
inout vec4 CUSTOM 自定义粒子数据。可从网格着色器作为**实例化_自定义**访问。
inout mat4 TRANSFORM 粒子变换。
in float LIFETIME 粒子寿命。
in float DELTA 达美处理时间。
in uint NUMBER 排放开始后的唯一编号。
in int INDEX 颗粒指数(来自总颗粒)。
in mat4 EMISSION_TRANSFORM 发射器变换(用于非本地系统)。
in uint RANDOM_SEED 随机种子被用作随机的基础。