Exploring ways to preserve the vanilla JS browser demo without compromising on the bundle. Experimenting with embedding images in the bundle as data URIs

This commit is contained in:
Rezmason
2025-05-06 12:59:02 -07:00
parent 6663c92f99
commit eea341f50c
27 changed files with 372 additions and 137 deletions

View File

@@ -1,6 +1,5 @@
import colorToRGB from "../utils/colorToRGB";
import { make1DTexture, makePassFBO, makePass } from "./utils";
import stripePassFrag from "../../shaders/glsl/stripePass.frag.glsl";
import colorToRGB from "../utils/colorToRGB.js";
import { loadText, make1DTexture, makePassFBO, makePass } from "./utils.js";
// Multiplies the rendered rain and bloom by a 1D gradient texture
// generated from the passed-in color sequence
@@ -28,7 +27,7 @@ const prideStripeColors = [
.map((color) => Array(2).fill(color))
.flat();
export default ({ regl, config }, inputs) => {
export default ({ regl, cache, config }, inputs) => {
const output = makePassFBO(regl, config.useHalfFloat);
const {
@@ -52,6 +51,8 @@ export default ({ regl, config }, inputs) => {
stripeColors.map((color) => [...colorToRGB(color), 1]),
);
const stripePassFrag = loadText(cache, "shaders/glsl/stripePass.frag.glsl");
const render = regl({
frag: regl.prop("frag"),
@@ -73,11 +74,11 @@ export default ({ regl, config }, inputs) => {
{
primary: output,
},
null,
stripePassFrag.loaded,
(w, h) => output.resize(w, h),
(shouldRender) => {
if (shouldRender) {
render({ frag: stripePassFrag });
render({ frag: stripePassFrag.text() });
}
},
);