Shaders de partículas¶
Shaders de partículas são um tipo especial de shader de vértice executado antes de o objeto ser desenhado. Eles são usados para calcular as propriedades do material, como cor, posição e rotação. Eles são desenhados com qualquer material regular para CanvasItem ou Spatial, dependendo se são 2D ou 3D.
Particle shaders are unique because they are not used to draw the object itself; they are used to calculate particle properties, which are then used by the CanvasItem of Spatial shader. They contain only a vertex processor function that outputs multiple properties (see built-ins below).
Particle shaders use a transform feedback shader, which is a special type of vertex shader that runs on its own. It takes in data in a buffer like a regular vertex shader does, but it also outputs to data buffers instead of outputting to the fragment shader for pixel-processing. Because of this, transform feedback shaders can build on themselves each run, unlike other shaders that discard the data they have calculated once they draw to the frame buffer.
Nota
Particle shaders are only available in the GLES3 backend. If you need particles in GLES2, use CPUParticles.
Modos de renderização¶
Modo de renderização |
Descrição |
---|---|
keep_data |
Do not clear previous data on restart. |
disable_force |
Disable attractor force. (Not currently implemented in 3.1) |
disable_velocity |
Ignore VELOCITY value. |
Embutidos¶
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.
Built-ins globais¶
Global built-ins are available everywhere, including custom functions.
Embutido |
Descrição |
---|---|
in float TIME |
Global time, in seconds. |
Vertex embutidos¶
In order to use the COLOR
variable in a SpatialMaterial, set use_vertex_as_albedo
to true
. In a ShaderMaterial, access it with the COLOR
variable.
Embutido |
Descrição |
---|---|
inout vec4 COLOR |
Particle color, can be written to and accessed in mesh's vertex function. |
inout vec3 VELOCITY |
Particle velocity, can be modified. |
out float MASS |
Particle mass, use for attractors (not implemented in 3.1). |
inout bool ACTIVE |
|
in bool RESTART |
|
inout vec4 CUSTOM |
Custom particle data. Accessible from shader of mesh as INSTANCE_CUSTOM. |
inout mat4 TRANSFORM |
Transformação de partícula. |
in float LIFETIME |
Tempo de vida da partícula. |
in float DELTA |
Delta process time. |
in uint NUMBER |
Unique number since emission start. |
in int INDEX |
Particle index (from total particles). |
in mat4 EMISSION_TRANSFORM |
Emitter transform (used for non-local systems). |
in uint RANDOM_SEED |
Random seed used as base for random. |