From 4389be6ef881616da32fe749a4a96b4db1f0a0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20J=C3=A4rvisalo?= Date: Wed, 24 Jul 2024 16:48:38 +0300 Subject: [PATCH] Animaatiot toimii --- 4kdemo.compofiller | 2 +- shader.glsl | 95 +++++++++++++++++++++++++++++----------------- 2 files changed, 62 insertions(+), 35 deletions(-) diff --git a/4kdemo.compofiller b/4kdemo.compofiller index baa5bd0..a1db361 100644 --- a/4kdemo.compofiller +++ b/4kdemo.compofiller @@ -6,7 +6,7 @@ PROJECT_INFO_FILE=prod.nfo PROJECT_SCREENSHOT= # Currently active config file name -ACTIVE_CONFIG=minified.config +ACTIVE_CONFIG=base.config # ------- GUI options/preferences -------- # Automatically rebuild DLLs when things have changed? diff --git a/shader.glsl b/shader.glsl index bae10d4..1aead72 100644 --- a/shader.glsl +++ b/shader.glsl @@ -81,10 +81,10 @@ const float STARTDELAY = 2.0; float factor = 9.0+9.0*clamp(sin(ringRotateFunc(2.0, 0.0, 1.0) * 0.05), -0.9, 0.9); -// delay start +// delay start if( u_time >= STARTDELAY ) { -factor = 9.0+9.0*clamp(sin(ringRotateFunc(2.0, 0.0, 1.0) * 0.05), -0.9, 0.9); -p.xy = rot2D(factor) * p.xy; + factor = 9.0+9.0*clamp(sin(ringRotateFunc(2.0, 0.0, 1.0) * 0.05), -0.9, 0.9); + p.xy = rot2D(factor) * p.xy; } if(u_time >= 14.0) { @@ -275,42 +275,69 @@ void main( ) vec3 rd = GetRayDir(uv, ro, vec3(0, 0., 0.), 1.); // ray direction vec3 col = vec3(0); // color - float d = rayMarch(ro, rd); - - if (d < 1000.) + if(u_time > 0.0) { - // Lighting - vec3 p = ro + rd * d; + float d = rayMarch(ro, rd); - float mat = map(p).y; - // Light 1 - // Light 1 Position - vec3 lightPos1 = vec3( 3, 5, 4); - // Light 1 Arguments - // 1: Ray starting point - // 2: Light position - // 3: Light intensity - // 4: Shadow intensity - float dif = getLight(p, lightPos1, 0.75, 0.2); - // Color for light 1 - col = vec3(dif * vec3(1)); + if (d < 1000.) + { + // Lighting + vec3 p = ro + rd * d; - // Light 2 - vec3 lightPos2 = vec3( -3, 5, -4); - dif = getLight(p, lightPos2, 0.75, 0.1); - // Color for light 2 - col += vec3(dif * vec3(0.5,0.2,0.1)); + float mat = map(p).y; + // Light 1 + // Light 1 Position + vec3 lightPos1 = vec3( 3, 5, 4); + // Light 1 Arguments + // 1: Ray starting point + // 2: Light position + // 3: Light intensity + // 4: Shadow intensity + float dif = getLight(p, lightPos1, 0.75, 0.2); + // Color for light 1 + col = vec3(dif * vec3(1)); - if(mat==0.){ - col *= vec3(0,0,1); - } - else if(mat==1.){ - col *= vec3(0,1,0); - } - else if(mat==2.){ - col *= vec3(1,0,0); + // Light 2 + vec3 lightPos2 = vec3( -3, 5, -4); + dif = getLight(p, lightPos2, 0.75, 0.1); + // Color for light 2 + col += vec3(dif * vec3(0.5,0.2,0.1)); + + if(mat==0.){ + col *= vec3(0,0,1); + } + else if(mat==1.){ + col *= vec3(0,1,0); + } + else if(mat==2.){ + col *= vec3(1,0,0); + } } + gl_FragColor = vec4(col, 1); } - gl_FragColor = vec4(col, 1); + else { + + // ************* post-process pass ****************** + // Uncomment this to try a post-processing "effect" + + vec4 c = texture2D(texture_sampler, (gl_FragCoord.xy / u_resolution )), + c1 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(1.0, 0.0)) / u_resolution) ), + c2 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(0.0, 1.0)) / u_resolution) ), + c3 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(1.0, 1.0)) / u_resolution) ), + c4 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(-1.0, 1.0)) / u_resolution) ), + c5 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(-1.0, 0.0)) / u_resolution) ), + c6 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(-1.0, -1.0)) / u_resolution) ), + c7 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(0.0, -1.0)) / u_resolution) ), + c8 = texture2D(texture_sampler, ((gl_FragCoord.xy + vec2(1.0, -1.0)) / u_resolution) ) + ; + + // weird emboss effect + // gl_FragColor = (c - c1 - c2 - c3 - c4 + c5 + c6 + c7 + c8) / 2.0; + + + // some sort of gamma correction with smoothing + gl_FragColor = sqrt(c * 2.0 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8) / 3.0; + + } }