diff options
author | floppyhammer <tannhauser_chen@outlook.com> | 2022-02-02 11:49:54 +0800 |
---|---|---|
committer | floppyhammer <tannhauser_chen@outlook.com> | 2022-02-22 17:50:01 +0800 |
commit | 0d5472dd1aa1b5d790daf1c9164d48217c507c19 (patch) | |
tree | f74cf79ca463d7219b2f02c253bf360533405a7e /servers/rendering/renderer_rd/shaders | |
parent | c77348b4688b7c58b13d7fd59d8e54a242bb8829 (diff) |
Fix GPUParticles2D emission offset in global coords
Diffstat (limited to 'servers/rendering/renderer_rd/shaders')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/particles_copy.glsl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/servers/rendering/renderer_rd/shaders/particles_copy.glsl b/servers/rendering/renderer_rd/shaders/particles_copy.glsl index b991880cd9..afbd5a9caa 100644 --- a/servers/rendering/renderer_rd/shaders/particles_copy.glsl +++ b/servers/rendering/renderer_rd/shaders/particles_copy.glsl @@ -61,6 +61,8 @@ layout(push_constant, std430) uniform Params { uint lifetime_split; bool lifetime_reverse; bool copy_mode_2d; + + mat4 inv_emission_transform; } params; @@ -199,6 +201,12 @@ void main() { txform = txform * trail_bind_poses.data[part_ofs]; } + if (params.copy_mode_2d) { + // In global mode, bring 2D particles to local coordinates + // as they will be drawn with the node position as origin. + txform = params.inv_emission_transform * txform; + } + txform = transpose(txform); } else { txform = mat4(vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); //zero scale, becomes invisible |