summaryrefslogtreecommitdiffstats
path: root/src/shader.frag
blob: 1818cc8d5dd31d8dfe1abf89d2db20f05b81a5cb (plain) (blame)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#version 450

layout(location = 0) in vec3 fragColor;
layout(location = 1) in vec2 fragTexCoord;

layout(location = 0) out vec4 outColor;

layout(binding = 1) uniform sampler2D texSampler;

layout(binding = 0) uniform UniformBufferObject {
  mat4 model;
  mat4 view;
  mat4 proj;
  vec2 resolution;
  float time;
  float dt;
} ubo;

void main() {
  // float pulse = sin(ubo.time * .2) * .5 + .5;
  // outColor = vec4(fragColor * texture(texSampler, fragTexCoord).rgb * pulse, 1.0);
  //outColor = texture(texSampler, fragTexCoord);
  outColor = vec4(fragColor, 1);
//   float repeat = 10;
//   float f = mod(ubo.time, repeat);
//   if (f < repeat / 2) {
//     outColor = vec4(fragColor * radians(f) ,1);
//   } else {
//     outColor = vec4(fragColor * radians(1 - f) ,1);
//   }
//   //outColor = (vec4(1) * ubo.model + vec4(1)) * vec4(texture(texSampler, fragTexCoord).rgb * fragColor, 1.0);
}

// float noise(vec2 p) {
//     return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
// }

// float smoothNoise(vec2 p) {
//     vec2 i = floor(p);
//     vec2 f = fract(p);
//     vec2 u = f * f * (3.0 - 2.0 * f);
//     return mix(mix(noise(i + vec2(0.0, 0.0)), noise(i + vec2(1.0, 0.0)), u.x),
//                mix(noise(i + vec2(0.0, 1.0)), noise(i + vec2(1.0, 1.0)), u.x), u.y);
// }

// float fbm(vec2 p) {
//     float value = 0.0;
//     float amplitude = 0.5;
//     for (int i = 0; i < 6; i++) {
//         value += amplitude * smoothNoise(p);
//         p *= 2.0;
//         amplitude *= 0.5;
//     }
//     return value;
// }

// void main() {
//     vec2 uv = gl_FragCoord.xy / ubo.resolution.xy;
//     vec2 p = uv * 2.0 - vec2(1.0);
//     float n = fbm(p * 5.0 - vec2(0.0, ubo.time * 2.0));
//     outColor = vec4(n, n * 0.5, 0.0, 1.0) * vec4(texture(texSampler, fragTexCoord).rgb, 1.0);
// }

// void main() {

//     // Calculate a pulsating factor based on sine wave
//     float pulse = sin(ubo.time * 2.0) * 0.5 + 0.5;
    
//     // Set the color using the pulse factor
//     outColor = vec4(pulse, 0.0, 1.0 - pulse, .5);
// }

// void main() {
//     vec2 uv = gl_FragCoord.xy / ubo.resolution;
//     vec2 center = uv - 0.5;
    
//     float angle = ubo.time;
//     float cosA = cos(angle);
//     float sinA = sin(angle);
    
//     vec2 rotated = vec2(
//         center.x * cosA - center.y * sinA,
//         center.x * sinA + center.y * cosA
//     );
    
//     float pattern = step(0.5, mod(rotated.x * 10.0, 1.0)) * step(0.5, mod(rotated.y * 10.0, 1.0));
    
//     outColor = vec4(vec3(pattern), 1.0);
// }