2018-09-04 11:30:04 +02:00
|
|
|
/**************************************************************************/
|
2022-08-18 11:09:22 +02:00
|
|
|
/* particle_process_material.h */
|
2018-09-04 11:30:04 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2022-08-18 11:09:22 +02:00
|
|
|
#ifndef PARTICLE_PROCESS_MATERIAL_H
|
|
|
|
#define PARTICLE_PROCESS_MATERIAL_H
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-09-26 13:03:44 +02:00
|
|
|
#include "core/templates/rid.h"
|
2023-08-13 13:08:52 +02:00
|
|
|
#include "core/templates/self_list.h"
|
2023-10-27 15:36:48 +02:00
|
|
|
#include "scene/resources/curve_texture.h"
|
2022-09-26 13:03:44 +02:00
|
|
|
#include "scene/resources/material.h"
|
|
|
|
|
2020-09-06 14:18:10 +02:00
|
|
|
/*
|
|
|
|
TODO:
|
|
|
|
-Path following
|
|
|
|
-Emitter positions deformable by bones
|
|
|
|
-Proper trails
|
|
|
|
*/
|
|
|
|
|
2022-08-18 11:09:22 +02:00
|
|
|
class ParticleProcessMaterial : public Material {
|
|
|
|
GDCLASS(ParticleProcessMaterial, Material);
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum Parameter {
|
|
|
|
PARAM_INITIAL_LINEAR_VELOCITY,
|
|
|
|
PARAM_ANGULAR_VELOCITY,
|
|
|
|
PARAM_ORBIT_VELOCITY,
|
|
|
|
PARAM_LINEAR_ACCEL,
|
|
|
|
PARAM_RADIAL_ACCEL,
|
|
|
|
PARAM_TANGENTIAL_ACCEL,
|
|
|
|
PARAM_DAMPING,
|
|
|
|
PARAM_ANGLE,
|
|
|
|
PARAM_SCALE,
|
|
|
|
PARAM_HUE_VARIATION,
|
|
|
|
PARAM_ANIM_SPEED,
|
|
|
|
PARAM_ANIM_OFFSET,
|
2021-11-26 15:18:46 +01:00
|
|
|
PARAM_TURB_INFLUENCE_OVER_LIFE,
|
|
|
|
PARAM_TURB_VEL_INFLUENCE,
|
|
|
|
PARAM_TURB_INIT_DISPLACEMENT,
|
2023-08-13 13:08:52 +02:00
|
|
|
PARAM_RADIAL_VELOCITY,
|
|
|
|
PARAM_DIRECTIONAL_VELOCITY,
|
|
|
|
PARAM_SCALE_OVER_VELOCITY,
|
2018-09-04 11:30:04 +02:00
|
|
|
PARAM_MAX
|
|
|
|
};
|
|
|
|
|
2021-08-18 15:50:38 +02:00
|
|
|
// When extending, make sure not to overflow the size of the MaterialKey below.
|
2020-12-05 00:35:57 +01:00
|
|
|
enum ParticleFlags {
|
|
|
|
PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY,
|
|
|
|
PARTICLE_FLAG_ROTATE_Y,
|
|
|
|
PARTICLE_FLAG_DISABLE_Z,
|
2023-08-13 13:08:52 +02:00
|
|
|
PARTICLE_FLAG_DAMPING_AS_FRICTION,
|
2020-12-05 00:35:57 +01:00
|
|
|
PARTICLE_FLAG_MAX
|
2018-09-04 11:30:04 +02:00
|
|
|
};
|
|
|
|
|
2021-08-18 15:50:38 +02:00
|
|
|
// When extending, make sure not to overflow the size of the MaterialKey below.
|
2018-09-04 11:30:04 +02:00
|
|
|
enum EmissionShape {
|
|
|
|
EMISSION_SHAPE_POINT,
|
|
|
|
EMISSION_SHAPE_SPHERE,
|
2021-11-27 23:28:53 +01:00
|
|
|
EMISSION_SHAPE_SPHERE_SURFACE,
|
2018-09-04 11:30:04 +02:00
|
|
|
EMISSION_SHAPE_BOX,
|
|
|
|
EMISSION_SHAPE_POINTS,
|
|
|
|
EMISSION_SHAPE_DIRECTED_POINTS,
|
2021-07-11 15:45:21 +02:00
|
|
|
EMISSION_SHAPE_RING,
|
2020-01-16 10:59:01 +01:00
|
|
|
EMISSION_SHAPE_MAX
|
2018-09-04 11:30:04 +02:00
|
|
|
};
|
|
|
|
|
2021-08-18 15:50:38 +02:00
|
|
|
// When extending, make sure not to overflow the size of the MaterialKey below.
|
2020-09-06 14:18:10 +02:00
|
|
|
enum SubEmitterMode {
|
|
|
|
SUB_EMITTER_DISABLED,
|
|
|
|
SUB_EMITTER_CONSTANT,
|
|
|
|
SUB_EMITTER_AT_END,
|
|
|
|
SUB_EMITTER_AT_COLLISION,
|
|
|
|
SUB_EMITTER_MAX
|
|
|
|
};
|
|
|
|
|
2022-05-20 23:59:13 +02:00
|
|
|
// When extending, make sure not to overflow the size of the MaterialKey below.
|
|
|
|
enum CollisionMode {
|
|
|
|
COLLISION_DISABLED,
|
|
|
|
COLLISION_RIGID,
|
|
|
|
COLLISION_HIDE_ON_CONTACT,
|
|
|
|
COLLISION_MAX
|
|
|
|
};
|
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
private:
|
2023-08-13 13:08:52 +02:00
|
|
|
struct MaterialKey {
|
|
|
|
// The bit size of the struct must be kept below or equal to 64 bits.
|
2021-08-18 15:50:38 +02:00
|
|
|
// Consider this when extending ParticleFlags, EmissionShape, or SubEmitterMode.
|
2023-08-13 13:08:52 +02:00
|
|
|
uint64_t texture_mask : PARAM_MAX;
|
|
|
|
uint64_t texture_color : 1;
|
2023-10-27 01:02:23 +02:00
|
|
|
uint64_t particle_flags : PARTICLE_FLAG_MAX;
|
2023-08-13 13:08:52 +02:00
|
|
|
uint64_t emission_shape : 3;
|
|
|
|
uint64_t invalid_key : 1;
|
|
|
|
uint64_t has_emission_color : 1;
|
|
|
|
uint64_t sub_emitter : 2;
|
|
|
|
uint64_t attractor_enabled : 1;
|
|
|
|
uint64_t collision_mode : 2;
|
|
|
|
uint64_t collision_scale : 1;
|
|
|
|
uint64_t turbulence_enabled : 1;
|
|
|
|
uint64_t limiter_curve : 1;
|
|
|
|
uint64_t alpha_curve : 1;
|
|
|
|
uint64_t emission_curve : 1;
|
|
|
|
uint64_t has_initial_ramp : 1;
|
2023-10-27 15:36:48 +02:00
|
|
|
uint64_t orbit_uses_curve_xyz : 1;
|
2023-08-13 13:08:52 +02:00
|
|
|
|
|
|
|
MaterialKey() {
|
|
|
|
memset(this, 0, sizeof(MaterialKey));
|
|
|
|
}
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
static uint32_t hash(const MaterialKey &p_key) {
|
2023-08-13 13:08:52 +02:00
|
|
|
return hash_djb2_buffer((const uint8_t *)&p_key, sizeof(MaterialKey));
|
2022-05-13 15:04:37 +02:00
|
|
|
}
|
|
|
|
bool operator==(const MaterialKey &p_key) const {
|
2023-08-13 13:08:52 +02:00
|
|
|
return memcmp(this, &p_key, sizeof(MaterialKey)) == 0;
|
2022-05-13 15:04:37 +02:00
|
|
|
}
|
2018-09-04 11:30:04 +02:00
|
|
|
bool operator<(const MaterialKey &p_key) const {
|
2023-08-13 13:08:52 +02:00
|
|
|
return memcmp(this, &p_key, sizeof(MaterialKey)) < 0;
|
2018-09-04 11:30:04 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ShaderData {
|
|
|
|
RID shader;
|
2021-02-09 18:24:36 +01:00
|
|
|
int users = 0;
|
2018-09-04 11:30:04 +02:00
|
|
|
};
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
static HashMap<MaterialKey, ShaderData, MaterialKey> shader_map;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
MaterialKey current_key;
|
|
|
|
|
|
|
|
_FORCE_INLINE_ MaterialKey _compute_key() const {
|
|
|
|
MaterialKey mk;
|
|
|
|
|
|
|
|
mk.texture_color = color_ramp.is_valid() ? 1 : 0;
|
|
|
|
mk.emission_shape = emission_shape;
|
|
|
|
mk.has_emission_color = emission_shape >= EMISSION_SHAPE_POINTS && emission_color_texture.is_valid();
|
2020-09-06 14:18:10 +02:00
|
|
|
mk.sub_emitter = sub_emitter_mode;
|
2022-05-20 23:59:13 +02:00
|
|
|
mk.collision_mode = collision_mode;
|
2020-10-08 02:29:49 +02:00
|
|
|
mk.attractor_enabled = attractor_interaction_enabled;
|
|
|
|
mk.collision_scale = collision_scale;
|
2022-08-02 15:41:14 +02:00
|
|
|
mk.turbulence_enabled = turbulence_enabled;
|
2023-08-13 13:08:52 +02:00
|
|
|
mk.limiter_curve = velocity_limit_curve.is_valid() ? 1 : 0;
|
|
|
|
mk.alpha_curve = alpha_curve.is_valid() ? 1 : 0;
|
|
|
|
mk.emission_curve = emission_curve.is_valid() ? 1 : 0;
|
|
|
|
mk.has_initial_ramp = color_initial_ramp.is_valid() ? 1 : 0;
|
2023-10-27 15:36:48 +02:00
|
|
|
CurveXYZTexture *texture = Object::cast_to<CurveXYZTexture>(tex_parameters[PARAM_ORBIT_VELOCITY].ptr());
|
|
|
|
mk.orbit_uses_curve_xyz = texture ? 1 : 0;
|
2023-08-13 13:08:52 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < PARAM_MAX; i++) {
|
|
|
|
if (tex_parameters[i].is_valid()) {
|
|
|
|
mk.texture_mask |= ((uint64_t)1 << i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < PARTICLE_FLAG_MAX; i++) {
|
|
|
|
if (particle_flags[i]) {
|
|
|
|
mk.particle_flags |= ((uint64_t)1 << i);
|
|
|
|
}
|
|
|
|
}
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
return mk;
|
|
|
|
}
|
|
|
|
|
2020-02-26 11:28:13 +01:00
|
|
|
static Mutex material_mutex;
|
2022-08-18 11:09:22 +02:00
|
|
|
static SelfList<ParticleProcessMaterial>::List *dirty_materials;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
struct ShaderNames {
|
2019-03-04 23:45:53 +01:00
|
|
|
StringName direction;
|
2018-09-04 11:30:04 +02:00
|
|
|
StringName spread;
|
|
|
|
StringName flatness;
|
2021-07-13 19:46:27 +02:00
|
|
|
StringName initial_linear_velocity_min;
|
|
|
|
StringName initial_angle_min;
|
|
|
|
StringName angular_velocity_min;
|
|
|
|
StringName orbit_velocity_min;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName radial_velocity_min;
|
2021-07-13 19:46:27 +02:00
|
|
|
StringName linear_accel_min;
|
|
|
|
StringName radial_accel_min;
|
|
|
|
StringName tangent_accel_min;
|
|
|
|
StringName damping_min;
|
|
|
|
StringName scale_min;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName scale_over_velocity_min;
|
2021-07-13 19:46:27 +02:00
|
|
|
StringName hue_variation_min;
|
|
|
|
StringName anim_speed_min;
|
|
|
|
StringName anim_offset_min;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName directional_velocity_min;
|
2021-07-13 19:46:27 +02:00
|
|
|
|
|
|
|
StringName initial_linear_velocity_max;
|
|
|
|
StringName initial_angle_max;
|
|
|
|
StringName angular_velocity_max;
|
|
|
|
StringName orbit_velocity_max;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName radial_velocity_max;
|
2021-07-13 19:46:27 +02:00
|
|
|
StringName linear_accel_max;
|
|
|
|
StringName radial_accel_max;
|
|
|
|
StringName tangent_accel_max;
|
|
|
|
StringName damping_max;
|
|
|
|
StringName scale_max;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName scale_over_velocity_max;
|
2021-07-13 19:46:27 +02:00
|
|
|
StringName hue_variation_max;
|
|
|
|
StringName anim_speed_max;
|
|
|
|
StringName anim_offset_max;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName directional_velocity_max;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
StringName angle_texture;
|
|
|
|
StringName angular_velocity_texture;
|
|
|
|
StringName orbit_velocity_texture;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName radial_velocity_texture;
|
2018-09-04 11:30:04 +02:00
|
|
|
StringName linear_accel_texture;
|
|
|
|
StringName radial_accel_texture;
|
|
|
|
StringName tangent_accel_texture;
|
|
|
|
StringName damping_texture;
|
|
|
|
StringName scale_texture;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName scale_over_velocity_texture;
|
2018-09-04 11:30:04 +02:00
|
|
|
StringName hue_variation_texture;
|
|
|
|
StringName anim_speed_texture;
|
|
|
|
StringName anim_offset_texture;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName velocity_limiter_texture;
|
|
|
|
StringName directional_velocity_texture;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
StringName color;
|
|
|
|
StringName color_ramp;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName alpha_ramp;
|
|
|
|
StringName emission_ramp;
|
2021-11-23 13:50:35 +01:00
|
|
|
StringName color_initial_ramp;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName velocity_limit_curve;
|
|
|
|
StringName velocity_pivot;
|
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
StringName emission_sphere_radius;
|
|
|
|
StringName emission_box_extents;
|
|
|
|
StringName emission_texture_point_count;
|
|
|
|
StringName emission_texture_points;
|
|
|
|
StringName emission_texture_normal;
|
|
|
|
StringName emission_texture_color;
|
2021-07-11 15:45:21 +02:00
|
|
|
StringName emission_ring_axis;
|
|
|
|
StringName emission_ring_height;
|
|
|
|
StringName emission_ring_radius;
|
|
|
|
StringName emission_ring_inner_radius;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName emission_shape_offset;
|
|
|
|
StringName emission_shape_scale;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-08-02 15:41:14 +02:00
|
|
|
StringName turbulence_enabled;
|
2021-11-26 15:18:46 +01:00
|
|
|
StringName turbulence_noise_strength;
|
|
|
|
StringName turbulence_noise_scale;
|
|
|
|
StringName turbulence_noise_speed;
|
|
|
|
StringName turbulence_noise_speed_random;
|
|
|
|
StringName turbulence_influence_over_life;
|
|
|
|
StringName turbulence_influence_min;
|
|
|
|
StringName turbulence_influence_max;
|
|
|
|
StringName turbulence_initial_displacement_min;
|
|
|
|
StringName turbulence_initial_displacement_max;
|
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
StringName gravity;
|
2023-08-13 13:08:52 +02:00
|
|
|
StringName inherit_emitter_velocity_ratio;
|
2019-07-15 06:48:20 +02:00
|
|
|
|
|
|
|
StringName lifetime_randomness;
|
2020-09-06 14:18:10 +02:00
|
|
|
|
|
|
|
StringName sub_emitter_frequency;
|
|
|
|
StringName sub_emitter_amount_at_end;
|
2022-09-24 14:22:37 +02:00
|
|
|
StringName sub_emitter_amount_at_collision;
|
2020-09-06 14:18:10 +02:00
|
|
|
StringName sub_emitter_keep_velocity;
|
2020-10-08 02:29:49 +02:00
|
|
|
|
|
|
|
StringName collision_friction;
|
|
|
|
StringName collision_bounce;
|
2018-09-04 11:30:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static ShaderNames *shader_names;
|
|
|
|
|
2022-08-18 11:09:22 +02:00
|
|
|
SelfList<ParticleProcessMaterial> element;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
void _update_shader();
|
|
|
|
_FORCE_INLINE_ void _queue_shader_change();
|
|
|
|
_FORCE_INLINE_ bool _is_shader_dirty() const;
|
|
|
|
|
2019-03-04 23:45:53 +01:00
|
|
|
Vector3 direction;
|
2022-05-02 16:28:25 +02:00
|
|
|
float spread = 0.0f;
|
|
|
|
float flatness = 0.0f;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-10-01 21:09:22 +02:00
|
|
|
float params_min[PARAM_MAX] = {};
|
|
|
|
float params_max[PARAM_MAX] = {};
|
|
|
|
float params[PARAM_MAX] = {};
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> tex_parameters[PARAM_MAX];
|
2018-09-04 11:30:04 +02:00
|
|
|
Color color;
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> color_ramp;
|
2023-08-13 13:08:52 +02:00
|
|
|
Ref<Texture2D> alpha_curve;
|
|
|
|
Ref<Texture2D> emission_curve;
|
2021-11-23 13:50:35 +01:00
|
|
|
Ref<Texture2D> color_initial_ramp;
|
2023-08-13 13:08:52 +02:00
|
|
|
Ref<Texture2D> velocity_limit_curve;
|
|
|
|
|
|
|
|
bool directional_velocity_global = false;
|
|
|
|
Vector3 velocity_pivot;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2020-12-05 00:35:57 +01:00
|
|
|
bool particle_flags[PARTICLE_FLAG_MAX];
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
EmissionShape emission_shape;
|
2022-05-02 16:28:25 +02:00
|
|
|
float emission_sphere_radius = 0.0f;
|
2018-09-04 11:30:04 +02:00
|
|
|
Vector3 emission_box_extents;
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> emission_point_texture;
|
|
|
|
Ref<Texture2D> emission_normal_texture;
|
|
|
|
Ref<Texture2D> emission_color_texture;
|
2021-07-11 15:45:21 +02:00
|
|
|
Vector3 emission_ring_axis;
|
2022-05-02 16:28:25 +02:00
|
|
|
real_t emission_ring_height = 0.0f;
|
|
|
|
real_t emission_ring_radius = 0.0f;
|
|
|
|
real_t emission_ring_inner_radius = 0.0f;
|
2021-02-09 18:24:36 +01:00
|
|
|
int emission_point_count = 1;
|
2023-08-13 13:08:52 +02:00
|
|
|
Vector3 emission_shape_offset;
|
|
|
|
Vector3 emission_shape_scale;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
bool anim_loop = false;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-08-02 15:41:14 +02:00
|
|
|
bool turbulence_enabled;
|
2021-11-26 15:18:46 +01:00
|
|
|
Vector3 turbulence_noise_speed;
|
|
|
|
Ref<Texture2D> turbulence_color_ramp;
|
|
|
|
float turbulence_noise_strength = 0.0f;
|
|
|
|
float turbulence_noise_scale = 0.0f;
|
|
|
|
float turbulence_noise_speed_random = 0.0f;
|
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
Vector3 gravity;
|
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
double lifetime_randomness = 0.0;
|
2023-08-13 13:08:52 +02:00
|
|
|
double inherit_emitter_velocity_ratio = 0.0;
|
2019-07-15 06:48:20 +02:00
|
|
|
|
2020-09-06 14:18:10 +02:00
|
|
|
SubEmitterMode sub_emitter_mode;
|
2022-05-02 16:28:25 +02:00
|
|
|
double sub_emitter_frequency = 0.0;
|
|
|
|
int sub_emitter_amount_at_end = 0;
|
2022-09-24 14:22:37 +02:00
|
|
|
int sub_emitter_amount_at_collision = 0;
|
2022-05-02 16:28:25 +02:00
|
|
|
bool sub_emitter_keep_velocity = false;
|
2018-09-04 11:30:04 +02:00
|
|
|
//do not save emission points here
|
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
bool attractor_interaction_enabled = false;
|
2022-05-20 23:59:13 +02:00
|
|
|
CollisionMode collision_mode;
|
2022-05-02 16:28:25 +02:00
|
|
|
bool collision_scale = false;
|
|
|
|
float collision_friction = 0.0f;
|
|
|
|
float collision_bounce = 0.0f;
|
2020-10-08 02:29:49 +02:00
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2022-08-12 22:57:11 +02:00
|
|
|
void _validate_property(PropertyInfo &p_property) const;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
public:
|
2019-03-04 23:45:53 +01:00
|
|
|
void set_direction(Vector3 p_direction);
|
|
|
|
Vector3 get_direction() const;
|
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
void set_spread(float p_spread);
|
|
|
|
float get_spread() const;
|
|
|
|
|
|
|
|
void set_flatness(float p_flatness);
|
|
|
|
float get_flatness() const;
|
|
|
|
|
2023-08-13 13:08:52 +02:00
|
|
|
void set_velocity_pivot(const Vector3 &p_pivot);
|
|
|
|
Vector3 get_velocity_pivot();
|
|
|
|
|
2021-07-13 19:46:27 +02:00
|
|
|
void set_param_min(Parameter p_param, float p_value);
|
|
|
|
float get_param_min(Parameter p_param) const;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2021-07-13 19:46:27 +02:00
|
|
|
void set_param_max(Parameter p_param, float p_value);
|
|
|
|
float get_param_max(Parameter p_param) const;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
void set_param_texture(Parameter p_param, const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_param_texture(Parameter p_param) const;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2023-08-13 13:08:52 +02:00
|
|
|
void set_velocity_limit_curve(const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_velocity_limit_curve() const;
|
|
|
|
|
|
|
|
void set_alpha_curve(const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_alpha_curve() const;
|
2018-09-04 11:30:04 +02:00
|
|
|
void set_color(const Color &p_color);
|
|
|
|
Color get_color() const;
|
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
void set_color_ramp(const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_color_ramp() const;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2021-11-23 13:50:35 +01:00
|
|
|
void set_color_initial_ramp(const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_color_initial_ramp() const;
|
|
|
|
|
2023-08-13 13:08:52 +02:00
|
|
|
void set_emission_curve(const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_emission_curve() const;
|
|
|
|
|
2020-12-05 00:35:57 +01:00
|
|
|
void set_particle_flag(ParticleFlags p_particle_flag, bool p_enable);
|
|
|
|
bool get_particle_flag(ParticleFlags p_particle_flag) const;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
|
|
|
void set_emission_shape(EmissionShape p_shape);
|
2021-08-12 16:07:47 +02:00
|
|
|
void set_emission_sphere_radius(real_t p_radius);
|
2018-09-04 11:30:04 +02:00
|
|
|
void set_emission_box_extents(Vector3 p_extents);
|
2019-06-11 20:43:37 +02:00
|
|
|
void set_emission_point_texture(const Ref<Texture2D> &p_points);
|
|
|
|
void set_emission_normal_texture(const Ref<Texture2D> &p_normals);
|
|
|
|
void set_emission_color_texture(const Ref<Texture2D> &p_colors);
|
2021-07-11 15:45:21 +02:00
|
|
|
void set_emission_ring_axis(Vector3 p_axis);
|
2021-08-12 16:07:47 +02:00
|
|
|
void set_emission_ring_height(real_t p_height);
|
|
|
|
void set_emission_ring_radius(real_t p_radius);
|
|
|
|
void set_emission_ring_inner_radius(real_t p_radius);
|
2018-09-04 11:30:04 +02:00
|
|
|
void set_emission_point_count(int p_count);
|
|
|
|
|
|
|
|
EmissionShape get_emission_shape() const;
|
2021-08-12 16:07:47 +02:00
|
|
|
real_t get_emission_sphere_radius() const;
|
2018-09-04 11:30:04 +02:00
|
|
|
Vector3 get_emission_box_extents() const;
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> get_emission_point_texture() const;
|
|
|
|
Ref<Texture2D> get_emission_normal_texture() const;
|
|
|
|
Ref<Texture2D> get_emission_color_texture() const;
|
2021-07-11 15:45:21 +02:00
|
|
|
Vector3 get_emission_ring_axis() const;
|
2021-08-12 16:07:47 +02:00
|
|
|
real_t get_emission_ring_height() const;
|
|
|
|
real_t get_emission_ring_radius() const;
|
|
|
|
real_t get_emission_ring_inner_radius() const;
|
2018-09-04 11:30:04 +02:00
|
|
|
int get_emission_point_count() const;
|
|
|
|
|
2022-08-02 15:41:14 +02:00
|
|
|
void set_turbulence_enabled(bool p_turbulence_enabled);
|
2021-11-26 15:18:46 +01:00
|
|
|
void set_turbulence_noise_strength(float p_turbulence_noise_strength);
|
|
|
|
void set_turbulence_noise_scale(float p_turbulence_noise_scale);
|
|
|
|
void set_turbulence_noise_speed_random(float p_turbulence_noise_speed_random);
|
|
|
|
void set_turbulence_noise_speed(const Vector3 &p_turbulence_noise_speed);
|
|
|
|
|
2022-08-02 15:41:14 +02:00
|
|
|
bool get_turbulence_enabled() const;
|
2021-11-26 15:18:46 +01:00
|
|
|
float get_turbulence_noise_strength() const;
|
|
|
|
float get_turbulence_noise_scale() const;
|
|
|
|
float get_turbulence_noise_speed_random() const;
|
|
|
|
Vector3 get_turbulence_noise_speed() const;
|
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
void set_gravity(const Vector3 &p_gravity);
|
|
|
|
Vector3 get_gravity() const;
|
|
|
|
|
2021-08-12 16:07:47 +02:00
|
|
|
void set_lifetime_randomness(double p_lifetime);
|
|
|
|
double get_lifetime_randomness() const;
|
2019-07-15 06:48:20 +02:00
|
|
|
|
2023-08-13 13:08:52 +02:00
|
|
|
void set_inherit_velocity_ratio(double p_ratio);
|
|
|
|
double get_inherit_velocity_ratio();
|
|
|
|
|
2020-10-08 02:29:49 +02:00
|
|
|
void set_attractor_interaction_enabled(bool p_enable);
|
|
|
|
bool is_attractor_interaction_enabled() const;
|
|
|
|
|
2022-05-20 23:59:13 +02:00
|
|
|
void set_collision_mode(CollisionMode p_collision_mode);
|
|
|
|
CollisionMode get_collision_mode() const;
|
2020-10-08 02:29:49 +02:00
|
|
|
|
|
|
|
void set_collision_use_scale(bool p_scale);
|
|
|
|
bool is_collision_using_scale() const;
|
|
|
|
|
|
|
|
void set_collision_friction(float p_friction);
|
|
|
|
float get_collision_friction() const;
|
|
|
|
|
|
|
|
void set_collision_bounce(float p_bounce);
|
|
|
|
float get_collision_bounce() const;
|
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
static void init_shaders();
|
|
|
|
static void finish_shaders();
|
|
|
|
static void flush_changes();
|
|
|
|
|
2020-09-06 14:18:10 +02:00
|
|
|
void set_sub_emitter_mode(SubEmitterMode p_sub_emitter_mode);
|
|
|
|
SubEmitterMode get_sub_emitter_mode() const;
|
|
|
|
|
2021-08-12 16:07:47 +02:00
|
|
|
void set_sub_emitter_frequency(double p_frequency);
|
|
|
|
double get_sub_emitter_frequency() const;
|
2020-09-06 14:18:10 +02:00
|
|
|
|
|
|
|
void set_sub_emitter_amount_at_end(int p_amount);
|
|
|
|
int get_sub_emitter_amount_at_end() const;
|
|
|
|
|
2022-09-24 14:22:37 +02:00
|
|
|
void set_sub_emitter_amount_at_collision(int p_amount);
|
|
|
|
int get_sub_emitter_amount_at_collision() const;
|
|
|
|
|
2020-09-06 14:18:10 +02:00
|
|
|
void set_sub_emitter_keep_velocity(bool p_enable);
|
|
|
|
bool get_sub_emitter_keep_velocity() const;
|
|
|
|
|
2023-08-13 13:08:52 +02:00
|
|
|
void set_emission_shape_offset(const Vector3 &p_emission_shape_offset);
|
|
|
|
Vector3 get_emission_shape_offset() const;
|
|
|
|
|
|
|
|
void set_emission_shape_scale(const Vector3 &p_emission_shape_scale);
|
|
|
|
Vector3 get_emission_shape_scale() const;
|
|
|
|
|
2021-01-06 00:01:50 +01:00
|
|
|
virtual RID get_shader_rid() const override;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Shader::Mode get_shader_mode() const override;
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-08-18 11:09:22 +02:00
|
|
|
ParticleProcessMaterial();
|
|
|
|
~ParticleProcessMaterial();
|
2018-09-04 11:30:04 +02:00
|
|
|
};
|
|
|
|
|
2022-08-18 11:09:22 +02:00
|
|
|
VARIANT_ENUM_CAST(ParticleProcessMaterial::Parameter)
|
|
|
|
VARIANT_ENUM_CAST(ParticleProcessMaterial::ParticleFlags)
|
|
|
|
VARIANT_ENUM_CAST(ParticleProcessMaterial::EmissionShape)
|
|
|
|
VARIANT_ENUM_CAST(ParticleProcessMaterial::SubEmitterMode)
|
|
|
|
VARIANT_ENUM_CAST(ParticleProcessMaterial::CollisionMode)
|
2018-09-04 11:30:04 +02:00
|
|
|
|
2022-08-18 11:09:22 +02:00
|
|
|
#endif // PARTICLE_PROCESS_MATERIAL_H
|