Make shine rays pulsate
This commit is contained in:
parent
0294800e6b
commit
a12a8e6193
|
@ -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]
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
"
|
||||
|
|
Loading…
Reference in a new issue