not bad for first time

This commit is contained in:
serge
2022-07-05 05:24:38 +10:00
parent a4a0406826
commit c2eb3d0602
4 changed files with 86 additions and 16 deletions

View File

@@ -91,7 +91,7 @@ const defaults = {
],
raindropLength: 1, // Adjusts the frequency of raindrops (and their length) in a column
slant: 0, // The angle at which rain falls; the orientation of the glyph grid
resolution: 1, // An overall scale multiplier
resolution: .75, // An overall scale multiplier
useHalfFloat: false,
renderer: "webgpu", // The preferred web graphics API
useHoloplay: false,
@@ -174,11 +174,11 @@ const versions = {
},
updated: {
font: "resurrections",
numColumns: 108,
numColumns: 100,
fallSpeed: 0.35,
cycleStyle: "cycleRandomly",
cycleSpeed: 0.8,
glyphEdgeCrop: 0.1,
glyphEdgeCrop: .27,
paletteEntries: [
{ hsl: [0.39, 0.9, 0.0], at: 0.0 },
{ hsl: [0.39, 1.0, 0.6], at: 0.5 },

View File

@@ -7,6 +7,7 @@ import makeStripePass from "./stripePass.js";
import makeImagePass from "./imagePass.js";
import makeResurrectionPass from "./resurrectionPass.js";
import makeQuiltPass from "./quiltPass.js";
import makeRipplesPass from "./ripplesPass.js";
import getLKG from "./lkgHelper.js";
const effects = {
@@ -20,6 +21,7 @@ const effects = {
image: makeImagePass,
resurrection: makeResurrectionPass,
resurrections: makeResurrectionPass,
ripples: makeRipplesPass,
};
const dimensions = { width: 1, height: 1 };
@@ -41,19 +43,19 @@ export default async (canvas, config) => {
canvas.height = Math.ceil(canvas.clientHeight * config.resolution);
};
window.onresize = resize;
if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
window.onclick = () => {
if (document.fullscreenElement == null) {
if (canvas.webkitRequestFullscreen != null) {
canvas.webkitRequestFullscreen();
} else {
canvas.requestFullscreen();
}
} else {
document.exitFullscreen();
}
};
}
// if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
// window.onclick = () => {
// if (document.fullscreenElement == null) {
// if (canvas.webkitRequestFullscreen != null) {
// canvas.webkitRequestFullscreen();
// } else {
// canvas.requestFullscreen();
// }
// } else {
// document.exitFullscreen();
// }
// };
// }
resize();
const regl = createREGL({

35
js/regl/ripplesPass.js Normal file
View File

@@ -0,0 +1,35 @@
import { loadImage, loadText, makePassFBO, makePass } from "./utils.js";
// Multiplies the rendered rain and bloom by a loaded in image
// const defaultBGURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Flammarion_Colored.jpg/917px-Flammarion_Colored.jpg";
export default ({ regl, config }, inputs) => {
console.log('ripples');
const output = makePassFBO(regl, config.useHalfFloat);
// const bgURL = "bgURL" in config ? config.bgURL : defaultBGURL;
// const bloomStrength = config.bloomStrength;
// const background = loadImage(regl, bgURL);
const ripplesPassFrag = loadText("shaders/glsl/ripplesPass.frag.glsl");
const render = regl({
frag: regl.prop("frag"),
uniforms: {
// bloomStrength,
time: regl.context("time"),
tex: inputs.primary,
bloomTex: inputs.bloom,
height: regl.context("viewportWidth"),
width: regl.context("viewportHeight"),
},
framebuffer: output,
});
return makePass(
{
primary: output,
},
Promise.all([ripplesPassFrag.loaded]),
(w, h) => output.resize(w, h),
() => render({ frag: ripplesPassFrag.text() })
);
};