This commit is contained in:
2025-07-31 18:03:01 +03:00
parent aa949ba2a7
commit b1f6fab663
2 changed files with 10 additions and 14 deletions

View File

@ -27,6 +27,8 @@
#endif #endif
#include "glext.h" #include "glext.h"
#include "fft.h"
#pragma data_seg(".shader") #pragma data_seg(".shader")
#include "shaders/fragment.inl" #include "shaders/fragment.inl"
#if POST_PASS #if POST_PASS
@ -34,18 +36,12 @@
#include "shaders/post.inl" #include "shaders/post.inl"
#endif #endif
#include "fft.h"
#pragma data_seg(".pids") #pragma data_seg(".pids")
// static allocation saves a few bytes // static allocation saves a few bytes
static int pidMain; static int pidMain;
static int pidPost; static int pidPost;
// static HDC hDC; // static HDC hDC;
#ifndef EDITOR_CONTROLS #ifndef EDITOR_CONTROLS
#pragma code_seg(".main") #pragma code_seg(".main")
// FFT buffers // FFT buffers
@ -234,11 +230,11 @@ int __cdecl main(int argc, char* argv[])
// Normalize output // Normalize output
for (int i = 0; i < (FFT_SIZE / 4); i++) for (int i = 0; i < (FFT_SIZE / 4); i++)
{ {
float gain = 0.025f; float gain = 0.05f;
float alpha = 0.15f; // "Hidastaa" FFT:n piikkejä float alpha = 0.10f; // "Hidastaa" FFT:n piikkejä
float threshhold = 0.015f; // Alin arvo mik<69> p<><70>stet<65><74>n shaderille (v<>hent<6E><74> "noisea") float threshhold = 0.00015f; // Alin arvo mik<69> p<><70>stet<65><74>n shaderille (v<>hent<6E><74> "noisea")
float magnitude = sqrt(signal[i].re * signal[i].re + signal[i].im * signal[i].im); // 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; float x_t = (magnitude < threshhold) ? 0.f : magnitude * gain;
// Exponential smoothing kaava // Exponential smoothing kaava
// s(t) = alpha*x(t)+(1-alpha)*s(t-1) // s(t) = alpha*x(t)+(1-alpha)*s(t-1)

View File

@ -117,9 +117,9 @@ vec2 mapScene(in vec3 p) {
float res = p.y; float res = p.y;
float mat = 0.; float mat = 0.;
float hexRadius = 0.85; float hexRadius = 0.83;
vec3 hexpos = vec3(p.x, p.y - 2.5, p.z); 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); float distFromCenter = hexDistance(hex.axial);
int fftIndex = int(clamp(distFromCenter + 1.0, 0.0, 511.0)); 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 syncsBass = clamp((syncs[1] + syncs[2] + syncs[3]), 0., 1.);
float fogAmount2 = 1.0 - exp(-t * fogAmount); 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 // highlight color
vec3 fogColor = mix(vec3(0.2706, 0.2706, 0.2863), vec3(0.2314, 0.2314, 0.2314), // Main 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)); pow(sunAmount, syncsBass * 1.0));