From fb6406e753c2cfbba66ad21b44851e79a37fea09 Mon Sep 17 00:00:00 2001 From: Rezmason Date: Fri, 29 Oct 2021 09:16:28 -0700 Subject: [PATCH] The texture sampler should operate linearly --- TODO.txt | 1 + js/webgpu_main.js | 8 ++++++-- webgpu_notes.txt | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/TODO.txt b/TODO.txt index baad448..4cdb575 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,6 +3,7 @@ TODO: WebGPU First decent rainRender vertex, fragment, with noise for + data texture lookup with textureLoad std140 Document and share it diff --git a/js/webgpu_main.js b/js/webgpu_main.js index bef3073..9c08e5f 100644 --- a/js/webgpu_main.js +++ b/js/webgpu_main.js @@ -68,7 +68,11 @@ export default async (canvas, config) => { ], }; - const sampler = device.createSampler(); + const msdfSampler = device.createSampler({ + magFilter: "linear", + minFilter: "linear", + }); + const msdfTexture = await loadTexture(device, config.glyphTexURL); const configStructLayout = std140(["i32", "i32", "f32"]); @@ -176,7 +180,7 @@ export default async (canvas, config) => { }, { binding: 2, - resource: sampler, + resource: msdfSampler, }, { binding: 3, diff --git a/webgpu_notes.txt b/webgpu_notes.txt index 70743f8..797b9fc 100644 --- a/webgpu_notes.txt +++ b/webgpu_notes.txt @@ -42,4 +42,8 @@ Bind groups let you bind a bunch of resources at once Render bundles let you reissue commands You can only use up to FOUR bind groups on your laptop's device! -Here's an annoying gotcha: uniform buffers are like classic UBOs, and have esoteric ("std140") layout requirements! \ No newline at end of file +Here's an annoying gotcha: uniform buffers are like classic UBOs, and have esoteric ("std140") layout requirements! + +Texture lookup in vertex shader + You can only sample textures in fragment stages + But you can use textureLoad anywhere to get a specific texel, no sampler needed