godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.1k stars 21.18k forks source link

GPUParticles2D particles no longer move with consistent velocity #84821

Open gokiburikin opened 1 year ago

gokiburikin commented 1 year ago

Godot version

v4.2.beta5.official [4c96e9676]

System information

Godot v4.2.beta5 - Windows 10.0.19044 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970 (NVIDIA; 31.0.15.3623) - Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz (16 Threads)

Issue description

GPUParticles2D with Disable Z enabled no longer move at a consistent velocity in 2D. In 3.5 these settings ensure particles move consistently over their lifetime, but in 4.x they appear to ignore Disable Z and move into the background or ignore the initial velocity parameters.

Comparison video (4.2 on top, 3.5.2 on bottom)

https://github.com/godotengine/godot/assets/3820082/3fb9c1b2-f725-4ee7-8162-7063e87170f7

Steps to reproduce

Attempt to create a GPUParticles2D with consistent movement by using Disable Z, Initial Velocity Min+Max 50, Spread 180. Particles appear to travel along Z anyway.

Minimal reproduction project

N/A

gokiburikin commented 1 year ago

For what it's worth this might be due to the function here https://github.com/godotengine/godot/blob/59457685c18e2d729eea50c751c11f049a7186f0/scene/resources/particle_process_material.cpp#L740-L761 which doesn't explictly create a 2D normalized vector in comparison to the 3.5 implementation https://github.com/godotengine/godot/blob/6c814135b69d4e703956bacc2073b4b179ff5a00/scene/resources/particles_material.cpp#L348-L354

I converted my particle material to shader code and changed the return to vec3(normalize(spread_direction.xy),0.0); and got the behaviour I expected, though I can't speak on if this is a good solution.

https://github.com/godotengine/godot/assets/3820082/078881b8-ff69-4922-8134-1de8f481c4b3

QbieShay commented 12 months ago

It is a good solution! I did a big refactor of particles for 4.2 so some things have been lost in translation. Are you interested in making the PR to fix this yourself? I can help you with that ^^

akien-mga commented 12 months ago

Had a quick look, the bug seems reproducible in both 4.1.3 and 4.2-beta6, so at least it doesn't seem to be a regression from the 4.2 refactoring.

But indeed it's an inconsistency with 3.x.