replace rainbow hex edge shimmer with theme color gradient
This commit is contained in:
parent
5d472ab086
commit
8f09492fc2
1 changed files with 9 additions and 9 deletions
|
|
@ -22,9 +22,11 @@ float sdHexagon(vec2 p, float r) {
|
||||||
return length(p) * sign(p.y);
|
return length(p) * sign(p.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rainbow from angle — color picker style
|
// Interpolate between three theme stops (t in [0,1])
|
||||||
vec3 hsv2rgb(float h) {
|
vec3 themeGradient(float t) {
|
||||||
return clamp(abs(mod(h * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
|
return t < 0.5
|
||||||
|
? mix(uC0.rgb, uC1.rgb, t * 2.0)
|
||||||
|
: mix(uC1.rgb, uC2.rgb, (t - 0.5) * 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
@ -73,15 +75,13 @@ void main() {
|
||||||
float edgeWidth = 5.0;
|
float edgeWidth = 5.0;
|
||||||
float edgeFactor = smoothstep(-edgeWidth, 0.0, d); // 0 at interior, 1 at edge
|
float edgeFactor = smoothstep(-edgeWidth, 0.0, d); // 0 at interior, 1 at edge
|
||||||
if (wf > 0.01 && edgeFactor > 0.0) {
|
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 angle = atan(p.y, p.x);
|
||||||
float hue = (angle + 3.14159) / 6.28318;
|
float t = fract((angle + 3.14159) / 6.28318 + center.x * 0.003 + center.y * 0.005);
|
||||||
// Shift hue by position so neighboring hexes have different phase
|
vec3 shimmerColor = themeGradient(t);
|
||||||
hue = fract(hue + center.x * 0.003 + center.y * 0.005);
|
|
||||||
vec3 rainbow = hsv2rgb(hue);
|
|
||||||
|
|
||||||
float shimmer = edgeFactor * wf;
|
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);
|
a = mix(a, 0.5, shimmer * 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue