From 8061d0a1ac1e3955d8260d4a6145701f786c029b Mon Sep 17 00:00:00 2001
From: Brian Peiris <brianpeiris@gmail.com>
Date: Fri, 2 Nov 2018 13:58:51 -0700
Subject: [PATCH] Shader refactoring

---
 src/utils/media-highlight-frag.glsl | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/utils/media-highlight-frag.glsl b/src/utils/media-highlight-frag.glsl
index d47ac0b13..82214980d 100644
--- a/src/utils/media-highlight-frag.glsl
+++ b/src/utils/media-highlight-frag.glsl
@@ -6,20 +6,22 @@ if (hubs_HighlightInteractorOne || hubs_HighlightInteractorTwo) {
     float line = mod(hubs_Time / 3000.0 * size, size * 2.0) + hubs_SweepParams.s - size / 2.0;
 
     if (hubs_WorldPosition.y < line) {
-      // Highlight with an sweeping gradient
+      // Highlight with a sweeping gradient.
       ratio = max(0.0, 1.0 - (line - hubs_WorldPosition.y) / size * 3.0);
     }
   }
 
-  float pulse = sin(hubs_Time / 1000.0) + 1.0;
   // Highlight with a gradient falling off with distance.
+  float pulse = 9.0 + 3.0 * (sin(hubs_Time / 1000.0) + 1.0);
+
   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;
+    ratio += -min(1.0, pow(dist1 * 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;
+    ratio += -min(1.0, pow(dist2 * pulse, 3.0)) + 1.0;
   }
 
   ratio = min(1.0, ratio);
-- 
GitLab