From 1528ca39a5e73d24e76e150c22479e6a0b68b0d3 Mon Sep 17 00:00:00 2001 From: Rezmason Date: Mon, 8 Nov 2021 03:45:06 -0800 Subject: [PATCH] Commenting out the tables and adding select to some shaders in place of the original ternary operator. --- TODO.txt | 3 ++- js/webgpu/main.js | 2 +- js/webgpu/rainPass.js | 2 +- shaders/wgsl/rainPass.wgsl | 11 ++--------- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/TODO.txt b/TODO.txt index 9a8f1a2..02c9389 100644 --- a/TODO.txt +++ b/TODO.txt @@ -9,8 +9,9 @@ WebGPU gpu-uniforms Is this an adequate name for it? Can't it be useful for non-uniform-related things? + gpu-buffer maybe? Resolve the remaining to-dos - Try and drive use it for the palette color buffer + Try and use it for the palette color buffer Test it Demo it to others Make improvements diff --git a/js/webgpu/main.js b/js/webgpu/main.js index 5a20127..016cfac 100644 --- a/js/webgpu/main.js +++ b/js/webgpu/main.js @@ -27,7 +27,7 @@ export default async (canvas, config) => { const canvasContext = canvas.getContext("webgpu"); const presentationFormat = canvasContext.getPreferredFormat(adapter); - console.table(device.limits); + // console.table(device.limits); const canvasConfig = { device, diff --git a/js/webgpu/rainPass.js b/js/webgpu/rainPass.js index 42ce1e6..9121537 100644 --- a/js/webgpu/rainPass.js +++ b/js/webgpu/rainPass.js @@ -26,7 +26,7 @@ const makeConfigBuffer = (device, configUniforms, config, density, gridSize) => slantScale: 1 / (Math.abs(Math.sin(2 * config.slant)) * (Math.sqrt(2) - 1) + 1), slantVec: [Math.cos(config.slant), Math.sin(config.slant)], }; - console.table(configData); + // console.table(configData); return makeUniformBuffer(device, configUniforms, configData); }; diff --git a/shaders/wgsl/rainPass.wgsl b/shaders/wgsl/rainPass.wgsl index f057d16..3d98012 100644 --- a/shaders/wgsl/rainPass.wgsl +++ b/shaders/wgsl/rainPass.wgsl @@ -225,11 +225,7 @@ fn computeResult (isFirstFrame : bool, previousResult : vec4, glyphPos : ve var previousCycle = previousResult.g; var resetGlyph = isFirstFrame; // || previousBrightness <= 0.0; // TODO: loop if (resetGlyph) { - if (bool(config.showComputationTexture)) { - previousCycle = 0.0; - } else { - previousCycle = randomFloat(screenPos); - } + previousCycle = select(randomFloat(screenPos), 0.0, bool(config.showComputationTexture)); } var localCycleSpeed = getCycleSpeed(rainTime, brightness); var cycle = previousCycle; @@ -291,10 +287,7 @@ fn computeResult (isFirstFrame : bool, previousResult : vec4, glyphPos : ve var volumetric = bool(config.volumetric); - var quadGridSize = vec2(1.0); - if (volumetric) { - quadGridSize = config.gridSize; - } + var quadGridSize = select(vec2(1.0), config.gridSize, volumetric); // Convert the vertex index into its quad's position and its corner in its quad var i = i32(input.index);