Renaming renderer to rainPass, renaming its shaders, and cleaning up the main code a little.

This commit is contained in:
Rezmason
2021-10-20 09:58:03 -07:00
parent c85642a270
commit f6e12ad795
5 changed files with 13 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
import { makeFullScreenQuad, makePipeline } from "./utils.js"; import { makeFullScreenQuad, makePipeline } from "./utils.js";
import makeConfig from "./config.js"; import makeConfig from "./config.js";
import makeMatrixRenderer from "./renderer.js"; import makeRain from "./rainPass.js";
import makeBloomPass from "./bloomPass.js"; import makeBloomPass from "./bloomPass.js";
import makePalettePass from "./palettePass.js"; import makePalettePass from "./palettePass.js";
import makeStripePass from "./stripePass.js"; import makeStripePass from "./stripePass.js";
@@ -49,12 +49,11 @@ const dimensions = { width: 1, height: 1 };
document.body.onload = async () => { document.body.onload = async () => {
// All this takes place in a full screen quad. // All this takes place in a full screen quad.
const fullScreenQuad = makeFullScreenQuad(regl); const fullScreenQuad = makeFullScreenQuad(regl);
const pipeline = makePipeline([makeMatrixRenderer, effect === "none" ? null : makeBloomPass, effects[effect]], (p) => p.outputs, regl, config);
const drawToScreen = regl({ const bloomPass = effect === "none" ? null : makeBloomPass;
uniforms: { const pipeline = makePipeline([makeRain, bloomPass, effects[effect]], (p) => p.outputs, regl, config);
tex: pipeline[pipeline.length - 1].outputs.primary, const uniforms = { tex: pipeline[pipeline.length - 1].outputs.primary };
}, const drawToScreen = regl({ uniforms });
});
await Promise.all(pipeline.map(({ ready }) => ready)); await Promise.all(pipeline.map(({ ready }) => ready));
const tick = regl.frame(({ viewportWidth, viewportHeight }) => { const tick = regl.frame(({ viewportWidth, viewportHeight }) => {
// tick.cancel(); // tick.cancel();

View File

@@ -35,10 +35,10 @@ export default (regl, config) => {
const uniforms = { const uniforms = {
...extractEntries(config, [ ...extractEntries(config, [
// rain general // general
"glyphHeightToWidth", "glyphHeightToWidth",
"glyphTextureColumns", "glyphTextureColumns",
// rain update // compute
"animationSpeed", "animationSpeed",
"brightnessMinimum", "brightnessMinimum",
"brightnessMix", "brightnessMix",
@@ -55,9 +55,9 @@ export default (regl, config) => {
"rippleSpeed", "rippleSpeed",
"rippleThickness", "rippleThickness",
"resurrectingCodeRatio", "resurrectingCodeRatio",
// rain render vertex // render vertex
"forwardSpeed", "forwardSpeed",
// rain render fragment // render fragment
"glyphEdgeCrop", "glyphEdgeCrop",
"isPolar", "isPolar",
]), ]),
@@ -94,7 +94,7 @@ export default (regl, config) => {
const output = makePassFBO(regl, config.useHalfFloat); const output = makePassFBO(regl, config.useHalfFloat);
const updateFrag = loadText("../shaders/update.frag"); const updateFrag = loadText("../shaders/compute.frag");
const update = regl({ const update = regl({
frag: regl.prop("frag"), frag: regl.prop("frag"),
uniforms: { uniforms: {
@@ -114,8 +114,8 @@ export default (regl, config) => {
); );
// We render the code into an FBO using MSDFs: https://github.com/Chlumsky/msdfgen // We render the code into an FBO using MSDFs: https://github.com/Chlumsky/msdfgen
const renderVert = loadText("../shaders/render.vert"); const renderVert = loadText("../shaders/rain.vert");
const renderFrag = loadText("../shaders/render.frag"); const renderFrag = loadText("../shaders/rain.frag");
const render = regl({ const render = regl({
blend: { blend: {
enable: true, enable: true,