pientä fixailua
This commit is contained in:
64
src/main.cpp
64
src/main.cpp
@ -270,8 +270,8 @@ int __cdecl main(int argc, char* argv[])
|
||||
for (int i = 0; i < (FFT_SIZE / 4); i++)
|
||||
{
|
||||
float gain = 50.0f;
|
||||
float alpha = 0.10f; // "Hidastaa" FFT:n piikkej<65>
|
||||
float threshhold = 0.05f; // Alin arvo mik<69> p<><70>stet<65><74>n shaderille (v<>hent<6E><74> "noisea")
|
||||
float alpha = 0.10f; // "Hidastaa" FFT:n piikkej<65>
|
||||
float threshhold = 0.05f; // Alin arvo mik<69> p<><70>stet<65><74>n shaderille (v<>hent<6E><74> "noisea")
|
||||
float x_t = fft_output[i] * gain;
|
||||
// Exponential smoothing kaava
|
||||
// s(t) = alpha*x(t)+(1-alpha)*s(t-1)
|
||||
@ -301,12 +301,12 @@ int __cdecl main(int argc, char* argv[])
|
||||
bool shapeJustStarted = false;
|
||||
|
||||
// Detect note change to start a new shape
|
||||
bool noteChanged = (captureSync - lastNote) * (captureSync - lastNote) > 0.0001f;
|
||||
bool noteChanged = (captureSync != lastNote) ? TRUE : FALSE;
|
||||
lastNote = captureSync;
|
||||
|
||||
|
||||
// If note changed and value is significant, start new shape
|
||||
if (captureSync > 0.001f && noteChanged) {
|
||||
if (noteChanged) {
|
||||
int index = currentShape * 4;
|
||||
|
||||
// Reset and activate current shape
|
||||
@ -345,10 +345,10 @@ int __cdecl main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// Bind and update u_ShapesTex
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glUniform1i(glGetUniformLocation(pidMain, "u_ShapesTex"), 0);
|
||||
glActiveTexture(GL_TEXTURE0 + 0);
|
||||
glBindTexture(GL_TEXTURE_2D, ShapesTex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SHAPES, SHAPES, GL_RGBA, GL_FLOAT, shapesData);
|
||||
glUniform1i(glGetUniformLocation(pidMain, "u_ShapesTex"), 2);
|
||||
|
||||
|
||||
/*
|
||||
@ -371,58 +371,6 @@ int __cdecl main(int argc, char* argv[])
|
||||
glUniform1fvProc(0, SU_NUMSYNCS + 1, syncs);
|
||||
glUniform1fvProc(20, FFT_SIZE / 4, fft_uniform);
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Hex Grid Builder
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
static float hexGridData[HEX_TEX_SIZE];
|
||||
|
||||
|
||||
float gap = 0.3f;
|
||||
|
||||
float cellW = 1.6f + 0.2f; // flat-to-flat width
|
||||
float cellH = (sqrtf(3.0f) / 2.0f) * cellW; // height based on regular hex geometry
|
||||
|
||||
float horizontalSpacing = 0.75f * cellW * (1.0f + gap); // 3/4 of width per column
|
||||
float verticalSpacing = cellH * (1.0f + gap); // full height per row
|
||||
|
||||
float rippleCenterX = 7.0f;
|
||||
float rippleCenterY = 7.0f;
|
||||
|
||||
Vec3 gridOffset = { horizontalSpacing * (GRID - 1) * 0.24f, -5.0f, verticalSpacing * (GRID - 1) * 0.24f };
|
||||
|
||||
for (int j = 0; j < GRID; ++j) {
|
||||
for (int i = 0; i < GRID; ++i) {
|
||||
// Offset every other column vertically
|
||||
float offsetZ = (i % 2 == 0) ? 0.0f : 0.5f * verticalSpacing;
|
||||
|
||||
float x = i * horizontalSpacing;
|
||||
float z = j * verticalSpacing + offsetZ;
|
||||
float y = 0.0f;
|
||||
|
||||
Vec3 hexPos = { x - gridOffset.x, y - gridOffset.y, z - gridOffset.z };
|
||||
|
||||
float dx = (float)i - rippleCenterX;
|
||||
float dy = (float)j - rippleCenterY;
|
||||
float hexDist = sqrtf(dx * dx + dy * dy);
|
||||
|
||||
int idx = (j * GRID + i) * 4;
|
||||
hexGridData[idx + 0] = hexPos.x;
|
||||
hexGridData[idx + 1] = hexPos.y;
|
||||
hexGridData[idx + 2] = hexPos.z;
|
||||
hexGridData[idx + 3] = hexDist;
|
||||
}
|
||||
}
|
||||
|
||||
// Bind and update u_hexGridTex
|
||||
glActiveTexture(GL_TEXTURE0 + 1);
|
||||
glBindTexture(GL_TEXTURE_2D, hexGridTex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GRID, GRID, GL_RGBA, GL_FLOAT, hexGridData);
|
||||
glUniform1i(glGetUniformLocation(pidMain, "u_hexGridTex"), 1);
|
||||
|
||||
glRects(-1, -1, 1, 1);
|
||||
|
||||
// render "post process" using the opengl backbuffer
|
||||
|
||||
Reference in New Issue
Block a user