diff --git a/sample/alphaToCoverage/meta.ts b/sample/alphaToCoverage/meta.ts index 1922e1cd..8cb35bc7 100644 --- a/sample/alphaToCoverage/meta.ts +++ b/sample/alphaToCoverage/meta.ts @@ -1,23 +1,20 @@ export default { name: 'Alpha-to-Coverage', description: ` -Visualizes how alpha-to-coverage translates alpha values into sample -coverage on your device. It draws two full-screen quads into a 4-sample -texture, with the configured color and alpha values. Then, it visualizes the -contents of that 4-sample texture: the circles show the 4 samples of each -pixel; the background checkerboard shows where the pixels are. - -The algorithm that converts alpha to a coverage sample mask varies per -device. This results in different proportions between the black background, -the first draw, and the second draw. +Alpha-to-coverage is an alternative to alpha testing and alpha blending. See: + -Examples: Some devices use 1x1 patterns, others 2x2, others 4x4. Not all devices -guarantee that once a sample "pops in", it will stay there at higher alpha -values. Some devices "move" samples around at certain alpha thresholds even -without increasing the total sample count. +This sample visualizes how alpha-to-coverage translates alpha values into sample +coverage on your device. It draws two full-screen quads into a 4-sample +texture, each with the configured color and alpha value. Then, it visualizes the +contents of the resulting 4-sample texture: the circles show the 4 samples of +each texel; the background shows the "resolved" results (average of 4 samples). -More info on alpha-to-coverage: - +The algorithm that converts alpha to a coverage sample mask varies per device. +This results in different average "blending" proportions between the black +background, the first draw, and the second draw. +Device differences include different tile sizes (e.g. 1x1, 2x2, or 4x4), +"moving" samples (or not) around with in the tile as alpha increases, etc. `, filename: __DIRNAME__, sources: [ diff --git a/sample/alphaToCoverage/showMultisampleTexture.wgsl b/sample/alphaToCoverage/showMultisampleTexture.wgsl index 3de18a8f..99b22a03 100644 --- a/sample/alphaToCoverage/showMultisampleTexture.wgsl +++ b/sample/alphaToCoverage/showMultisampleTexture.wgsl @@ -50,7 +50,7 @@ fn fmain(vary: Varying) -> @location(0) vec4f { let xyFrac = xy % vec2f(1, 1); // Show the visualization only if the resolution is large enough to see it - if (dpdx(xy.x) < kGridEdgeHalfWidth) & (dpdy(xy.y) < kGridEdgeHalfWidth) { + if (dpdx(xy.x) < kGridEdgeHalfWidth * 2) & (dpdy(xy.y) < kGridEdgeHalfWidth * 2) { // Check if we're close to a sample; if so, visualize the sample value for (var sampleIndex = 0; sampleIndex < kSampleCount; sampleIndex += 1) { let distanceFromSample = distance(xyFrac, kSamplePositions[sampleIndex]);