Moved the makePyramid and resizePyramid methods from the regl solution's util module to bloomPass.

Adding the canvas context's preferred format to the shared pass context (named "canvasFormat").
Added a placeholder bloomPass, which the existing passes now receive input from.
This commit is contained in:
Rezmason
2021-11-09 20:06:59 -08:00
parent f0f422e933
commit f4130013f4
9 changed files with 163 additions and 59 deletions

View File

@@ -12,7 +12,7 @@ import { loadShader, makeUniformBuffer, makePassFBO, makePass } from "./utils.js
const numVerticesPerQuad = 2 * 3;
export default (context, getInputs) => {
const { config, adapter, device, canvasContext, timeBuffer } = context;
const { config, device, timeBuffer, canvasFormat } = context;
const linearSampler = device.createSampler({
magFilter: "linear",
@@ -29,8 +29,6 @@ export default (context, getInputs) => {
],
};
const presentationFormat = canvasContext.getPreferredFormat(adapter);
let renderPipeline;
let configBuffer;
let output;
@@ -50,7 +48,7 @@ export default (context, getInputs) => {
entryPoint: "fragMain",
targets: [
{
format: presentationFormat,
format: canvasFormat,
},
],
},
@@ -62,7 +60,7 @@ export default (context, getInputs) => {
const setSize = (width, height) => {
output?.destroy();
output = makePassFBO(device, width, height, presentationFormat);
output = makePassFBO(device, width, height, canvasFormat);
};
const getOutputs = () => ({
@@ -72,7 +70,7 @@ export default (context, getInputs) => {
const execute = (encoder) => {
const inputs = getInputs();
const tex = inputs.primary;
const bloomTex = inputs.primary; // TODO: bloom
const bloomTex = inputs.bloom; // TODO: bloom
const renderBindGroup = makeBindGroup(device, renderPipeline, 0, [configBuffer, timeBuffer, linearSampler, tex.createView(), bloomTex.createView()]);
renderPassConfig.colorAttachments[0].view = output.createView();