diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2024-06-01 01:47:10 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2024-06-01 01:47:10 +0300 |
commit | 64617ea2c46d13cd2f72df72fcd426d2fc561bff (patch) | |
tree | 570b2c2d0728a94466059c3652bd982ad436062d /src/shader.frag | |
parent | 9acc6b19c6efefb75ee5bc409df3e9346bd07d73 (diff) | |
download | cgame-64617ea2c46d13cd2f72df72fcd426d2fc561bff.tar.gz cgame-64617ea2c46d13cd2f72df72fcd426d2fc561bff.tar.bz2 cgame-64617ea2c46d13cd2f72df72fcd426d2fc561bff.zip |
multisample
Diffstat (limited to 'src/shader.frag')
-rw-r--r-- | src/shader.frag | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/src/shader.frag b/src/shader.frag index 1818cc8..3e80e21 100644 --- a/src/shader.frag +++ b/src/shader.frag @@ -16,50 +16,50 @@ layout(binding = 0) uniform UniformBufferObject { 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); +// 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 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 noise(vec2 p) { + return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); +} -// 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; -// } +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); +} -// 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); -// } +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() { |