Skip to content

Commit

Permalink
Deploying to gh-pages from @ a1bee53 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Nov 19, 2024
1 parent 6acd373 commit 7d29272
Show file tree
Hide file tree
Showing 9 changed files with 9,501 additions and 1 deletion.
17 changes: 17 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ var bitonicSort = {
],
};

var blending = {
name: 'Blending',
description: `
This example provides shows how to use blending in WebGPU. It draws a texture with diagonal lines
on top of a canvas with a CSS based checkerboard background. It then draws a texture with
3 blurry circles on top the first texture with [blending settings](https://gpuweb.github.io/gpuweb/#color-target-state).
This lets you see both the effect of blending settings in WebGPU and the final result when composited on top of the canvas.
See [this article](https://webgpufundamentals.org/webgpu/lessons/webgpu-transparency.html)
for a more detailed explanation.
The presets are equivalent to the 2d canvas context's
[\`globalCompositingOperation\`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation).
`,
filename: "sample/blending",
sources: [{ path: 'main.ts' }, { path: 'texturedQuad.wgsl' }],
};

var bundleCulling = {
name: 'Bundle Culling',
description: `A demonstration of using frustum culling with render bundles through indirect instanced draw calls.`,
Expand Down Expand Up @@ -667,6 +683,7 @@ const pageCategories = [
occlusionQuery,
samplerParameters,
timestampQuery,
blending,
},
},
// Samples that demonstrate the GPGPU functionality of WebGPU. These samples generally provide some
Expand Down
2 changes: 1 addition & 1 deletion main.js.map

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions sample/blending/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>webgpu-samples: blending</title>
<style>
:root {
color-scheme: light dark;
}
html, body {
margin: 0; /* remove default margin */
height: 100%; /* make body fill the browser window */
display: flex;
place-content: center center;
}
canvas {
width: 600px;
height: 600px;
max-width: 100%;
display: block;

/* give the canvas a checked background so we can see visualize blending the WebGPU texture with the canvas' background */
background-color: #404040;
background-image:
linear-gradient(45deg, #808080 25%, transparent 25%),
linear-gradient(-45deg, #808080 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #808080 75%),
linear-gradient(-45deg, transparent 75%, #808080 75%);
background-size: 32px 32px;
background-position: 0 0, 0 16px, 16px -16px, -16px 0px;

}
</style>
<script defer src="main.js" type="module"></script>
<script defer type="module" src="../../js/iframe-helper.js"></script>
</head>
<body>
<canvas></canvas>
</body>
</html>
Loading

0 comments on commit 7d29272

Please sign in to comment.