From b1f6fab6631e85ecbf66e95c86da015212b94f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petri=20J=C3=A4rvisalo?= Date: Thu, 31 Jul 2025 18:03:01 +0300 Subject: [PATCH] fix --- src/main.cpp | 18 +++++++----------- src/shaders/fragment.frag | 6 +++--- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c22d8c2..3ef5c24 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,8 @@ #endif #include "glext.h" +#include "fft.h" + #pragma data_seg(".shader") #include "shaders/fragment.inl" #if POST_PASS @@ -34,18 +36,12 @@ #include "shaders/post.inl" #endif -#include "fft.h" - - #pragma data_seg(".pids") // static allocation saves a few bytes static int pidMain; static int pidPost; // static HDC hDC; - - - #ifndef EDITOR_CONTROLS #pragma code_seg(".main") // FFT buffers @@ -234,11 +230,11 @@ int __cdecl main(int argc, char* argv[]) // Normalize output for (int i = 0; i < (FFT_SIZE / 4); i++) { - float gain = 0.025f; - float alpha = 0.15f; // "Hidastaa" FFT:n piikkejä - float threshhold = 0.015f; // Alin arvo mik� p��stet��n shaderille (v�hent�� "noisea") - float magnitude = sqrt(signal[i].re * signal[i].re + signal[i].im * signal[i].im); - + float gain = 0.05f; + float alpha = 0.10f; // "Hidastaa" FFT:n piikkejä + float threshhold = 0.00015f; // Alin arvo mik� p��stet��n shaderille (v�hent�� "noisea") + // float magnitude = sqrt(signal[i].re * signal[i].re + signal[i].im * signal[i].im); // signal strength + float magnitude = (float)signal[i].re; float x_t = (magnitude < threshhold) ? 0.f : magnitude * gain; // Exponential smoothing kaava // s(t) = alpha*x(t)+(1-alpha)*s(t-1) diff --git a/src/shaders/fragment.frag b/src/shaders/fragment.frag index bf2b283..c6e43c9 100644 --- a/src/shaders/fragment.frag +++ b/src/shaders/fragment.frag @@ -117,9 +117,9 @@ vec2 mapScene(in vec3 p) { float res = p.y; float mat = 0.; - float hexRadius = 0.85; + float hexRadius = 0.83; vec3 hexpos = vec3(p.x, p.y - 2.5, p.z); - HexData hex = hexTile(hexpos, 1.5); + HexData hex = hexTile(hexpos, 1.1); float distFromCenter = hexDistance(hex.axial); int fftIndex = int(clamp(distFromCenter + 1.0, 0.0, 511.0)); @@ -264,7 +264,7 @@ vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) { float syncsBass = clamp((syncs[1] + syncs[2] + syncs[3]), 0., 1.); float fogAmount2 = 1.0 - exp(-t * fogAmount); - float sunAmount = max(dot(rd, lightDir), 0.0); + float sunAmount = max(dot(rd, lightDir), 1.0); // highlight color vec3 fogColor = mix(vec3(0.2706, 0.2706, 0.2863), vec3(0.2314, 0.2314, 0.2314), // Main color pow(sunAmount, syncsBass * 1.0));