#version 300 es precision highp float; in vec4 vColor; uniform highp sampler2D u_sceneDepth; uniform vec2 u_invViewport; // 1 / current framebuffer size out vec4 fragColor; void main() { // manual depth test against the scene pass (drawn post-PP, so no hardware depth to test against); // primitive depths carry the scene pass polygon offset, so coplanar wireframes win the compare. // sampled by normalized screen position — stays correct if the scene renders at another resolution float sceneDepth = texture(u_sceneDepth, gl_FragCoord.xy * u_invViewport).r; if (gl_FragCoord.z > sceneDepth) discard; fragColor = vColor; }