Separated color passes into separate modules.

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.
This commit is contained in:
Rezmason
2020-01-25 23:05:54 -08:00
parent 7aaf85a345
commit 99ef8bbf0a
11 changed files with 278 additions and 257 deletions

27
js/imagePass.js Normal file
View File

@@ -0,0 +1,27 @@
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
);
};