Skip to content

Commit f1f9e7b

Browse files
ShadertoyBackground
1 parent 8ddb394 commit f1f9e7b

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"dependencies": {
1212
"react": "^17.0.2",
1313
"react-dom": "^17.0.2",
14-
"react-router-dom": "^6.27.0"
14+
"react-router-dom": "^6.27.0",
15+
"shadertoy-react": "^1.1.2"
1516
},
1617
"devDependencies": {
1718
"@monaco-editor/react": "^4.3.1",
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
//@ts-ignore
2+
import ShadertoyReact from "shadertoy-react";
3+
//Above is like only JS, but it works with react.
4+
//@ts-check
5+
6+
const fragmentShader = `
7+
void main(void) {
8+
vec2 uv = gl_FragCoord.xy/iResolution.xy;
9+
vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
10+
gl_FragColor = vec4(col*0.25 ,1.0);
11+
}
12+
`;
13+
114
export function Background(): JSX.Element {
215
return <>
3-
<div className = "bg-black"></div>
16+
<div className="-z-1 fixed top-0 left-0 w-full h-full">
17+
<ShadertoyReact fs={fragmentShader} />
18+
</div>
419
</>;
520
}

src/app.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,23 @@ import PGASGame from './Pages/ProjectsPage/PGASGame';
1010

1111
export const App: React.FC = () => {
1212
return <>
13-
{<Background />}
13+
{<Background />}
1414

1515
{/* Top bar stuff */}
16-
{<Navbar />}
16+
<div className='z-1 relative'>
17+
{<Navbar />}
18+
</div>
1719

1820
{/* Main page stuff */}
19-
<Routes>
20-
<Route path="/" element={<Home />} />
21-
<Route path="/proj" element={<Projects />} />
21+
<div className='z-0 pt-2'>
22+
<Routes>
23+
<Route path="/" element={<Home />} />
24+
<Route path="/proj" element={<Projects />} />
2225

23-
{/* Side Pages */}
24-
<Route path="/proj-first-glsl" element={<FirstGLSL />} />
25-
<Route path="/proj-pgas-game" element={<PGASGame />} />
26-
</Routes>
26+
{/* Side Pages */}
27+
<Route path="/proj-first-glsl" element={<FirstGLSL />} />
28+
<Route path="/proj-pgas-game" element={<PGASGame />} />
29+
</Routes>
30+
</div>
2731
</>;
2832
}

0 commit comments

Comments
 (0)