mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-17 13:59:30 -07:00
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:
27
js/imagePass.js
Normal file
27
js/imagePass.js
Normal 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
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user