Compare commits
3 Commits
b62df3ff88
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ad8abed4d2 | |||
| dea77c1ec7 | |||
| bd8c146348 |
@ -5,7 +5,7 @@ float PHI = sqrt(5.) * 0.5 + 0.5;
|
|||||||
layout(location = 0) uniform float syncs[11];
|
layout(location = 0) uniform float syncs[11];
|
||||||
layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4
|
layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4
|
||||||
float u_time = syncs[0];
|
float u_time = syncs[0];
|
||||||
float u_time = syncs[0];
|
//float u_time = syncs[0];
|
||||||
|
|
||||||
// paletti muunnos: arg 0.8 --> 0.5
|
// paletti muunnos: arg 0.8 --> 0.5
|
||||||
vec3 palette(float t, float arg, float arg2){
|
vec3 palette(float t, float arg, float arg2){
|
||||||
@ -105,14 +105,13 @@ vec2 mapScene(vec3 p) {
|
|||||||
float minDist = 1e9;
|
float minDist = 1e9;
|
||||||
for (int dx = -repeat; dx <= repeat; ++dx) {
|
for (int dx = -repeat; dx <= repeat; ++dx) {
|
||||||
for (int dy = -repeat; dy <= repeat; ++dy) {
|
for (int dy = -repeat; dy <= repeat; ++dy) {
|
||||||
vec2 offset = vec2(dx, dy);
|
|
||||||
vec3 hexpos = vec3(p.x-dx, p.y-8.0, p.z-dy);
|
vec3 hexpos = vec3(p.x-dx, p.y-8.0, p.z-dy);
|
||||||
HexData hex = hexTile(hexpos, 1.1);
|
HexData hex = hexTile(hexpos, 1.1);
|
||||||
float distFromCenter = hexDistance(hex.axial);
|
float distFromCenter = hexDistance(hex.axial);
|
||||||
int fftIndex = int(cl(distFromCenter + 1., 0.0, 511.0));
|
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(u_time * 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.);
|
float hexHeight = cl(1.0 + (fft_output[fftIndex] * 2.0) * cl(distFromCenter*0.25, 0.6, 1.5) + noise, 0., 9.);
|
||||||
vec3 r = vec3(hex.local.x + offset.x,hex.local.y,hex.local.z+offset.y);
|
vec3 r = vec3(hex.local.x + dx,hex.local.y,hex.local.z+dy);
|
||||||
// r.yz *= rot2D(PI * 0.5);
|
// r.yz *= rot2D(PI * 0.5);
|
||||||
r.xz *= rot2D(0.5);
|
r.xz *= rot2D(0.5);
|
||||||
float d = fHexagonCircumcircle(r, vec2(0.85, hexHeight));
|
float d = fHexagonCircumcircle(r, vec2(0.85, hexHeight));
|
||||||
@ -231,20 +230,23 @@ vec3 pal(float color) {
|
|||||||
//return c2;
|
//return c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
vec3 applyFog(vec3 color, float dist, vec3 fogColor, float fogDensity) {
|
||||||
vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) {
|
float fogFactor = exp(-dist * fogDensity);
|
||||||
|
return mix(fogColor, color, fogFactor);
|
||||||
float syncsBass = cl((syncs[1] + syncs[2] + syncs[3]), 0., 1.);
|
|
||||||
|
|
||||||
float fogAmount2 = 1.0 - exp(-t * fogAmount);
|
|
||||||
float sunAmount = max(dot(rd, lightDir), 1.0);
|
|
||||||
// highlight color
|
|
||||||
vec3 fogColor = mix(vec3(0.3, 0.3, 0.3), vec3(0.2, 0.2, 0.2), // Main color
|
|
||||||
pow(sunAmount, syncsBass * 1.0));
|
|
||||||
return mix(col, fogColor, fogAmount2);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
//vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) {
|
||||||
|
//
|
||||||
|
// float syncsBass = cl((syncs[1]), 0., 1.);
|
||||||
|
//
|
||||||
|
// float fogAmount2 = 1.0 - exp(-t * fogAmount);
|
||||||
|
// float sunAmount = max(dot(rd, lightDir), 1.0);
|
||||||
|
// // highlight color
|
||||||
|
// vec3 fogColor = vec3(0.2, 0.2, 0.2);
|
||||||
|
// return mix(col, fogColor, fogAmount2);
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*
|
||||||
vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 caPos) {
|
vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 caPos) {
|
||||||
vec3 outMaterial = vec3(0.0);
|
vec3 outMaterial = vec3(0.0);
|
||||||
|
|
||||||
@ -254,7 +256,7 @@ vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 caPos) {
|
|||||||
//lights += phongLighting(p, n, camPos, dir, vec3(0.51), outMaterial);
|
//lights += phongLighting(p, n, camPos, dir, vec3(0.51), outMaterial);
|
||||||
lights += addPointLight(vec3(0., 20.0, 0.), vec3(0.7, 0.3, 0.7), 15.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
|
// LIGHT CHANGING WITH CIRCLE RADIUS
|
||||||
float maxRadius = 25.; // Circle radius
|
float maxRadius = 25.; // Circle radius
|
||||||
float particleHeight = 15.; //(syncs[5] * 40.);
|
float particleHeight = 15.; //(syncs[5] * 40.);
|
||||||
@ -276,18 +278,18 @@ vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 caPos) {
|
|||||||
//res = opU(res, vec2(sdSphere(p - objPos, sphereRadius), 1.));
|
//res = opU(res, vec2(sdSphere(p - objPos, sphereRadius), 1.));
|
||||||
|
|
||||||
lights += addPointLight(objPos, vec3(0.33, 0.91, 0.93), 30.0, p, dir, n);
|
lights += addPointLight(objPos, vec3(0.33, 0.91, 0.93), 30.0, p, dir, n);
|
||||||
*/
|
|
||||||
/*
|
|
||||||
vec3 lightDir = vec3(0., 2., 3);
|
vec3 lightDir = vec3(0., 2., 3);
|
||||||
float ind = cl(dot(n, no(lightDir * vec3(.0, 1.0, -2.0))), 0.0, 1.0);
|
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.4;
|
lights += vec3(0.6, 0.6, 0.6) * ind * 0.4;
|
||||||
*/
|
|
||||||
|
|
||||||
outMaterial *= max(vec3(0.), lights); // output with lights;
|
outMaterial *= max(vec3(0.), lights); // output with lights;
|
||||||
|
|
||||||
return outMaterial;
|
return outMaterial;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
vec3 postProcess(vec3 col) {
|
vec3 postProcess(vec3 col) {
|
||||||
// Contrast
|
// Contrast
|
||||||
float contrast = 0.85;
|
float contrast = 0.85;
|
||||||
@ -308,6 +310,7 @@ vec3 postProcess(vec3 col) {
|
|||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// RENDERING //
|
// RENDERING //
|
||||||
@ -338,7 +341,7 @@ vec3 render(vec2 uv) {
|
|||||||
vec3 mat = pal(hitPos.y*hitPos.y*0.01);
|
vec3 mat = pal(hitPos.y*hitPos.y*0.01);
|
||||||
|
|
||||||
//vec3 lights = vec3(0.);
|
//vec3 lights = vec3(0.);
|
||||||
vec3 lights = addPointLight(vec3(0., 20.0, 0.), vec3(0.7, 0.3, 0.7), 15.0, hitPos, rayDir, nor);
|
vec3 lights = addPointLight(vec3(0., 20.0, 0.), vec3(0.7, 0.3, 0.7), 5.0, hitPos, rayDir, nor);
|
||||||
mat *= max(vec3(0.), lights); // output with lights;
|
mat *= max(vec3(0.), lights); // output with lights;
|
||||||
col = mat;
|
col = mat;
|
||||||
}
|
}
|
||||||
@ -348,22 +351,27 @@ vec3 render(vec2 uv) {
|
|||||||
float bGlowDistance = 0.8;
|
float bGlowDistance = 0.8;
|
||||||
vec3 p = camPos + t.x * rayDir;
|
vec3 p = camPos + t.x * rayDir;
|
||||||
|
|
||||||
vec3 bGlowLevel = bGlowColor * exp(-(p.y + 0.0) / bGlowDistance) * 10000.;
|
vec3 bGlowLevel = bGlowColor * exp(-(p.y + 0.0) / bGlowDistance) * 9e3;
|
||||||
col += bGlowLevel;
|
col += bGlowLevel;
|
||||||
col = clamp(mix(bGlowLevel, col, t.z), 0.0, 1.0);
|
col = clamp(mix(bGlowLevel, col, t.z), 0.0, 1.0);
|
||||||
|
|
||||||
// distance fog + bass thunder
|
// distance fog + bass thunder
|
||||||
/*
|
vec3 fogColor = vec3(0.1, 0.2, 0.3); // light gray-blue fog
|
||||||
float fogAmount = 0.01;
|
float fogDensity = 5e-3;
|
||||||
col = col * exp(-t.x * fogAmount) + applyFog(col, t.x, rayDir, vec3(0., -0.5, 1.8), fogAmount) * (1.0 - exp(-t.x * fogAmount));
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
col = applyFog(col, t.x, fogColor, fogDensity);
|
||||||
|
//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;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 finalColor = render(getUV());
|
vec3 finalColor = render(getUV());
|
||||||
finalColor = postProcess(finalColor);
|
//finalColor = postProcess(finalColor);
|
||||||
|
|
||||||
|
finalColor = mix(finalColor, smoothstep(0.0, 1.0, finalColor), 0.8); // contrast
|
||||||
|
finalColor = pow(finalColor, vec3(.4)); // gamma 2.2
|
||||||
|
|
||||||
o = vec4(finalColor, 1.);
|
o = vec4(finalColor, 1.);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user