diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2024-05-21 11:56:12 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2024-05-21 11:56:12 +0300 |
commit | b04db611ed0eb7ec9e1b7d988f3031fe63a1de52 (patch) | |
tree | 91be243faa9c06f22379e8e774b14463b285a47b /src/shader.frag | |
parent | 7c26dcc4480025b5d11e315273541b3fb2c34a09 (diff) | |
download | cgame-b04db611ed0eb7ec9e1b7d988f3031fe63a1de52.tar.gz cgame-b04db611ed0eb7ec9e1b7d988f3031fe63a1de52.tar.bz2 cgame-b04db611ed0eb7ec9e1b7d988f3031fe63a1de52.zip |
hot reload shaders bby
Diffstat (limited to 'src/shader.frag')
-rw-r--r-- | src/shader.frag | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/shader.frag b/src/shader.frag index cad317c..4702e65 100644 --- a/src/shader.frag +++ b/src/shader.frag @@ -5,8 +5,30 @@ layout(location = 1) in vec2 fragPos; layout(location = 0) out vec4 outColor; +layout(binding = 0) uniform UniformBufferObject { + mat4 model; + mat4 view; + mat4 proj; + vec2 resolution; +} ubo; + +// vec4 ubo_proj(vec2 v) { +// return ubo.proj * ubo.view * ubo.model * vec4(v, 0.0, 1.0); +// } + // void main() { -// outColor = vec4(fragColor, 1.0); +// // 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; @@ -20,13 +42,13 @@ vec3 mandel(vec2 z0) { return sin(mu*0.1 + vec3(0.0,0.5,1.0)); } void main() { - float ar = fragPos.x / fragPos.y; - vec2 uv = gl_FragCoord.xy / fragPos.yy - vec2(0.66 * ar, 0.5); - //uv = uv * 2.0 + vec2(-0.3, 1.0); + 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(4.0, t); + float scale = 0.5 + pow(2.0, t); vec2 offset = vec2(-1.36799, .01); uv += offset*scale; uv /= scale; |