This commit is contained in:
Teemu Järvisalo
2025-08-01 15:36:28 +03:00
parent 353c4440ea
commit 04e2761e04
2 changed files with 29 additions and 20 deletions

View File

@ -6,7 +6,7 @@
#define BREAK_COMPATIBILITY 0
#else
#define OPENGL_DEBUG 0
#define FULLSCREEN 0
#define FULLSCREEN 1
#define DESPERATE 0
#define BREAK_COMPATIBILITY 0
#endif

View File

@ -6,7 +6,7 @@ const float TAU = (2. * PI);
const float PHI = sqrt(5.) * 0.5 + 0.5;
layout(location = 0) uniform float syncs[11];
layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4
// float u_time = syncs[0];
float u_time = syncs[0];
// paletti muunnos: arg 0.8 --> 0.5
vec3 palette(float t, float arg, float arg2){
@ -37,7 +37,6 @@ float noise(in vec2 xy, in float seed) {
// shorted functions
vec3 no(vec3 v) { return normalize(v); }
float cl(float a, float b, float c) { return clamp(a,b,c); }
float lev3(vec3 s) { return length(s); }
float lev2(vec2 s) { return length(s); }
@ -140,7 +139,7 @@ vec2 mapScene(vec3 p) {
HexData hex = hexTile(hexpos, 1.1);
float distFromCenter = hexDistance(hex.axial);
int fftIndex = int(cl(distFromCenter + 1., 0.0, 511.0));
float noise = mix(noise(hex.axial+1., 0.1), noise(hex.axial+1., 0.2), sin(syncs[0] * 4.));
float noise = mix(noise(hex.axial+1., 0.1), noise(hex.axial+1., 0.2), sin(u_time * 4.));
float hexHeight = cl(1.0 + (fft_output[fftIndex] * 2.0 + noise), 0., 15.);
vec3 r = vec3(hex.local.x + offset.x,hex.local.y,hex.local.z+offset.y);
// r.yz *= rot2D(PI * 0.5);
@ -220,7 +219,7 @@ vec3 addPointLight(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPo
// Light vector from surface to light
//float roughness = 1.0;
vec3 lightDir = lightPos - worldPos;
float lightDistance = lev3(lightDir);
float lightDistance = length(lightDir);
lightDir = no(lightDir);
// Attenuation (quadratic falloff)
@ -255,17 +254,15 @@ vec3 calcNormal(vec3 pos) {
}
vec3 pal(float color) {
color *= 0.2;
//color *= 0.2;
vec3 c = palette(color, 0.25, 0.63);
vec3 c2 = palette(color, 0.5 ,0.2);
float t = cl((syncs[0] - 129.0) / 2.0, 0.0, 1.0); // Smoothly ramps from 0 to 1 after 12s
float t = cl((u_time - 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) {
float syncsBass = cl((syncs[1] + syncs[2] + syncs[3]), 0., 1.);
@ -277,21 +274,22 @@ vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) {
pow(sunAmount, syncsBass * 1.0));
return mix(col, fogColor, fogAmount2);
}
*/
vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 camPos) {
vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 caPos) {
vec3 outMaterial = vec3(0.0);
outMaterial = pal(p.y*p.y*0.01);
vec3 lights = vec3(0.);
//lights += phongLighting(p, n, camPos, dir, vec3(0.51), outMaterial);
lights += addPointLight(vec3(0., 20.0, 0.), vec3(0.7, 0.3, 0.7), 20.0, p, dir, n);
lights += addPointLight(vec3(0., 20.0, 0.), vec3(0.7, 0.3, 0.7), 15.0, p, dir, n);
/*
// LIGHT CHANGING WITH CIRCLE RADIUS
float maxRadius = 25.; // Circle radius
float particleHeight = 15.; //(syncs[5] * 40.);
float particlePos = (syncs[0] * 0.5) + syncs[5];
float particlePos = (u_time * 0.5) + syncs[5];
// Map param to angle
float particleStartPos = particlePos * 2.0 * PI;
@ -310,11 +308,11 @@ vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 camPos) {
lights += addPointLight(objPos, vec3(0.33, 0.91, 0.93), 30.0, p, dir, n);
*/
/*
vec3 lightDir = vec3(0., 2., 3);
float ind = cl(dot(n, no(lightDir * vec3(.0, 1.0, -2.0))), 0.0, 1.0);
lights += vec3(0.6, 0.6, 0.6) * ind * 0.6;
lights += vec3(0.6, 0.6, 0.6) * ind * 0.4;
*/
outMaterial *= max(vec3(0.), lights); // output with lights;
@ -352,7 +350,7 @@ vec3 getCameraRayDir(vec2 uv, vec3 camPos, vec3 camTarget, float fov) {
}
vec3 render(vec2 uv) {
vec3 camPos = vec3(-20.0 + sin(syncs[0] * 0.25) * 5, abs(sin(syncs[0] * 0.25) * 10) + 25.0, -20.0);
vec3 camPos = vec3(-20.0 + sin(u_time * 0.25) * 5, abs(sin(u_time * 0.25) * 10) + 25.0, -20.0);
// vec3 camTarget = vec3(0.) // Adjust target as needed
//float fov = 1.0;
@ -365,21 +363,32 @@ vec3 render(vec2 uv) {
if(t.x > 0.0) {
vec3 nor = calcNormal(hitPos);
col = shading(hitPos, nor, rayDir, camPos);
//col = shading(hitPos, nor, rayDir, camPos);
//vec3 mat = vec3(0.0);
vec3 mat = pal(hitPos.y*hitPos.y*0.01);
//vec3 lights = vec3(0.);
vec3 lights = addPointLight(vec3(0., 20.0, 0.), vec3(0.7, 0.3, 0.7), 15.0, hitPos, rayDir, nor);
mat *= max(vec3(0.), lights); // output with lights;
col = mat;
}
//glow from the bottom
vec3 bGlowColor = pal(syncs[0] * .075); // color change
vec3 bGlowColor = pal(u_time * .075); // color change
float bGlowDistance = 0.8;
vec3 p = camPos + t.x * rayDir;
vec3 bGlowLevel = bGlowColor * exp(-(p.y + 0.0) / bGlowDistance) * 9900.;
vec3 bGlowLevel = bGlowColor * exp(-(p.y + 0.0) / bGlowDistance) * 10000.;
col += bGlowLevel;
col = clamp(mix(bGlowLevel, col, t.z), 0.0, 1.0);
// distance fog + bass thunder
/*
float fogAmount = 0.01;
col = col * exp(-t.x * fogAmount) + applyFog(col, t.x, rayDir, vec3(0., -0.5, 1.8), fogAmount) * (1.0 - exp(-t.x * fogAmount));
*/
return col;
}