#version 300 es precision highp float; uniform sampler2D u_texture; uniform vec2 u_resolution; uniform float u_time; in vec2 v_texCoord; out vec4 fragColor; const float EDGE_STRENGTH = 0.2; // Adjust edge brightness const float EDGE_THRESHOLD = 0.01; // Minimum edge strength to display void main() { vec2 uv = gl_FragCoord.xy/u_resolution.xy; vec2 texel = 1.0 / u_resolution.xy; // Sample the neighboring pixels vec3 top = texture(u_texture, uv + vec2(0.0, texel.y)).rgb; vec3 bottom = texture(u_texture, uv + vec2(0.0, -texel.y)).rgb; vec3 left = texture(u_texture, uv + vec2(-texel.x, 0.0)).rgb; vec3 right = texture(u_texture, uv + vec2(texel.x, 0.0)).rgb; vec3 center = texture(u_texture, uv).rgb * 4.0; // Apply Laplacian kernel vec3 laplacian = -center + top + bottom + left + right; // Convert to grayscale float edge = dot(abs(laplacian), vec3(0.2126, 0.7152, 0.0722)); // Apply threshold and adjust strength edge = smoothstep(EDGE_THRESHOLD, EDGE_THRESHOLD + 0.01, edge) * EDGE_STRENGTH; fragColor = vec4(vec3(edge), 1.0); }