Fixed z-billboard-y-velocity to correctly respect non-uniform scale instead of averaging scale

This commit is contained in:
Conor Lawton 2023-09-05 12:52:13 +01:00
parent 75de1ca768
commit 9ecafcc491
2 changed files with 6 additions and 8 deletions

View file

@ -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;
}

View file

@ -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;
}