Compare commits
1 Commits
2e7f3b6cc7
...
750fc2f7d5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
750fc2f7d5 |
@ -17,12 +17,15 @@ function App() {
|
|||||||
localStorage.getItem("token") || ""
|
localStorage.getItem("token") || ""
|
||||||
);
|
);
|
||||||
const [theme, setTheme] = useState<string>("default");
|
const [theme, setTheme] = useState<string>("default");
|
||||||
|
const [isShaderTheme, setIsShaderTheme] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (theme !== "default") {
|
if (theme !== "default") {
|
||||||
document.body.classList.add("shader-theme");
|
document.body.classList.add("shader-theme");
|
||||||
|
setIsShaderTheme(true);
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.remove("shader-theme");
|
document.body.classList.remove("shader-theme");
|
||||||
|
setIsShaderTheme(false);
|
||||||
}
|
}
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
@ -85,7 +88,7 @@ function App() {
|
|||||||
<option value="clouds">Clouds Theme</option>
|
<option value="clouds">Clouds Theme</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<ShaderBackground theme= {theme} />
|
{isShaderTheme && <ShaderBackground theme= {theme} />}
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<PersonList people={people} />} />
|
<Route path="/" element={<PersonList people={people} />} />
|
||||||
<Route path="/games" element={<GameList />} />
|
<Route path="/games" element={<GameList />} />
|
||||||
|
|||||||
@ -154,6 +154,7 @@ export const ShaderBackground: React.FC<ShaderBackgroundProps> = ({
|
|||||||
shader_code = CLOUDS_SHADER_CODE;
|
shader_code = CLOUDS_SHADER_CODE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
console.error("Unknown shader theme:", theme);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,8 @@ out vec4 FragColor;
|
|||||||
|
|
||||||
float orb(vec3 p) {
|
float orb(vec3 p) {
|
||||||
// orb time
|
// orb time
|
||||||
float t = T * 4.f;
|
float t = T * 4.;
|
||||||
return length(p - vec3(sin(sin(t * .2f) + t * .4f) * 6.f, 1.f + sin(sin(t * .5f) + t * .2f) * 4.f, 12.f + T + cos(t * .3f) * 8.f));
|
return length(p - vec3(sin(sin(t * .2) + t * .4) * 6., 1. + sin(sin(t * .5) + t * .2) * 4., 12. + T + cos(t * .3) * 8.));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainImage(out vec4 o, vec2 u) {
|
void mainImage(out vec4 o, vec2 u) {
|
||||||
@ -21,41 +21,42 @@ void mainImage(out vec4 o, vec2 u) {
|
|||||||
u = (u + u - p.xy) / p.y;
|
u = (u + u - p.xy) / p.y;
|
||||||
|
|
||||||
// camera movement
|
// camera movement
|
||||||
u += vec2(cos(t * .1f) * .3f, cos(t * .3f) * .1f);
|
u += vec2(cos(t * .1) * .3, cos(t * .3) * .1);
|
||||||
|
|
||||||
for(o *= i; i++ < 128.f;
|
for(o *= i; i++ < 128.;
|
||||||
|
|
||||||
// accumulate distance
|
// accumulate distance
|
||||||
d += s = min(.03f + .2f * abs(s), e = max(.5f * e, .01f)),
|
d += s = min(.03 + .2 * abs(s), e = max(.5 * e, .01)),
|
||||||
|
|
||||||
// grayscale color and orb light
|
// grayscale color and orb light
|
||||||
o += 1.f / (s + e * 3.f))
|
o += 1. / (s + e * 3.))
|
||||||
|
|
||||||
// noise loop start, march
|
// noise loop start, march
|
||||||
for(p = vec3(u * d, d + t), // p = ro + rd *d, p.z + t;
|
for(p = vec3(u * d, d + t), // p = ro + rd *d, p.z + t;
|
||||||
|
|
||||||
// entity (orb)
|
// entity (orb)
|
||||||
e = orb(p) - .1f,
|
e = orb(p) - .1,
|
||||||
|
|
||||||
// spin by t, twist by p.z
|
// spin by t, twist by p.z
|
||||||
p.xy *= mat2(cos(.1f * t + p.z / 8.f + vec4(0, 33, 11, 0))),
|
p.xy *= mat2(cos(.1 * t + p.z / 8. + vec4(0, 33, 11, 0))),
|
||||||
|
|
||||||
// mirrored planes 4 units apart
|
// mirrored planes 4 units apart
|
||||||
s = 4.f - abs(p.y),
|
s = 4. - abs(p.y),
|
||||||
|
|
||||||
// noise starts at .8 up to 32., grow by a+=a
|
// noise starts at .8 up to 32., grow by a+=a
|
||||||
a = .8f; a < 32.f; a += a)
|
a = .8; a < 32.; a += a)
|
||||||
|
|
||||||
// apply turbulence
|
// apply turbulence
|
||||||
p += cos(.7f * t + p.yzx) * .2f,
|
p += cos(.7 * t + p.yzx) * .2,
|
||||||
|
|
||||||
// apply noise
|
// apply noise
|
||||||
s -= abs(dot(sin(.1f * t + p * a), .6f + p - p)) / a;
|
s -= abs(dot(sin(.1 * t + p * a), .6 + p - p)) / a;
|
||||||
|
|
||||||
// tanh tonemap, brightness, light off-screen
|
// tanh tonemap, brightness, light off-screen
|
||||||
o = tanh(o / 1e1f);
|
o = tanh(o / 1e1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
mainImage(FragColor, gl_FragCoord.xy);
|
mainImage(FragColor, gl_FragCoord.xy);
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user