From a12a8e6193a6e8e7ec3cce2ddf2fbf8445e0ccc5 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Sun, 4 Nov 2018 18:14:21 +0100 Subject: [PATCH] Make shine rays pulsate --- models/flag.glb.import | 3 +++ scenes/Goal.tscn | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/models/flag.glb.import b/models/flag.glb.import index 582d5d0..e3256d9 100644 --- a/models/flag.glb.import +++ b/models/flag.glb.import @@ -7,7 +7,10 @@ path="res://.import/flag.glb-0b6fa3c4b5180c1221a26057702dcf53.scn" [deps] source_file="res://models/flag.glb" +source_md5="6c4291e2219e6d5042a96bf9bb78d31e" + dest_files=[ "res://.import/flag.glb-0b6fa3c4b5180c1221a26057702dcf53.scn" ] +dest_md5="8e9acf5ce51013ce35e065b6c13566fd" [params] diff --git a/scenes/Goal.tscn b/scenes/Goal.tscn index 2d3d397..d18f602 100644 --- a/scenes/Goal.tscn +++ b/scenes/Goal.tscn @@ -22,15 +22,8 @@ void vertex() { float shine_ray(vec2 center_coords, float time, float offset, float speed) { // atan() is in [-pi, pi[ - float angle = atan(center_coords.x, center_coords.y) + offset; - if (angle > PI) { - angle -= 2.0 * PI; - } - if (angle < -PI) { - angle += 2.0 * PI; - } - float t = mod(-time * speed, 2.0 * PI) - PI; // [-pi, pi[ - bool on_ray = abs(angle - t) < 0.05; + float angle = atan(center_coords.x, center_coords.y); + bool on_ray = abs(angle - offset) < 0.1; if (!on_ray) { return 0.0; @@ -38,7 +31,7 @@ float shine_ray(vec2 center_coords, float time, float offset, float speed) { float max_dist = 0.5; // maximum orthogonal distance from center in a [0,1] rectangle float center_dist = sqrt(pow(center_coords.x, 2) + pow(center_coords.y, 2)) / max_dist; - float intensity = 1.0; + float intensity = 1.0 + (sin(time * 3.0) / 3.0); return clamp((1.0 - center_dist) * intensity, 0.0, 1.0); } @@ -47,10 +40,12 @@ void fragment() { vec2 center_coords = vec2(UV.x - 0.5, UV.y - 0.5); ALPHA = clamp( - shine_ray(center_coords, TIME, 0.0, 0.3) + - shine_ray(center_coords, TIME, PI, 0.3) + - shine_ray(center_coords, TIME, 0.0, 0.5) + - shine_ray(center_coords, TIME, PI, 0.4), + shine_ray(center_coords, TIME, 0.5 * PI, 0.3) + + shine_ray(center_coords, TIME, (-1.0 + 0.5) * PI, 0.3) + + shine_ray(center_coords, TIME, 0.3 * PI, 0.5) + + shine_ray(center_coords, TIME, (-1.0 + 0.3) * PI, 0.4) + + shine_ray(center_coords, TIME, 0.8 * PI, 0.5) + + shine_ray(center_coords, TIME, (-1.0 + 0.8) * PI, 0.4), 0.0, 1.0); } "