Skip to content

Commit

Permalink
Changed fullscreenQuad name to positionQuad to better reflect the sha…
Browse files Browse the repository at this point in the history
…der's functionality, edited the meta.ts and index.html naming accordingly
  • Loading branch information
cmhhelgeson committed Apr 4, 2024
1 parent f1ffdce commit 61e2416
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sample/stencilMask/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>webgpu-samples: instancedCube</title>
<title>webgpu-samples: stencilMask</title>
<style>
:root {
color-scheme: light dark;
Expand Down
2 changes: 1 addition & 1 deletion sample/stencilMask/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ const tmpMat4Scene1 = mat4.create();
// Update the transformation matrix data for each instance.
function updateTransformationMatrix() {
const nowScene0 = Date.now() / 1000;
const nowScene1 = nowScene0 + 100.0;
const nowScene1 = nowScene0 * 2;

let m = 0,
i = 0;
Expand Down
2 changes: 1 addition & 1 deletion sample/stencilMask/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
// Ts files
{ path: 'main.ts' },
// Stencil Mask shaders
{ path: 'fullscreenQuad.vert.wgsl' },
{ path: 'positionQuad.vert.wgsl' },
{ path: 'sdf.frag.wgsl' },
// Instanced Cube verts
{ path: '../instancedCube/instanced.vert.wgsl' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct VertexOutput {
@builtin(position) Position : vec4f,
@location(0) fragUV : vec2f,
@location(0) v_uv : vec2f,
}

struct Uniforms {
Expand Down Expand Up @@ -38,13 +38,15 @@ fn vertexMain(@builtin(vertex_index) VertexIndex : u32) -> VertexOutput {
let mask_offset = vec2f(uniforms.offset_x, uniforms.offset_y);
// scale_to_canvas is effectively a transformation that takes our quad positions from NDC space to canvas space.
let scale_to_canvas = vec2<f32>(uniforms.scale_to_canvas_x, uniforms.scale_to_canvas_y);
// Position in canvas space
let posCS = pos[VertexIndex] * scale_to_canvas;
// offset of position based on mouse cursor input in canvas space
let offsetCS = mask_offset * scale_to_canvas;
output.Position = vec4(
posCS * uniforms.radius_scale + offsetCS,
0.0,
1.0
);
output.fragUV = uv[VertexIndex];
output.v_uv = uv[VertexIndex];
return output;
}

0 comments on commit 61e2416

Please sign in to comment.