replace rainbow hex edge shimmer with theme color gradient

This commit is contained in:
Damocles 2026-04-13 21:21:46 +02:00
parent 5d472ab086
commit 8f09492fc2

View file

@ -22,9 +22,11 @@ float sdHexagon(vec2 p, float r) {
return length(p) * sign(p.y);
}
// Rainbow from angle — color picker style
vec3 hsv2rgb(float h) {
return clamp(abs(mod(h * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
// Interpolate between three theme stops (t in [0,1])
vec3 themeGradient(float t) {
return t < 0.5
? mix(uC0.rgb, uC1.rgb, t * 2.0)
: mix(uC1.rgb, uC2.rgb, (t - 0.5) * 2.0);
}
void main() {
@ -73,15 +75,13 @@ void main() {
float edgeWidth = 5.0;
float edgeFactor = smoothstep(-edgeWidth, 0.0, d); // 0 at interior, 1 at edge
if (wf > 0.01 && edgeFactor > 0.0) {
// Angle around hex center → hue
// Vary shimmer color across theme gradient using angle + position
float angle = atan(p.y, p.x);
float hue = (angle + 3.14159) / 6.28318;
// Shift hue by position so neighboring hexes have different phase
hue = fract(hue + center.x * 0.003 + center.y * 0.005);
vec3 rainbow = hsv2rgb(hue);
float t = fract((angle + 3.14159) / 6.28318 + center.x * 0.003 + center.y * 0.005);
vec3 shimmerColor = themeGradient(t);
float shimmer = edgeFactor * wf;
rgb = mix(rgb, rainbow, shimmer * 0.8);
rgb = mix(rgb, shimmerColor, shimmer * 0.8);
a = mix(a, 0.5, shimmer * 0.6);
}