-
After read lessons/webgpu-multiple-canvases and lessons/webgpu-multisampling I encountered some confusion while using MRT and MSAA. When a triangle rotates, aliasing occurs, and I began to try using MSAA for anti-aliasing. (In my case, I used MRT to implement the object selection feature, which determines whether an object is selected by reading the pixel color.) I found that when a pipeline sets the multisample.count to 4, all textures must have a sampleCount of 4. Therefore, I now have to set the pickingObjectTexture to 4 as well. I have the following questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You can use
I honestly don't know what state of the art is. There's a ton of techniques. They each have strengths and weaknesses. Sorry I don't have an answer. see https://www.google.com/search?q=gpu+antialiasing+methods btw: there's a picking example here. It is not anti-aliased though, nor is it using MRT. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
well, there's the smoothstep circle @fragment fn fs(vin: VSOut) -> @location(0) vec4f {
//
// inner outer border fade
// center radius radius radius radius
// V V V V V
// | <--- circle ---> | <- blend -> | <- border -> | <- anti-alias -> |
// | color | to border | color | blend to 0 |
const innerRadius = 0.2;
const outerRadius = 0.3;
const borderRadius = 0.4;
const fadeRadius = 0.5;
let distance = length(vin.uv - 0.5);
let innerMix = smoothstep(innerRadius, outerRadius, distance);
let outerMix = smoothstep(borderRadius, fadeRadius, distance);
let circleColor = vec4f(1, 0, 0, 1);
let borderColor = vec4f(1, 1, 0, 1);
let edgeColor = vec4f(0, 0, 0, 0);
let color = mix(
mix(circleColor, borderColor, innerMix),
edgeColor,
outerMix);
// premultiply
return vec4f(color.rgb * color.a, color.a);
} you'll need to choose radii that fit the current resolution the quad is being rendered, or use I think this works.
|
Beta Was this translation helpful? Give feedback.
seems to work.