4118k
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
#define BREAK_COMPATIBILITY 0
|
#define BREAK_COMPATIBILITY 0
|
||||||
#else
|
#else
|
||||||
#define OPENGL_DEBUG 0
|
#define OPENGL_DEBUG 0
|
||||||
#define FULLSCREEN 0
|
#define FULLSCREEN 1
|
||||||
#define DESPERATE 0
|
#define DESPERATE 0
|
||||||
#define BREAK_COMPATIBILITY 0
|
#define BREAK_COMPATIBILITY 0
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,7 +6,7 @@ const float TAU = (2. * PI);
|
|||||||
const float PHI = sqrt(5.) * 0.5 + 0.5;
|
const 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];
|
||||||
|
|
||||||
// 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){
|
||||||
@ -37,7 +37,6 @@ float noise(in vec2 xy, in float seed) {
|
|||||||
// shorted functions
|
// shorted functions
|
||||||
vec3 no(vec3 v) { return normalize(v); }
|
vec3 no(vec3 v) { return normalize(v); }
|
||||||
float cl(float a, float b, float c) { return clamp(a,b,c); }
|
float cl(float a, float b, float c) { return clamp(a,b,c); }
|
||||||
float lev3(vec3 s) { return length(s); }
|
|
||||||
float lev2(vec2 s) { return length(s); }
|
float lev2(vec2 s) { return length(s); }
|
||||||
|
|
||||||
|
|
||||||
@ -140,7 +139,7 @@ vec2 mapScene(vec3 p) {
|
|||||||
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(syncs[0] * 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 + noise), 0., 15.);
|
||||||
vec3 r = vec3(hex.local.x + offset.x,hex.local.y,hex.local.z+offset.y);
|
vec3 r = vec3(hex.local.x + offset.x,hex.local.y,hex.local.z+offset.y);
|
||||||
// r.yz *= rot2D(PI * 0.5);
|
// r.yz *= rot2D(PI * 0.5);
|
||||||
@ -220,7 +219,7 @@ vec3 addPointLight(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPo
|
|||||||
// Light vector from surface to light
|
// Light vector from surface to light
|
||||||
//float roughness = 1.0;
|
//float roughness = 1.0;
|
||||||
vec3 lightDir = lightPos - worldPos;
|
vec3 lightDir = lightPos - worldPos;
|
||||||
float lightDistance = lev3(lightDir);
|
float lightDistance = length(lightDir);
|
||||||
lightDir = no(lightDir);
|
lightDir = no(lightDir);
|
||||||
|
|
||||||
// Attenuation (quadratic falloff)
|
// Attenuation (quadratic falloff)
|
||||||
@ -255,17 +254,15 @@ vec3 calcNormal(vec3 pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec3 pal(float color) {
|
vec3 pal(float color) {
|
||||||
|
//color *= 0.2;
|
||||||
color *= 0.2;
|
|
||||||
|
|
||||||
vec3 c = palette(color, 0.25, 0.63);
|
vec3 c = palette(color, 0.25, 0.63);
|
||||||
vec3 c2 = palette(color, 0.5 ,0.2);
|
vec3 c2 = palette(color, 0.5 ,0.2);
|
||||||
|
float t = cl((u_time - 129.0) / 2.0, 0.0, 1.0); // Smoothly ramps from 0 to 1 after 12s
|
||||||
float t = cl((syncs[0] - 129.0) / 2.0, 0.0, 1.0); // Smoothly ramps from 0 to 1 after 12s
|
|
||||||
return mix(c, c2, t); // Blend between c and c2 over ~2 seconds
|
return mix(c, c2, t); // Blend between c and c2 over ~2 seconds
|
||||||
//return c2;
|
//return c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) {
|
vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) {
|
||||||
|
|
||||||
float syncsBass = cl((syncs[1] + syncs[2] + syncs[3]), 0., 1.);
|
float syncsBass = cl((syncs[1] + syncs[2] + syncs[3]), 0., 1.);
|
||||||
@ -277,21 +274,22 @@ vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float fogAmount) {
|
|||||||
pow(sunAmount, syncsBass * 1.0));
|
pow(sunAmount, syncsBass * 1.0));
|
||||||
return mix(col, fogColor, fogAmount2);
|
return mix(col, fogColor, fogAmount2);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 camPos) {
|
vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 caPos) {
|
||||||
vec3 outMaterial = vec3(0.0);
|
vec3 outMaterial = vec3(0.0);
|
||||||
|
|
||||||
outMaterial = pal(p.y*p.y*0.01);
|
outMaterial = pal(p.y*p.y*0.01);
|
||||||
|
|
||||||
vec3 lights = vec3(0.);
|
vec3 lights = vec3(0.);
|
||||||
//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), 20.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.);
|
||||||
float particlePos = (syncs[0] * 0.5) + syncs[5];
|
float particlePos = (u_time * 0.5) + syncs[5];
|
||||||
|
|
||||||
// Map param to angle
|
// Map param to angle
|
||||||
float particleStartPos = particlePos * 2.0 * PI;
|
float particleStartPos = particlePos * 2.0 * PI;
|
||||||
@ -310,11 +308,11 @@ vec3 shading(vec3 p, vec3 n, vec3 dir, vec3 camPos) {
|
|||||||
|
|
||||||
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.6;
|
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;
|
||||||
|
|
||||||
@ -352,7 +350,7 @@ vec3 getCameraRayDir(vec2 uv, vec3 camPos, vec3 camTarget, float fov) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec3 render(vec2 uv) {
|
vec3 render(vec2 uv) {
|
||||||
vec3 camPos = vec3(-20.0 + sin(syncs[0] * 0.25) * 5, abs(sin(syncs[0] * 0.25) * 10) + 25.0, -20.0);
|
vec3 camPos = vec3(-20.0 + sin(u_time * 0.25) * 5, abs(sin(u_time * 0.25) * 10) + 25.0, -20.0);
|
||||||
// vec3 camTarget = vec3(0.) // Adjust target as needed
|
// vec3 camTarget = vec3(0.) // Adjust target as needed
|
||||||
//float fov = 1.0;
|
//float fov = 1.0;
|
||||||
|
|
||||||
@ -365,21 +363,32 @@ vec3 render(vec2 uv) {
|
|||||||
|
|
||||||
if(t.x > 0.0) {
|
if(t.x > 0.0) {
|
||||||
vec3 nor = calcNormal(hitPos);
|
vec3 nor = calcNormal(hitPos);
|
||||||
col = shading(hitPos, nor, rayDir, camPos);
|
//col = shading(hitPos, nor, rayDir, camPos);
|
||||||
|
|
||||||
|
//vec3 mat = vec3(0.0);
|
||||||
|
vec3 mat = pal(hitPos.y*hitPos.y*0.01);
|
||||||
|
|
||||||
|
//vec3 lights = vec3(0.);
|
||||||
|
vec3 lights = addPointLight(vec3(0., 20.0, 0.), vec3(0.7, 0.3, 0.7), 15.0, hitPos, rayDir, nor);
|
||||||
|
mat *= max(vec3(0.), lights); // output with lights;
|
||||||
|
col = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
//glow from the bottom
|
//glow from the bottom
|
||||||
vec3 bGlowColor = pal(syncs[0] * .075); // color change
|
vec3 bGlowColor = pal(u_time * .075); // color change
|
||||||
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) * 9900.;
|
vec3 bGlowLevel = bGlowColor * exp(-(p.y + 0.0) / bGlowDistance) * 10000.;
|
||||||
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
|
||||||
|
/*
|
||||||
float fogAmount = 0.01;
|
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));
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user