/** * Slightly adapted from https://github.com/mrdoob/three.js * MIT License Copyright (c) 2010-2020 three.js authors * * WebGL port of Subpixel Morphological Antialiasing (SMAA) v2.8 * Preset: SMAA 1x Medium (with color edge detection) * https://github.com/iryoku/smaa/releases/tag/v2.8 */ export const edges_vert = ` precision highp float; attribute vec2 aPosition; uniform vec2 uQuadScale; uniform vec2 uTexSizeInv; uniform vec4 uViewport; varying vec2 vUv; varying vec4 vOffset[3]; void SMAAEdgeDetectionVS(vec2 texCoord) { vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component vOffset[2] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-2.0, 0.0, 0.0, 2.0); // WebGL port note: Changed sign in W component } void main() { vec2 scale = uViewport.zw * uTexSizeInv; vec2 shift = uViewport.xy * uTexSizeInv; vUv = (aPosition + 1.0) * 0.5 * scale + shift; SMAAEdgeDetectionVS(vUv); vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale; gl_Position = vec4(position, 0.0, 1.0); } `;