From ddade2ab44d5d6f862e73bb4ab48e4e0638bcf38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20J=C3=A4rvisalo?= Date: Fri, 1 Aug 2025 13:29:18 +0300 Subject: [PATCH] merge --- src/shaders/fragment.frag | 46 +++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/shaders/fragment.frag b/src/shaders/fragment.frag index 320c15f..cc1f7e8 100644 --- a/src/shaders/fragment.frag +++ b/src/shaders/fragment.frag @@ -8,15 +8,24 @@ layout(location = 0) uniform float syncs[11]; layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4 // float u_time = syncs[0]; -// paletti muunnos: arg 0.75 --> 0. -vec3 palette(float t, float arg){ - vec3 a=vec3(0.39,0.56,0.47); - vec3 b=vec3(0.54,0.56,0.51); - vec3 c=vec3(0.45,0.79,0.42); - vec3 d=vec3(0.08,0.37,arg); // t�st� viimenen floatti siirrett�v� 0, kun tehd��n paletti switch +// paletti muunnos: arg 0.8 --> 0.5 +vec3 palette(float t, float arg, float arg2){ + vec3 a=vec3(0.52,0.56,0.47); + vec3 b=vec3(0.62,0.56,0.51); + vec3 c=vec3(0.43,0.79,0.42); + vec3 d=vec3(arg,0.42,arg2); // t�st� viimenen floatti siirrett�v� 0, kun tehd��n paletti switch return a+b*cos(6.28318*(c*t+d)); } +/* +vec3 palette(float t){ + vec3 a=vec3(0.52,0.56,0.47); + vec3 b=vec3(0.62,0.56,0.51); + vec3 c=vec3(0.43,0.79,0.42); + vec3 d=vec3(0,0.42,0.63); + return a+b*cos(6.28318*(c*t+d)); +} +*/ vec2 getUV() { const vec2 scale = vec2(0.00104166667, 0.00185185185); return gl_FragCoord.xy * scale - 1.0; @@ -160,7 +169,7 @@ vec2 mapScene(vec3 p) { for (int dx = -repeat; dx <= repeat; ++dx) { for (int dy = -repeat; dy <= repeat; ++dy) { vec2 offset = vec2(dx, dy); - vec3 hexpos = vec3(p.x-dx, p.y - 2.5, p.z-dy); + vec3 hexpos = vec3(p.x-dx, p.y-8.0, p.z-dy); HexData hex = hexTile(hexpos, 1.1); float distFromCenter = hexDistance(hex.axial); int fftIndex = int(cl(distFromCenter + 1.0, 0.0, 511.0)); @@ -297,7 +306,7 @@ vec3 phongLighting(vec3 p, vec3 normal, vec3 lightPos, vec3 viewPos, vec3 lightC vec3 diffuse = diff * lightColor; // Specular - float specularStrength = 11.5; + float specularStrength = 13.5; float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32.0); // shininess vec3 specular = specularStrength * spec * lightColor; @@ -312,11 +321,15 @@ vec3 calcNormal(vec3 pos) { } vec3 pal(float color) { - vec3 c = palette(color, 0.75); - vec3 c2 = palette(color, 0.0); - float t = clamp((syncs[0] - 12.0) / 2.0, 0.0, 1.0); // Smoothly ramps from 0 to 1 after 12s + color *= 0.2; + + vec3 c = palette(color, 0.25, 0.63); + vec3 c2 = palette(color, 0.5 ,0.2); + + float t = clamp((syncs[0] - 129.0) / 2.0, 0.0, 1.0); // Smoothly ramps from 0 to 1 after 12s return mix(c, c2, t); // Blend between c and c2 over ~2 seconds + //return c2; } vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) { @@ -337,7 +350,8 @@ vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 camPos) { outMaterial = pal(p.y*p.y*0.01); vec3 lights = vec3(0.); - lights += phongLighting(p, n, camPos, dir, vec3(0.51), outMaterial); + //lights += phongLighting(p, n, camPos, dir, vec3(0.51), outMaterial); + lights += phongLighting(p, n, vec3(4., 4., -4.), dir, vec3(2.51), outMaterial); vec3 lightDir = vec3(0., 2., 3); @@ -351,15 +365,15 @@ vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 camPos) { vec3 postProcess(vec3 col) { // Contrast - float contrast = 0.75; + float contrast = 0.85; col = mix(col, smoothstep(0.0, 1.0, col), contrast); // Colour mapping - // col *= vec3(1.0, 1.0, 1.0); + //col *= vec3(1.0, 1.0, 1.0); // Gamma - col = pow(col, vec3(0.4545)); // gamma 2.2 + col = pow(col, vec3(.55)); // gamma 2.2 // fade in at the beginning //col*=vec3(clamp((u_time-1.8)*0.5,0., 1.)); @@ -398,7 +412,7 @@ vec3 render(vec2 uv) { //glow from the bottom vec3 bGlowColor = pal(syncs[0] * .075); // color change - float bGlowDistance = 0.3; + float bGlowDistance = 0.8; vec3 p = camPos + t.x * rayDir; vec3 bGlowLevel = bGlowColor * exp(-(p.y + 0.0) / bGlowDistance) * 9900.;