-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alphaToCoverage: show resolve result; draw twice with different color…
…s/alphas (#445) * alphaToCoverage: show resolve result; draw twice with different colors/alphas This demonstrates how different alpha-to-coverage algorithms produce different blending results. * lint fix * add checkbox to hide resolved color * add link to article on alpha-to-coverage * avoid recreating texture every frame * more size options, fix another redundantly allocated texture * improve description
- Loading branch information
Showing
4 changed files
with
166 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
struct Config { | ||
alpha: f32, | ||
}; | ||
@group(0) @binding(0) var<uniform> config: Config; | ||
|
||
struct Varying { | ||
@builtin(position) pos: vec4f, | ||
// Color from instance-step-mode vertex buffer | ||
@location(0) color: vec4f, | ||
} | ||
|
||
@vertex | ||
fn vmain( | ||
@builtin(vertex_index) vertex_index: u32, | ||
@location(0) color: vec4f, | ||
) -> Varying { | ||
var square = array( | ||
vec2f(-1, -1), vec2f(-1, 1), vec2f( 1, -1), | ||
vec2f( 1, -1), vec2f(-1, 1), vec2f( 1, 1), | ||
); | ||
|
||
return Varying(vec4(square[vertex_index], 0, 1)); | ||
return Varying(vec4(square[vertex_index], 0, 1), color); | ||
} | ||
|
||
@fragment | ||
fn fmain(vary: Varying) -> @location(0) vec4f { | ||
return vec4f(1, 1, 1, config.alpha); | ||
return vary.color; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters