scaledFFT

This commit is contained in:
Teemu Järvisalo
2025-07-24 23:50:49 +03:00
parent 62e58d0e1f
commit 77e5f0fc70
2 changed files with 81 additions and 105 deletions

View File

@ -129,7 +129,7 @@ vec2 mapScene(in vec3 p) {
float gridsize = 16.0; // or GRID if you want full size
//float hexGap = 0.2;
for(float j = 0.; j < gridsize; j++) {
for(float i = 0.; i < gridsize; i++) {
ivec2 texSize = textureSize(u_hexGridTex, 0);
@ -142,7 +142,7 @@ vec2 mapScene(in vec3 p) {
// Optionally use hexDist for ripple effect with FFT
int index = clamp(int((hexDist / 34.)*512.), 0, 511);
float hexSize = fft_output[index] * 5.0;
float hexSize = getScaledFFT(index, 15. ,0.);
float a = sdHex(p - hexPos, 1.0 + hexSize, 0.0);
res = min(res, vec2(a, 1.));
@ -323,10 +323,10 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
}
vec3 lights = vec3(0.);
lights += addPointLight(vec3(0., 40.0, -10.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
//lights += addPointLight(vec3(0., 40.0, -10.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
//lights += addPointLight(vec3(0., 20.0, 15.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
// LIGHTS IN HEX GRID PATTERN
float gridsize = 16.0; // or GRID if you want full size
vec3 p = vec3(0.);
for(float j = 0.; j < gridsize; j++) {
@ -341,14 +341,13 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
// Optionally use hexDist for ripple effect with FFT
int index = clamp(int((hexDist / 34.)*512.), 0, 511);
float hexSize = fft_output[index] * 5.0;
float hexSize = getScaledFFT(index, 15. ,0.);
//float a = sdHex(p - hexPos, 1.0 + hexSize, 0.0);
lights += addPointLightNoShadow(vec3(hexPos.x, (hexPos.y + hexSize) + 3., hexPos.z), palette(hexSize* 1.5), clamp(hexSize * 3., 0., 1.) ,v, dir, n, shininess);
lights += addPointLightNoShadow(vec3(hexPos.x, (hexPos.y + hexSize) + 2., hexPos.z), palette(hexSize* 1.5), clamp(hexSize * 5., 0., 1.) ,v, dir, n, shininess);
}
}
vec3 lightDir = vec3(0., 1., -3);
//float sun_dif = clamp(dot(n, lightDir), 0., 1.);
//float shadow = softshadow(v + n * 0.01, lightDir, .01, 30., 18.);