pygfx.renderers.wgpu.DDAAPass

class pygfx.renderers.wgpu.DDAAPass(*, max_edge_iters=5)

Bases: PPAAPass

An effect pass implementing Directional Diffusion anti-aliasing.

DDAA produces better results than FXAA for near-diagonal lines, at the same performance. It estimates the direction of the edge, and then diffuses (i.e. smoothes) in that direction. For near-horizontal and near-vertical a technique similar to FXAA is used.

wgsl = "{$ include 'pygfx.ddaa2.wgsl' $}"

Overloadable class attribute that contains the WGSL shading code for the fragment shader.

Use the following template:

@fragment
fn fs_main(varyings: Varyings) -> @location(0) vec4<f32> {

    // Available variables:
    // colorTex - the texture containing the rendered image, or the previous effect pass.
    // depthTex - the texture containing the renderd depth values.
    // texSampler - a sampler to use for the above.
    // varyings.position - the position in physical pixels (a vec4f).
    // varyings.texCoord - the coordinate in the textures (a vec2f).
    // u_effect.time - the current time in seconds, changes each frame.
    // u_effect.xx - whatever uniforms you added.

    // Calculate the pixel index, e.g. if you want to use textureLoad().
    let texIndex = vec2i(varyings.position.xy);

    // To simply copy the image:
    return textureSample(colorTex, texSampler, varyings.texCoord);
}
property max_edge_iters

The maximum number of iters (of 3 samples) to search along an edge.

Default 5 (i.e. search 15 pixels along an edge). Set higger for prettier edges, or lower for more performance.

Examples

Post processing effects 1

Post processing effects 1