-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRotating UVs.glsl
71 lines (53 loc) · 2.22 KB
/
Rotating UVs.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#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 = 2; // Time speed scaler
float adjustedTime = time * speed; // Adjusted time sped up by
float adjustedSlowTime = time * .1; // Adjusted time sped up by scaler
vec2 coord = gl_FragCoord.xy; // screen coord
vec2 uv = coord / resolution.x; // UV coord using height
vec2 centeredUV = uv - vec2(.5,.5);
centeredUV *= 2; // scale UVs
// Rotates the UV
float sin_factor = sin(adjustedTime);
float cos_factor = cos(adjustedTime);
vec2 rotatedUV = centeredUV * mat2(cos_factor, sin_factor, -sin_factor, cos_factor);
vec2 mixedUV = mix(centeredUV, rotatedUV, length(rotatedUV));
//fragColor = vec4((mixedUV.x), abs(mixedUV.y), 0, 0);
fragColor = vec4((mixedUV.x), abs(mixedUV.y), 0, 0);
}
/*
float cellsize = 8
; // size of the cells
vec2 rowColnormalized = floor(uv * cellsize) / cellsize; // column, row
vec2 rowColIndex = floor(uv * cellsize);
vec2 normCells = mod(uv * cellsize, 1); // Cells normalized values on X and Y
// offsets based on row and col indexes
float offsetSpacing = 7;
//float offset = (sin( adjustedTime + ( (rowColIndex.x ) * offsetSpacing)) + 1) / 2; // Horizontal offset
//float offset = (sin( adjustedTime + ( (rowColIndex.x + rowColIndex.y) * offsetSpacing )) + 1) / 2; // Angle offset
float offset = sin( adjustedTime + length(centeredUV * offsetSpacing));
//float offset = (sin( adjustedTime + ( rowColIndex.x * (rowColIndex.y + adjustedSlowTime))) + 1) / 2; // morphing offset
// making the dots
vec2 distFrmCntrNorm = abs(normCells - vec2(.5, .5)) * 2; // Distance normalized
//float diamonds = (distFrmCntrNorm.x + distFrmCntrNorm.y) / 2;
float dot = length(distFrmCntrNorm); // Dot created from the Length of the vector from the center of the cell
dot = pow(dot, 4 * ( offset) ); //
dot = floor(dot * 1.2);
*/