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...
GPUParticles3D
繼承: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object
3D 粒子發射器。
說明
3D particle node used to create a variety of particle systems and effects. GPUParticles3D features an emitter that generates some number of particles at a given rate.
Use process_material to add a ParticleProcessMaterial to configure particle appearance and behavior. Alternatively, you can add a ShaderMaterial which will be applied to all particles.
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
capture_aabb() const |
|
void |
convert_from_particles(particles: Node) |
void |
emit_particle(xform: Transform3D, velocity: Vector3, color: Color, custom: Color, flags: int) |
get_draw_pass_mesh(pass: int) const |
|
void |
request_particles_process(process_time: float, process_time_residual: float = 0.0) |
void |
|
void |
set_draw_pass_mesh(pass: int, mesh: Mesh) |
訊號
finished() 🔗
Emitted when all active particles have finished processing. To immediately restart the emission cycle, call restart().
This signal is never emitted when one_shot is disabled, as particles will be emitted and processed continuously.
Note: For one_shot emitters, due to the particles being computed on the GPU, there may be a short period after receiving the signal during which setting emitting to true will not restart the emission cycle. This delay is avoided by instead calling restart().
列舉
enum DrawOrder: 🔗
DrawOrder DRAW_ORDER_INDEX = 0
粒子按發射順序繪製。
DrawOrder DRAW_ORDER_LIFETIME = 1
Particles are drawn in order of remaining lifetime. In other words, the particle with the highest lifetime is drawn at the front.
DrawOrder DRAW_ORDER_REVERSE_LIFETIME = 2
Particles are drawn in reverse order of remaining lifetime. In other words, the particle with the lowest lifetime is drawn at the front.
DrawOrder DRAW_ORDER_VIEW_DEPTH = 3
粒子按深度順序繪製。
enum EmitFlags: 🔗
EmitFlags EMIT_FLAG_POSITION = 1
粒子在指定位置開始。
EmitFlags EMIT_FLAG_ROTATION_SCALE = 2
粒子以指定的旋轉和縮放開始。
EmitFlags EMIT_FLAG_VELOCITY = 4
粒子從指定的速度向量開始,該向量定義了發射方向和速度。
EmitFlags EMIT_FLAG_COLOR = 8
粒子以指定的顏色開始。
EmitFlags EMIT_FLAG_CUSTOM = 16
粒子以指定的 CUSTOM 資料開始。
enum TransformAlign: 🔗
TransformAlign TRANSFORM_ALIGN_DISABLED = 0
Do not align particle transforms relative to the camera or velocity.
TransformAlign TRANSFORM_ALIGN_Z_BILLBOARD = 1
Align each particle's Z axis to face the camera.
TransformAlign TRANSFORM_ALIGN_Y_TO_VELOCITY = 2
Align each particle's Y axis to the velocity vector.
TransformAlign TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY = 3
Align each particle's Z axis to face the camera and Y axis to the velocity vector.
TransformAlign TRANSFORM_ALIGN_LOCAL_BILLBOARD = 4
Align each particle's Z axis to face the camera, while preserving a given axis (X or Y).
常數
MAX_DRAW_PASSES = 4 🔗
支援的最大繪製階段數。
屬性說明
The number of particles to emit in one emission cycle. The effective emission rate is (amount * amount_ratio) / lifetime particles per second. Higher values will increase GPU requirements, even if not all particles are visible at a given time or if amount_ratio is decreased.
Note: Changing this value will cause the particle system to restart. To avoid this, change amount_ratio instead.
The ratio of particles that should actually be emitted. If set to a value lower than 1.0, this will set the amount of emitted particles throughout the lifetime to amount * amount_ratio. Unlike changing amount, changing amount_ratio while emitting does not affect already-emitted particles and doesn't cause the particle system to restart. amount_ratio can be used to create effects that make the number of emitted particles vary over time.
Note: Reducing the amount_ratio has no performance benefit, since resources need to be allocated and processed for the total amount of particles regardless of the amount_ratio. If you don't intend to change the number of particles emitted while the particles are emitting, make sure amount_ratio is set to 1 and change amount to your liking instead.
float collision_base_size = 0.01 🔗
The base diameter for particle collision in meters. If particles appear to sink into the ground when colliding, increase this value. If particles appear to float when colliding, decrease this value. Only effective if ParticleProcessMaterial.collision_mode is ParticleProcessMaterial.COLLISION_RIGID or ParticleProcessMaterial.COLLISION_HIDE_ON_CONTACT.
Note: Particles always have a spherical collision shape.
Particle draw order.
Note: DRAW_ORDER_INDEX is the only option that supports motion vectors for effects like TAA. It is suggested to use this draw order if the particles are opaque to fix ghosting artifacts.
第一繪製階段所繪製的 Mesh。
第二繪製階段所繪製的 Mesh。
第三繪製階段所繪製的 Mesh。
第四繪製階段所繪製的 Mesh。
算繪粒子時的繪製階段數。
There is currently no description for this property. Please help us by contributing one!
If true, particles are being emitted. emitting can be used to start and stop particles from emitting. However, if one_shot is true setting emitting to true will not restart the emission cycle unless all active particles have finished processing. Use the finished signal to be notified once all active particles finish processing.
Note: For one_shot emitters, due to the particles being computed on the GPU, there may be a short period after receiving the finished signal during which setting this to true will not restart the emission cycle.
Tip: If your one_shot emitter needs to immediately restart emitting particles once finished signal is received, consider calling restart() instead of setting emitting.
每次發射之間的時間比。如果為 0,則粒子是連續發射的。如果為 1,則所有的粒子都同時發射。
粒子系統的畫面播放速率被固定為一個值。例如,將值更改為 2 會使粒子以每秒 2 影格的速度算繪。請注意,這並不會降低粒子系統本身的類比速度。
如果為 為true,則使用分數差異量 delta 計算,將具有更平滑的粒子顯示效果。
Causes all the particles in this node to interpolate towards the end of their lifetime.
Note: This only works when used with a ParticleProcessMaterial. It needs to be manually implemented for custom process shaders.
啟用粒子插值,當fixed_fps 低於螢幕更新率時,使粒子運動更平滑。
The amount of time each particle will exist (in seconds). The effective emission rate is (amount * amount_ratio) / lifetime particles per second.
如果為 true,則粒子使用父節點的座標空間(稱為局部座標)。這將導致粒子在移動或旋轉時沿著 GPUParticles3D 節點(及其父節點)移動和旋轉。如果為 false,則粒子使用全域座標;當移動或旋轉時,它們不會沿著 GPUParticles3D 節點(及其父節點)移動或旋轉。
If true, only the number of particles equal to amount will be emitted.
Amount of time to preprocess the particles before animation starts. Lets you start the animation some time after particles have started emitting.
Note: This can be very expensive if set to a high number as it requires running the particle shader a number of times equal to the fixed_fps (or 30, if fixed_fps is 0) for every second. In extreme cases it can even lead to a GPU crash due to the volume of work done in a single frame.
用於處理粒子的 Material 。可以是 ParticleProcessMaterial 或 ShaderMaterial 。
發出隨機率。
Sets the random seed used by the particle system. Only effective if use_fixed_seed is true.
速度縮放比例。0 的值可被用於暫停粒子。
NodePath sub_emitter = NodePath("") 🔗
Path to another GPUParticles3D node that will be used as a subemitter (see ParticleProcessMaterial.sub_emitter_mode). Subemitters can be used to achieve effects such as fireworks, sparks on collision, bubbles popping into water drops, and more.
Note: When sub_emitter is set, the target GPUParticles3D node will no longer emit particles on its own.
如果為 true,則使用網格蒙皮系統來啟用粒子尾跡。旨在與 RibbonTrailMesh 和 TubeTrailMesh 一起使用。
注意:還必須在粒子網格的材質上啟用 BaseMaterial3D.use_particle_trails。否則,將 trail_enabled 設定為 true 將無效。
注意:與 GPUParticles2D 不同,尾跡部分及其細分的數量是在 RibbonTrailMesh 或 TubeTrailMesh 的屬性中設定的。
代表粒子軌跡的時間量(以秒為單位)。僅當 trail_enabled 為 true 時有效。
TransformAlign transform_align = 0 🔗
void set_transform_align(value: TransformAlign)
TransformAlign get_transform_align()
The alignment of particles. Use this for billboarding and aligning to velocity.
ParticlesTransformAlignAxis transform_align_axis 🔗
void set_transform_align_axis(value: ParticlesTransformAlignAxis)
ParticlesTransformAlignAxis get_transform_align_axis()
When using transform align local billboard, which axis to use for the billboarding. Supports only X or Y.
ParticlesTransformAlignCustomSrc transform_align_channel_filter 🔗
void set_transform_align_channel_filter(value: ParticlesTransformAlignCustomSrc)
ParticlesTransformAlignCustomSrc get_transform_align_channel_filter()
In the case of billboarded particles, which custom channel to read from to calculate their angle.
If true, particles will use the same seed for every simulation using the seed defined in seed. This is useful for situations where the visual outcome should be consistent across replays, for example when using Movie Maker mode.
AABB visibility_aabb = AABB(-4, -4, -4, 8, 8, 8) 🔗
The AABB that determines the node's region which needs to be visible on screen for the particle system to be active. GeometryInstance3D.extra_cull_margin is added on each of the AABB's axes. Particle collisions and attraction will only occur within this area.
Grow the box if particles suddenly appear/disappear when the node enters/exits the screen. The AABB can be grown via code or with the Particles → Generate AABB editor tool.
Note: visibility_aabb is overridden by GeometryInstance3D.custom_aabb if that property is set to a non-default value.
方法說明
返回包含目前影格中所有活動粒子的軸對齊邊界框。
void convert_from_particles(particles: Node) 🔗
設定該節點的屬性以配對給定的 GPUParticles3D 節點,該給定節點已分配了一個 ParticleProcessMaterial。
void emit_particle(xform: Transform3D, velocity: Vector3, color: Color, custom: Color, flags: int) 🔗
Emits a single particle. Whether xform, velocity, color and custom are applied depends on the value of flags. See EmitFlags.
The default ParticleProcessMaterial will overwrite color and use the contents of custom as (rotation, age, animation, lifetime).
Note: emit_particle() is only supported on the Forward+ and Mobile rendering methods, not Compatibility.
Mesh get_draw_pass_mesh(pass: int) const 🔗
返回在索引 pass 處繪製的 Mesh 。
void request_particles_process(process_time: float, process_time_residual: float = 0.0) 🔗
Requests the particles to process for extra process time during a single frame.
process_time defines the time that the particles will process while emitting is on. process_time_residual defines the time that particles will process with emitting turned off for the simulation. When combined with speed_scale set to 0.0, this is useful to be able to seek a particle system timeline.
void restart(keep_seed: bool = false) 🔗
Restarts the particle emission cycle, clearing existing particles. To avoid particles vanishing from the viewport, wait for the finished signal before calling.
Note: The finished signal is only emitted by one_shot emitters.
If keep_seed is true, the current random seed will be preserved. Useful for seeking and playback.
void set_draw_pass_mesh(pass: int, mesh: Mesh) 🔗
設定在索引 pass 處繪製的 Mesh 。