diff options
| author | Conor Lawton <conor.lawton1@gmail.com> | 2023-09-05 12:52:13 +0100 |
|---|---|---|
| committer | Conor Lawton <conor.lawton1@gmail.com> | 2023-09-08 20:01:57 +0100 |
| commit | 9ecafcc491515665430cb862f9ad59229b2c02cd (patch) | |
| tree | 299446406942ffdff04b7bfbfc57841f6541e65e | |
| parent | 75de1ca76871fdf7f5a9e081aa57ec0e33061107 (diff) | |
| download | redot-engine-9ecafcc491515665430cb862f9ad59229b2c02cd.tar.gz | |
Fixed z-billboard-y-velocity to correctly respect non-uniform scale instead of averaging scale
| -rw-r--r-- | drivers/gles3/shaders/particles_copy.glsl | 7 | ||||
| -rw-r--r-- | servers/rendering/renderer_rd/shaders/particles_copy.glsl | 7 |
2 files changed, 6 insertions, 8 deletions
diff --git a/drivers/gles3/shaders/particles_copy.glsl b/drivers/gles3/shaders/particles_copy.glsl index 774aa139b3..0bb8efc52d 100644 --- a/drivers/gles3/shaders/particles_copy.glsl +++ b/drivers/gles3/shaders/particles_copy.glsl @@ -84,7 +84,6 @@ void main() { } break; case TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY: { vec3 sv = velocity_flags.xyz - sort_direction * dot(sort_direction, velocity_flags.xyz); //screen velocity - float s = (length(txform[0]) + length(txform[1]) + length(txform[2])) / 3.0; if (length(sv) == 0.0) { sv = align_up; @@ -92,9 +91,9 @@ void main() { sv = normalize(sv); - txform[0].xyz = normalize(cross(sv, sort_direction)) * s; - txform[1].xyz = sv * s; - txform[2].xyz = sort_direction * s; + txform[0].xyz = normalize(cross(sv, sort_direction)) * length(txform[0]); + txform[1].xyz = sv * length(txform[1]); + txform[2].xyz = sort_direction * length(txform[2]); } break; } diff --git a/servers/rendering/renderer_rd/shaders/particles_copy.glsl b/servers/rendering/renderer_rd/shaders/particles_copy.glsl index 6a06979c2c..93c4d1009d 100644 --- a/servers/rendering/renderer_rd/shaders/particles_copy.glsl +++ b/servers/rendering/renderer_rd/shaders/particles_copy.glsl @@ -182,7 +182,6 @@ void main() { case TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY: { vec3 v = particles.data[particle].velocity; vec3 sv = v - params.sort_direction * dot(params.sort_direction, v); //screen velocity - float s = (length(txform[0]) + length(txform[1]) + length(txform[2])) / 3.0; if (length(sv) == 0) { sv = params.align_up; @@ -190,9 +189,9 @@ void main() { sv = normalize(sv); - txform[0].xyz = normalize(cross(sv, params.sort_direction)) * s; - txform[1].xyz = sv * s; - txform[2].xyz = params.sort_direction * s; + txform[0].xyz = normalize(cross(sv, params.sort_direction)) * length(txform[0]); + txform[1].xyz = sv * length(txform[1]); + txform[2].xyz = params.sort_direction * length(txform[2]); } break; } |
