summaryrefslogtreecommitdiffstats
path: root/src/shader.frag
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader.frag')
-rw-r--r--src/shader.frag46
1 files changed, 5 insertions, 41 deletions
diff --git a/src/shader.frag b/src/shader.frag
index 4702e65..203bf3b 100644
--- a/src/shader.frag
+++ b/src/shader.frag
@@ -1,10 +1,12 @@
#version 450
layout(location = 0) in vec3 fragColor;
-layout(location = 1) in vec2 fragPos;
+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;
@@ -12,45 +14,7 @@ layout(binding = 0) uniform UniformBufferObject {
vec2 resolution;
} ubo;
-// vec4 ubo_proj(vec2 v) {
-// return ubo.proj * ubo.view * ubo.model * vec4(v, 0.0, 1.0);
-// }
-
-// void main() {
-// // float x = gl_FragCoord.x / ubo.resolution.x;
-// // float y = gl_FragCoord.y / ubo.resolution.y;
-// float x = ubo_proj(vec2(gl_FragCoord.x, gl_FragCoord.y)).x / ubo.resolution.x;
-// float y = ubo_proj(vec2(gl_FragCoord.x, gl_FragCoord.y)).y / ubo.resolution.y;
-// //bool colored = mod(gl_FragCoord.x, 10) > 9 || mod(gl_FragCoord.y, 10) > 9;
-// bool colored = mod(x,0.1) > 0.09 || mod(y, 0.1) > 0.09;
-// if (colored) {
-// outColor = vec4(gl_FragCoord.x / ubo.resolution.x, gl_FragCoord.y / ubo.resolution.y, 1.0, 1.0);
-// } else {
-// outColor = vec4(0,0,0, 1.0);
-// }
-// //outColor = vec4(fragColor, 1.0);
-// }
-vec3 mandel(vec2 z0) {
- float k = 0.0;
- vec2 z = vec2(0.0);
- for(int i = 0; i < 420; ++i) {
- z = vec2(z.x*z.x-z.y*z.y, z.x*z.y*2.0) + z0;
- if (length(z) > 20.0) break;
- k += 1.0;
- }
- float mu = k + 1.0 - log2(log(length(z)));
- return sin(mu*0.1 + vec3(0.0,0.5,1.0));
-}
void main() {
- float ar = ubo.resolution.x / ubo.resolution.y;
- vec2 uv = gl_FragCoord.xy / ubo.resolution.yy - vec2(0.66 * ar, 0.5);
- // uv = uv * 2.0 + vec2(-0.3, 0.0);
- float p = 30.0;
- float t = mod(13.0, p);
- if (t > p/2.0) t = p - t;
- float scale = 0.5 + pow(2.0, t);
- vec2 offset = vec2(-1.36799, .01);
- uv += offset*scale;
- uv /= scale;
- outColor = vec4(mandel(uv), 1.0);
+ //outColor = vec4(fragColor * texture(texSampler, fragTexCoord).rgb, 1.0);
+ outColor = texture(texSampler, fragTexCoord);
}