pygfx.renderers.wgpu.EffectPass
- class pygfx.renderers.wgpu.EffectPass
Bases:
FullQuadPassBase class to do post-processing effect passes, converting one image into another.
- USES_DEPTH = False
Overloadable class attribute to state whether bindings to the depth buffer are needed.
- uniform_type = {'time': 'f4'}
Overloadable class attribute that defines the structure of the uniform struct.
In a subclass you should use something like this:
uniform_type = dict( EffectPass.uniform_type, color="4xf4", strength="f4", )
- wgsl = 'EffectPass_needs_to_be_subclassed(and_its_wgsl_attr_overloaded);'
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 enabled
Whether the effect pass is enabled.
- render(command_encoder, color_tex, depth_tex, target_tex)
Render the pass using the provided textures.
If
USES_DEPTHis False, thedepth_texis ignored (and may be set to None).