summaryrefslogtreecommitdiffstats
path: root/src/shader.frag
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2024-05-31 21:00:57 +0300
committergramanas <anastasis.gramm2@gmail.com>2024-05-31 21:00:57 +0300
commita5a82709028c475d0ff6cd54f6d07f16375e156e (patch)
treedb1386b3e5af7075ee6e5c45c3a4964cdecdc9d2 /src/shader.frag
parent1f6538bcaf379cb3fe257a0053e4e7567f8ddb98 (diff)
downloadcgame-a5a82709028c475d0ff6cd54f6d07f16375e156e.tar.gz
cgame-a5a82709028c475d0ff6cd54f6d07f16375e156e.tar.bz2
cgame-a5a82709028c475d0ff6cd54f6d07f16375e156e.zip
Allaboard
Diffstat (limited to 'src/shader.frag')
-rw-r--r--src/shader.frag73
1 files changed, 70 insertions, 3 deletions
diff --git a/src/shader.frag b/src/shader.frag
index 3f76290..075c2ae 100644
--- a/src/shader.frag
+++ b/src/shader.frag
@@ -12,10 +12,77 @@ layout(binding = 0) uniform UniformBufferObject {
mat4 view;
mat4 proj;
vec2 resolution;
+ float time;
+ float dt;
} ubo;
void main() {
- //outColor = vec4(fragColor * texture(texSampler, fragTexCoord).rgb, 1.0);
- outColor = texture(texSampler, fragTexCoord);
- //outColor = vec4(fragColor ,1);
+ float pulse = sin(ubo.time * .2) * .5 + .5;
+ outColor = vec4(fragColor * texture(texSampler, fragTexCoord).rgb * pulse, 1.0);
+ //outColor = texture(texSampler, fragTexCoord);
+// 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);
+// }