Documentation
¶
Overview ¶
Package Particle provides a particle shader pipeline used for shading 2D and 3D particles.
Index ¶
- type Process
- type RenderMode
- type Shader
- func (*Shader[T]) Fragment(state Startup) Process
- func (*Shader[T]) Lighting(Process) struct{}
- func (*Shader[T]) Material(state Process) State
- func (s *Shader[T]) OnCreate(value reflect.Value)
- func (*Shader[T]) Pipeline() [3]string
- func (*Shader[T]) RenderMode() []RenderMode
- func (*Shader[T]) ShaderType() string
- type Startup
- type State
- func (State) AmountRatio() float.X
- func (State) Delta() float.X
- func (State) EmissionTransform() mat4.ColumnMajor
- func (State) EmitterVelocity() vec3.XYZ
- func (State) FlagEmitColor() uint.X
- func (State) FlagEmitCustom() uint.X
- func (State) FlagEmitPosition() uint.X
- func (State) FlagEmitRotScale() uint.X
- func (State) FlagEmitVelocity() uint.X
- func (State) Index() float.X
- func (State) InterpolateToEnd() float.X
- func (State) Lifetime() float.X
- func (State) Number() float.X
- func (State) RandomSeed() float.X
- func (State) UserData() [6]vec4.XYZW
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Process ¶
type Process State
func (Process) AttractorForce ¶
AttractorForce is the combined force of the attractors at the moment on that particle.
func (Process) CollisionDepth ¶
CollisionDepth is the length of the normal of the last collision. If there is no collision detected it is equal to 0.0.
func (Process) CollisionNormal ¶
CollisionNormal of the last collision. If there is no collision detected it is equal to (0.0, 0.0, 0.0).
type RenderMode ¶
type RenderMode string
const ( KeepData RenderMode = "keep_data" // Do not clear previous data on restart. DisableForce RenderMode = "disable_force" // Disable attractor force. DisableVelocity RenderMode = "disable_velocity" // Ignore VELOCITY value. CollisionUseScale RenderMode = "collision_use_scale" // Scale the particle's size for collisions. )
type Shader ¶
type Shader[T gdclass.Interface] struct { ShaderMaterial.Extension[T] }
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 unique because they are not used to draw the object itself; they are used to calculate particle properties, which are then used by a CanvasItem or Spatial shader. They contain two processor functions: start() and process().
Unlike other shader types, particle shaders keep the data that was output the previous frame. Therefore, particle shaders can be used for complex effects that take place over multiple frames.
func (*Shader[T]) RenderMode ¶
func (*Shader[T]) RenderMode() []RenderMode
func (*Shader[T]) ShaderType ¶
type Startup ¶
type Startup State
func (Startup) RestartColor ¶
RestartColor is true if particle is restarted, or emitted without a custom color (i.e. this particle was created by emit_subparticle() without the FLAG_EMIT_COLOR flag).
func (Startup) RestartCustom ¶
RestartCustom is true if particle is restarted, or emitted without a custom property (i.e. this particle was created by emit_subparticle() without the FLAG_EMIT_CUSTOM flag).
func (Startup) RestartPosition ¶
RestartPosition is true if particle is restarted, or emitted without a custom position (i.e. this particle was created by emit_subparticle() without the FLAG_EMIT_POSITION flag).
func (Startup) RestartRotScale ¶
RestartRotScale is true if particle is restarted, or emitted without a custom rotation or scale (i.e. this particle was created by emit_subparticle() without the FLAG_EMIT_ROT_SCALE flag).
func (Startup) RestartVelocity ¶
RestartVelocity is true if particle is restarted, or emitted without a custom velocity (i.e. this particle was created by emit_subparticle() without the FLAG_EMIT_VELOCITY flag).
type State ¶
type State struct { Active bool.X `gd:"ACTIVE"` // true when the particle is active, can be set false. Color vec4.RGBA `gd:"COLOR"` // Particle color, can be written to and accessed in mesh's vertex function. Velocity vec3.XYZ `gd:"VELOCITY"` // Particle velocity, can be modified. Transform mat4.ColumnMajor `gd:"TRANSFORM"` // Particle transform. Custom vec4.XYZW `gd:"CUSTOM"` // Custom particle data. Accessible from shader of mesh as INSTANCE_CUSTOM. Mass float.X `gd:"MASS"` // Particle mass, intended to be used with attractors. Equals 1.0 by default. EmitSubParticle func(xform mat4.ColumnMajor, velocity vec3.XYZ, color vec4.RGBA, custom vec4.XYZW, flags uint.X) bool.X `gd:"emit_subparticle"` }
func (State) AmountRatio ¶
AmountRatio value of amount_ratio (3D) property of Particles node.
func (State) EmissionTransform ¶
func (State) EmissionTransform() mat4.ColumnMajor
EmissionTransform (used for non-local systems).
func (State) EmitterVelocity ¶
EmitterVelocity is the Velocity of the Particles2D (3D) node.
func (State) FlagEmitColor ¶
FlagEmitColor for using on the last argument of emit_subparticle() function to assign a color to a new particle.
func (State) FlagEmitCustom ¶
FlagEmitCustom for using on the last argument of emit_subparticle() function to assign a custom value to a new particle.
func (State) FlagEmitPosition ¶
FlagEmitPosition for using on the last argument of emit_subparticle() function to assign a position to a new particle's transform.
func (State) FlagEmitRotScale ¶
FlagEmitRotScale for using on the last argument of emit_subparticle() function to assign a rotation and scale to a new particle's transform.
func (State) FlagEmitVelocity ¶
FlagEmitVelocity for using on the last argument of emit_subparticle() function to assign a velocity to a new particle.
func (State) InterpolateToEnd ¶
InterpolateToEnd Value of interp_to_end (3D) property of Particles node.