mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
Moved main JS into its own module. Main module now builds passes into a pipeline, based on the value of config.effect. The passes no longer make stubs when they're not meant to be active. Asset loading has been moved into the passes, which resolve their ready promise when they've finished loading.
28 lines
709 B
JavaScript
28 lines
709 B
JavaScript
import { loadImage, makePassFBO, makePass } from "./utils.js";
|
|
|
|
export default (regl, { bgURL }, input) => {
|
|
const output = makePassFBO(regl);
|
|
const bgLoader = loadImage(regl, bgURL);
|
|
return makePass(
|
|
output,
|
|
regl({
|
|
frag: `
|
|
precision mediump float;
|
|
uniform sampler2D tex;
|
|
uniform sampler2D bgTex;
|
|
varying vec2 vUV;
|
|
|
|
void main() {
|
|
vec3 bgColor = texture2D(bgTex, vUV).rgb;
|
|
float brightness = pow(texture2D(tex, vUV).r, 1.5);
|
|
gl_FragColor = vec4(bgColor * brightness, 1.0);
|
|
}
|
|
`,
|
|
uniforms: { bgTex: bgLoader.texture, tex: input },
|
|
framebuffer: output
|
|
}),
|
|
null,
|
|
bgLoader.ready
|
|
);
|
|
};
|