Upload backdrop-shader.ts
Browse files- backdrop-shader.ts +40 -0
backdrop-shader.ts
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @license
|
3 |
+
* SPDX-License-Identifier: Apache-2.0
|
4 |
+
*/
|
5 |
+
const vs = `precision highp float;
|
6 |
+
|
7 |
+
in vec3 position;
|
8 |
+
|
9 |
+
uniform mat4 modelViewMatrix;
|
10 |
+
uniform mat4 projectionMatrix;
|
11 |
+
|
12 |
+
void main() {
|
13 |
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);
|
14 |
+
}`;
|
15 |
+
|
16 |
+
const fs = `precision highp float;
|
17 |
+
|
18 |
+
out vec4 fragmentColor;
|
19 |
+
|
20 |
+
uniform vec2 resolution;
|
21 |
+
uniform float rand;
|
22 |
+
|
23 |
+
void main() {
|
24 |
+
float aspectRatio = resolution.x / resolution.y;
|
25 |
+
vec2 vUv = gl_FragCoord.xy / resolution;
|
26 |
+
float noise = (fract(sin(dot(vUv, vec2(12.9898 + rand,78.233)*2.0)) * 43758.5453));
|
27 |
+
|
28 |
+
vUv -= .5;
|
29 |
+
vUv.x *= aspectRatio;
|
30 |
+
|
31 |
+
float factor = 4.;
|
32 |
+
float d = factor * length(vUv);
|
33 |
+
vec3 from = vec3(3.) / 255.;
|
34 |
+
vec3 to = vec3(16., 12., 20.) / 2550.;
|
35 |
+
|
36 |
+
fragmentColor = vec4(mix(from, to, d) + .005 * noise, 1.);
|
37 |
+
}
|
38 |
+
`;
|
39 |
+
|
40 |
+
export {fs, vs};
|