Came up with some performance improvements. Hopefully this will help it run better on more machines leading up to the sequel coming out.

This commit is contained in:
Rezmason
2021-07-11 18:18:13 -07:00
parent d094f7e0b7
commit 6708ab03a7
8 changed files with 40 additions and 24 deletions

View File

@@ -22,10 +22,10 @@ export default (regl, config, inputs) => {
"highPassThreshold"
]);
const highPassPyramid = makePyramid(regl, pyramidHeight);
const hBlurPyramid = makePyramid(regl, pyramidHeight);
const vBlurPyramid = makePyramid(regl, pyramidHeight);
const output = makePassFBO(regl);
const highPassPyramid = makePyramid(regl, pyramidHeight, config.useHalfFloat);
const hBlurPyramid = makePyramid(regl, pyramidHeight, config.useHalfFloat);
const vBlurPyramid = makePyramid(regl, pyramidHeight, config.useHalfFloat);
const output = makePassFBO(regl, config.useHalfFloat);
// The high pass restricts the blur to bright things in our input texture.
const highPass = regl({
@@ -126,13 +126,15 @@ export default (regl, config, inputs) => {
bloom: output
},
() => {
highPassPyramid.forEach(fbo => highPass({ fbo, tex: inputs.primary }));
hBlurPyramid.forEach((fbo, index) =>
blur({ fbo, tex: highPassPyramid[index], direction: [1, 0] })
);
vBlurPyramid.forEach((fbo, index) =>
blur({ fbo, tex: hBlurPyramid[index], direction: [0, 1] })
);
for (let i = 0; i < pyramidHeight; i++) {
const highPassFBO = highPassPyramid[i];
const hBlurFBO = hBlurPyramid[i];
const vBlurFBO = vBlurPyramid[i];
highPass({ fbo: highPassFBO, tex: inputs.primary });
blur({ fbo: hBlurFBO, tex: highPassFBO, direction: [1, 0] });
blur({ fbo: vBlurFBO, tex: hBlurFBO, direction: [0, 1] });
}
flattenPyramid();
},
(w, h) => {