playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.69k stars 1.36k forks source link

Particles depend on camera angle #6632

Open LeXXik opened 5 months ago

LeXXik commented 5 months ago

When particles in a particle system set to align to motion, they should only consider their velocity. However, the camera's angle is also included, making them rotate on camera rotation.

Repro: https://playcanvas.com/project/1223253/overview/particle-system-issue

https://github.com/playcanvas/engine/assets/5677782/11119f11-5755-4aee-a132-efee20fa8061

kirelisaurimas commented 5 months ago

I think we should add https://api.playcanvas.com/classes/Engine.ParticleSystemComponent.html#particleNormal to that as well. you you set orientation to world there are something wrong with it. Please correct me if I am wrong, but this is not correct behavior. to reproduce it just rotate parent 180 degrees, and try play with world orientation particle normal parameters:

1) setting parent to 180, then particle normal x = -1 and z = -1. You will notice that increasing particles normal x to lower value than -1 (for example -16) will actually effect the orientation. 2) particle normal (1; 0; 0) and (1 ; 0 ; 0,0001) behavior is completely different when parent is rotated 180 degreess. 3) rotate object -90 degrees and on particles try find values that would make particles go correct direction you will find that is impossible regardless of values. this assuming that particles looks like fish or arrows, so you could see particles easily.

It might be connected with orientation problems. or might be new ones.

mvaligursky commented 5 months ago

Velocity is just a single vector. A quad needs to be aligned two two vectors, otherwise it could randomly rotate around the velocity. I think the other vector is related to the camera, so that the quad is visible by the camera. What else are you suggesting here @LeXXik ?

LeXXik commented 5 months ago

Hmm, to be honest I haven't studied the particle system implementation yet. There isn't anything else in addition to it. Just that the particles should maintain their orientation while in flight regardless of camera's angle. Can the particles not use camera vectors and use world up/forward instead when they are in the world space?