Skip to content

Commit af85e08

Browse files
authored
Merge pull request #117 from CreativeCodeBerlin/self-host-shadertoy-artwort
self-hosting shadertoy sketches
2 parents ad02b17 + fe342eb commit af85e08

8 files changed

Lines changed: 8615 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Welcome to the Creative Code Berlin website source code, you can visit our websi
88

99
## Adding Artworks
1010

11-
Add the generated JSON generated to the [project.js file](/assets/projects.js)
11+
Add the generated JSON generated to the [project.js file](/assets/projects.js).
12+
We must host ShaderToy sketches ourselves since 2026. [Here's how to do it](docs/shadertoy.md).
1213

1314

1415
## Development Instructions

assets/projects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default [
22
{
3-
"url": "https://www.shadertoy.com/embed/wsB3Rt?gui=false&t=10&paused=false&muted=true",
3+
"url": "https://creativecode.berlin/shadertoys/?shader=wsB3Rt",
44
"author": "Kazik",
55
"author_url": "https://xemantic.com/",
66
"color": "black",

docs/shader-request.jpg

22.5 KB
Loading

docs/shadertoy.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Self-hosting sketches from ShaderToy
2+
3+
1) Visit the ShaderToy sketch in your browser (needed because of Cloudflare validation)
4+
2) Watch network traffic in the development console. Look for the request that downloads a JSON with the sketch's content:
5+
![screenshot of request](shader-request.jpg)
6+
3) Save the response into `public/shadertoys` as `sk3tch.json` (keeping the sketch's ID).
7+
4) In `assets/projects.js` use this URL: `https://creativecode.berlin/shadertoys/?shader=sk3tch`
8+
9+
### Background
10+
11+
To make this work, we are hosting three files that come from ShaderToy:
12+
- effect.js
13+
- piLibs.js
14+
- index.html
15+
16+
The HTML has a few embedded scripts. These have been manually edited so the sketch is shown in embed mode, and no requests are made to unneeded assets like button images. The initial logic made a POST request to `/shadertoy`. This has been replaced with the `?shader=` query parameter.

0 commit comments

Comments
 (0)