Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix particles not properly updated by their lifetime #45496

Merged
merged 1 commit into from
Feb 3, 2021

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Jan 27, 2021

Fixed several properties which gather from the texture in default Particles material that is not properly handled by lifetime_randomness. Also fixed in CPUParticles/CPUParticles2D.

Before:

particles_before

After:

particles_after

Fix #43485

Test Project:
Particles_3.2_CurveTest.zip

@Chaosus Chaosus added this to the 4.0 milestone Jan 27, 2021
@Chaosus Chaosus changed the title Fix particles not properly modified by their lifetime Fix particles not properly updated by their lifetime Jan 27, 2021
@akien-mga akien-mga requested a review from a team January 27, 2021 11:53
} else {
uint32_t alt_seed = p.seed;

p.time += local_delta;
p.custom[1] = p.time / lifetime;
tv = p.time / p.lifetime;

Copy link
Member

@lawnjelly lawnjelly Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should p.custom[1] be set as the same as tv too? Or is there something that assumes p.custom[1] is in relation to the unadjusted lifetime?

Copy link
Member Author

@Chaosus Chaosus Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its used in this code:

float base_angle = (parameters[PARAM_ANGLE] + tex_angle) * Math::lerp(1.0f, p.angle_rand, randomness[PARAM_ANGLE]);
			base_angle += p.custom[1] * lifetime * (parameters[PARAM_ANGULAR_VELOCITY] + tex_angular_velocity) * Math::lerp(1.0f, rand_from_seed(alt_seed) * 2.0f - 1.0f, randomness[PARAM_ANGULAR_VELOCITY]);
			p.rotation = Math::deg2rad(base_angle); //angle
			float animation_phase = (parameters[PARAM_ANIM_OFFSET] + tex_anim_offset) * Math::lerp(1.0f, p.anim_offset_rand, randomness[PARAM_ANIM_OFFSET]) + p.custom[1] * (parameters[PARAM_ANIM_SPEED] + tex_anim_speed) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_ANIM_SPEED]);
			p.custom[2] = animation_phase;

I'm not sure whether it's can be changed here so I used a temporary variable to avoid this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no idea either not that familiar with the particles, we'll see if anyone else chimes in.. Worst case though it wouldn't be bad to merge as is and this could be fixed in a separate PR if necessary.

@akien-mga akien-mga merged commit 7185a7c into godotengine:master Feb 3, 2021
@akien-mga
Copy link
Member

Thanks!

@Chaosus Chaosus deleted the fix_particles branch February 3, 2021 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Particles don't adjust curves to fit a randomized lifetime
3 participants