create-shaderpad 1.0.0-beta.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +222 -0
- package/package.json +33 -0
- package/template-basic-js/index.html +12 -0
- package/template-basic-js/package-lock.json +1148 -0
- package/template-basic-js/package.json +18 -0
- package/template-basic-js/public/favicon.svg +1 -0
- package/template-basic-js/src/main.js +12 -0
- package/template-basic-js/src/shaders/fragment.glsl +46 -0
- package/template-basic-js/vite.config.js +9 -0
- package/template-basic-ts/index.html +12 -0
- package/template-basic-ts/package-lock.json +1163 -0
- package/template-basic-ts/package.json +19 -0
- package/template-basic-ts/public/favicon.svg +1 -0
- package/template-basic-ts/src/main.ts +12 -0
- package/template-basic-ts/src/shaders/fragment.glsl +46 -0
- package/template-basic-ts/src/shaders.d.ts +4 -0
- package/template-basic-ts/src/vite-env.d.ts +1 -0
- package/template-basic-ts/tsconfig.json +20 -0
- package/template-basic-ts/vite.config.ts +9 -0
- package/template-face-js/index.html +12 -0
- package/template-face-js/package-lock.json +1162 -0
- package/template-face-js/package.json +20 -0
- package/template-face-js/public/favicon.svg +1 -0
- package/template-face-js/src/main.js +51 -0
- package/template-face-js/src/shaders/fragment.glsl +17 -0
- package/template-face-js/vite.config.js +13 -0
- package/template-face-ts/index.html +12 -0
- package/template-face-ts/package-lock.json +1177 -0
- package/template-face-ts/package.json +21 -0
- package/template-face-ts/public/favicon.svg +1 -0
- package/template-face-ts/src/main.ts +51 -0
- package/template-face-ts/src/shaders/fragment.glsl +17 -0
- package/template-face-ts/src/shaders.d.ts +4 -0
- package/template-face-ts/src/vite-env.d.ts +1 -0
- package/template-face-ts/tsconfig.json +20 -0
- package/template-face-ts/vite.config.ts +13 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shaderpad-template-face-js",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@mediapipe/tasks-vision": "^0.10.32",
|
|
13
|
+
"shaderpad": "1.0.0-beta.67"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@vitejs/plugin-basic-ssl": "^2.2.0",
|
|
17
|
+
"vite": "^7.3.1",
|
|
18
|
+
"vite-plugin-glsl": "^1.5.6"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg clip-rule="evenodd" fill="#000" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h1024v1024h-1024z" fill="none"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 -182.973 319.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 73.0271 1087.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 438.973 192.61)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 -182.973 831.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 438.973 704.61)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 694.973 -63.3896)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 73.0271 575.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 694.973 448.61)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 585.027 1087.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 1206.97 -63.3896)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 585.027 575.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 1206.97 448.61)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 329.027 319.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 950.973 192.61)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 -.492608 .492608 0 329.027 831.39)"/><path d="m583.404 728.719h-389.762c0-107.63 87.251-194.881 194.881-194.881s194.881 87.251 194.881 194.881z" transform="matrix(0 .492608 -.492608 0 950.973 704.61)"/></svg>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import ShaderPad from 'shaderpad';
|
|
2
|
+
import autosize from 'shaderpad/plugins/autosize';
|
|
3
|
+
import face from 'shaderpad/plugins/face';
|
|
4
|
+
import helpers from 'shaderpad/plugins/helpers';
|
|
5
|
+
import { createFullscreenCanvas } from 'shaderpad/util';
|
|
6
|
+
|
|
7
|
+
import fragmentShaderSrc from './shaders/fragment.glsl';
|
|
8
|
+
|
|
9
|
+
async function getWebcam() {
|
|
10
|
+
const video = document.createElement('video');
|
|
11
|
+
video.autoplay = true;
|
|
12
|
+
video.muted = true;
|
|
13
|
+
video.playsInline = true;
|
|
14
|
+
|
|
15
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
16
|
+
video: {
|
|
17
|
+
facingMode: 'user',
|
|
18
|
+
},
|
|
19
|
+
audio: false,
|
|
20
|
+
});
|
|
21
|
+
video.srcObject = stream;
|
|
22
|
+
await video.play();
|
|
23
|
+
return video;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function main() {
|
|
27
|
+
const video = await getWebcam();
|
|
28
|
+
const canvas = createFullscreenCanvas();
|
|
29
|
+
const shader = new ShaderPad(fragmentShaderSrc, {
|
|
30
|
+
plugins: [
|
|
31
|
+
autosize(),
|
|
32
|
+
helpers(),
|
|
33
|
+
face({
|
|
34
|
+
textureName: 'u_webcam',
|
|
35
|
+
options: {
|
|
36
|
+
maxFaces: 1,
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
canvas,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
shader.initializeTexture('u_webcam', video);
|
|
44
|
+
shader.play(() => {
|
|
45
|
+
shader.updateTextures({ u_webcam: video });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
main().catch(error => {
|
|
50
|
+
console.error(error);
|
|
51
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#version 300 es
|
|
2
|
+
precision highp float;
|
|
3
|
+
|
|
4
|
+
in vec2 v_uv;
|
|
5
|
+
uniform sampler2D u_webcam;
|
|
6
|
+
out vec4 outColor;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
vec2 webcamUV = fitCover(vec2(1.0 - v_uv.x, v_uv.y), vec2(textureSize(u_webcam, 0)));
|
|
10
|
+
vec3 color = texture(u_webcam, webcamUV).rgb;
|
|
11
|
+
color = mix(color, vec3(0.0, 1.0, 0.0), inFace(webcamUV));
|
|
12
|
+
color = mix(color, vec3(1.0, 0.0, 0.0), inMouth(webcamUV));
|
|
13
|
+
color = mix(color, vec3(0.0), inInnerMouth(webcamUV));
|
|
14
|
+
color = mix(color, vec3(1.0), inEye(webcamUV));
|
|
15
|
+
color = mix(color, vec3(0.0, 0.0, 1.0), inEyebrow(webcamUV));
|
|
16
|
+
outColor = vec4(color, 1.0);
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import basicSsl from '@vitejs/plugin-basic-ssl';
|
|
3
|
+
import glsl from 'vite-plugin-glsl';
|
|
4
|
+
|
|
5
|
+
const isStackBlitz = 'STACKBLITZ' in process.env;
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [glsl(), ...(isStackBlitz ? [] : [basicSsl()])],
|
|
9
|
+
server: {
|
|
10
|
+
host: true,
|
|
11
|
+
...(isStackBlitz ? {} : { https: true }),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
|
+
<title>Built with ShaderPad</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<script type="module" src="/src/main.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|