pygfx.renderers.wgpu.DepthPass
- class pygfx.renderers.wgpu.DepthPass
Bases:
EffectPassAn effect that simply renders the depth. Mostly for debugging purposes.
- USES_DEPTH = True
Overloadable class attribute to state whether bindings to the depth buffer are needed.
- wgsl = '\n @fragment\n fn fs_main(varyings: Varyings) -> @location(0) vec4<f32> {\n let texIndex = vec2i(varyings.position.xy);\n let depth = textureLoad(depthTex, texIndex, 0);\n return vec4f(depth, depth, depth, 1.0);\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); }