From 850be3d3e556092bcea5cbf8059378c3ca66b982 Mon Sep 17 00:00:00 2001 From: Brian Peiris <brianpeiris@gmail.com> Date: Fri, 2 Nov 2018 13:52:05 -0700 Subject: [PATCH] Minor shader refactor --- src/utils/media-highlight-frag.glsl | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/utils/media-highlight-frag.glsl b/src/utils/media-highlight-frag.glsl index 27efe3115..d47ac0b13 100644 --- a/src/utils/media-highlight-frag.glsl +++ b/src/utils/media-highlight-frag.glsl @@ -1,19 +1,10 @@ if (hubs_HighlightInteractorOne || hubs_HighlightInteractorTwo) { - float dist1, dist2; - - if (hubs_HighlightInteractorOne) { - dist1 = distance(hubs_WorldPosition, hubs_InteractorOnePos); - } - - if (hubs_HighlightInteractorTwo) { - dist2 = distance(hubs_WorldPosition, hubs_InteractorTwoPos); - } + float ratio = 0.0; if (hubs_EnableSweepingEffect) { float size = hubs_SweepParams.t - hubs_SweepParams.s; float line = mod(hubs_Time / 3000.0 * size, size * 2.0) + hubs_SweepParams.s - size / 2.0; - float ratio = 0.0; if (hubs_WorldPosition.y < line) { // Highlight with an sweeping gradient ratio = max(0.0, 1.0 - (line - hubs_WorldPosition.y) / size * 3.0); @@ -23,9 +14,11 @@ if (hubs_HighlightInteractorOne || hubs_HighlightInteractorTwo) { float pulse = sin(hubs_Time / 1000.0) + 1.0; // Highlight with a gradient falling off with distance. if (hubs_HighlightInteractorOne) { + float dist1 = distance(hubs_WorldPosition, hubs_InteractorOnePos); ratio += -min(1.0, pow(dist1 * (9.0 + 3.0 * pulse), 3.0)) + 1.0; } if (hubs_HighlightInteractorTwo) { + float dist2 = distance(hubs_WorldPosition, hubs_InteractorTwoPos); ratio += -min(1.0, pow(dist2 * (9.0 + 3.0 * pulse), 3.0)) + 1.0; } -- GitLab