-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
272e68a
commit a036c8d
Showing
5 changed files
with
97 additions
and
133 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/experiences/home/world/shaders/partials/clockDots.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* clock Dots | ||
* | ||
* @original-author Andre VanKammen / https://github.com/AndreVanKammen | ||
* | ||
* @source https://www.shadertoy.com/view/3dtSRj | ||
*/ | ||
|
||
float clockDots(vec2 uv) { | ||
float seg = .0; | ||
uv.y -= .5; | ||
seg += (1. - smoothstep(0.11, .13, length(uv))) * (1. - length(uv) * 2.0); | ||
uv.y += 1.; | ||
seg += (1. - smoothstep(0.11, .13, length(uv))) * (1. - length(uv) * 2.0); | ||
return seg; | ||
} | ||
|
||
#pragma glslify: export(clockDots) |
20 changes: 20 additions & 0 deletions
20
src/experiences/home/world/shaders/partials/clockNumber.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma glslify: sevenSegment = require(./sevenSegment.glsl) | ||
|
||
float clockNumber(vec2 uv, int nr, bool zeroTrim, bool on) { | ||
// Speed optimization, leave if pixel is not in segment/ | ||
if(abs(uv.x) > 1.5 || abs(uv.y) > 1.2) | ||
return .0; | ||
|
||
float seg = .0; | ||
if(uv.x > .0) { | ||
nr /= 10; | ||
if(nr == 0 && zeroTrim) | ||
nr = -1; | ||
seg += sevenSegment(uv + vec2(-0.75, .0), nr, on); | ||
} else | ||
seg += sevenSegment(uv + vec2(0.75, .0), int(mod(float(nr), 10.0)), on); | ||
|
||
return seg; | ||
} | ||
|
||
#pragma glslify: export(clockNumber) |
40 changes: 40 additions & 0 deletions
40
src/experiences/home/world/shaders/partials/sevenSegment.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* SevenSegment | ||
* | ||
* @original-author Andre VanKammen / https://github.com/AndreVanKammen | ||
* | ||
* @source https://www.shadertoy.com/view/3dtSRj | ||
*/ | ||
|
||
bool showOff = false; | ||
|
||
float segment(vec2 uv, bool On) { | ||
if(!On && !showOff) | ||
return .0; | ||
|
||
float seg = (1. - smoothstep(0.08, .09 + float(On) * .02, abs(uv.x))) * | ||
(1. - smoothstep(0.46, .47 + float(On) * .02, abs(uv.y) + abs(uv.x))); | ||
|
||
// Led like brightness | ||
if(On) | ||
seg *= (1. - length(uv * vec2(3.8, .9))); | ||
else | ||
seg *= -(0.05 + length(uv * vec2(0.2, .1))); | ||
|
||
return seg; | ||
} | ||
|
||
float sevenSegment(vec2 uv, int num, bool on) { | ||
float seg = .0; | ||
seg += segment(uv.yx + vec2(-1., .0), num != -1 && num != 1 && num != 4 && on); | ||
seg += segment(uv.xy + vec2(-0.5, -0.5), num != -1 && num != 1 && num != 2 && num != 3 && num != 7 && on); | ||
seg += segment(uv.xy + vec2(0.5, -0.5), num != -1 && num != 5 && num != 6 && on); | ||
seg += segment(uv.yx + vec2(.0, .0), num != -1 && num != 0 && num != 1 && num != 7 && on); | ||
seg += segment(uv.xy + vec2(-0.5, .5), (num == 0 || num == 2 || num == 6 || num == 8) && on); | ||
seg += segment(uv.xy + vec2(0.5, .5), num != -1 && num != 2 && on); | ||
seg += segment(uv.yx + vec2(1., .0), num != -1 && num != 1 && num != 4 && num != 7 && on); | ||
|
||
return seg; | ||
} | ||
|
||
#pragma glslify: export(sevenSegment) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters