pygfx.renderers.wgpu.CopyPass
- class pygfx.renderers.wgpu.CopyPass
Bases:
EffectPassSimple pass that does nothing but copy the texture over, using linear interpolation if the texture size does not match. Mostly included for testing.
- wgsl = '\n @fragment\n fn fs_main(varyings: Varyings) -> @location(0) vec4<f32> {\n return textureSample(colorTex, texSampler, varyings.texCoord);\n }\n '
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); }