-
Notifications
You must be signed in to change notification settings - Fork 1
/
Pulsing dots.glsl
51 lines (38 loc) · 1.45 KB
/
Pulsing dots.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#version 150
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
uniform vec3 spectrum;
uniform sampler2D texture0;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;
uniform sampler2D prevFrame;
in VertexData
{
vec4 v_position;
vec3 v_normal;
vec2 v_texcoord;
} inData;
out vec4 fragColor;
void main(void)
{
float speed = 4;
float adjustedTime = time * speed;
vec2 coord = gl_FragCoord.xy; // screen coord
// coord -= resolution * 0.5; // screen coord with 0,0 centered
vec2 uv = coord / resolution.y; // UV coord using height
float normSin = (sin(adjustedTime) + 1) / 2; // normalized sin value
float normCos = (cos(adjustedTime) + 1) / 2; // normalized cos value
float cellsize = 4; // size of the cells
vec2 rowColnormalized = floor(uv * cellsize) / cellsize; // column, row
vec2 rowColIndex = floor(uv * cellsize);
vec2 normCells = mod(uv * cellsize, 1);
vec2 distFrmCntr = abs(normCells - vec2(.5, .5)); // distance from center of the cell
vec2 distFrmCntrNorm = abs(normCells - vec2(.5, .5)) * 2; // distance normalized
//float diamond = (distFrmCntrNorm.x + distFrmCntrNorm.y) / 2;
float dot = length(distFrmCntrNorm); //length of the distance from the center
dot = pow(dot, 20 * normSin);
//fragColor = vec4(distFrmCntr.x,distFrmCntr.y, 0, 0); // dist from cell center
fragColor = vec4(1 - dot, 1 - dot, 1 - dot, 0);
}