From 59828b4a86e65b98f1d1aff5a64435ba0ab69723 Mon Sep 17 00:00:00 2001 From: TheJackiMonster <thejackimonster@gmail.com> Date: Fri, 22 Jul 2022 10:47:37 +0200 Subject: [PATCH] Fixed spinning trails artifacts Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> --- projects/fire_works/shaders/trail.geom | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/projects/fire_works/shaders/trail.geom b/projects/fire_works/shaders/trail.geom index 47a5a2cb..02794347 100644 --- a/projects/fire_works/shaders/trail.geom +++ b/projects/fire_works/shaders/trail.geom @@ -54,22 +54,6 @@ void main() { return; } - vec3 positions [2]; - uint viewIndex = instanceIndex; - - if (viewIndex > startIndex) { - viewIndex--; - } - - for (uint i = 0; i < 2; i++) { - const uint index = (viewIndex + i) % points.length(); - - positions[i] = points[index].position; - } - - vec3 pos = positions[0]; - vec3 dir = normalize(cross(positions[1] - pos, pos - camera)); - const float trailFactor = mediumDensity / friction; for (uint i = 0; i < count; i++) { @@ -79,11 +63,9 @@ void main() { const vec3 position = points[index].position; const float size = points[index].size; + const vec3 velocity = points[index].velocity; - if (i > 0) { - dir = normalize(cross(position - pos, pos - camera)); - pos = position; - } + const vec3 dir = normalize(cross(abs(velocity), position - camera)); vec3 offset = dir * size; float density = trailFactor * (1.0f - u * u) / size; -- GitLab