#version 410 compatibility #define SMAA_PIXEL_SIZE vec2(1.0 / 512.0, 1.0 / 512.0) #define SMAA_THRESHOLD 0.05 #define SMAA_MAX_SEARCH_STEPS 32 #define SMAA_MAX_SEARCH_STEPS_DIAG 16 #define SMAA_CORNER_ROUNDING 25 #ifndef SMAA_DEPTH_THRESHOLD #define SMAA_DEPTH_THRESHOLD (0.1 * SMAA_THRESHOLD) #endif #ifndef SMAA_REPROJECTION #define SMAA_REPROJECTION 0 #endif #define SMAA_REPROJECTION_WEIGHT_SCALE 30.0 #ifndef SMAA_AREATEX_MAX_DISTANCE #define SMAA_AREATEX_MAX_DISTANCE 16 #endif #ifndef SMAA_AREATEX_MAX_DISTANCE_DIAG #define SMAA_AREATEX_MAX_DISTANCE_DIAG 20 #endif #define SMAA_AREATEX_PIXEL_SIZE (1.0 / vec2(160.0, 560.0)) #define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0) /* --- Define section is over ---- */ /** * Blend Weight Calculation Vertex Shader */ void SMAABlendingWeightCalculationVS(vec4 position, out vec4 svPosition, inout vec2 texcoord, out vec2 pixcoord, out vec4 offset[3]) { svPosition = position; pixcoord = texcoord / SMAA_PIXEL_SIZE; // We will use these offsets for the searches later on (see @PSEUDO_GATHER4): offset[0] = texcoord.xyxy + SMAA_PIXEL_SIZE.xyxy * vec4(-0.25, -0.125, 1.25, -0.125); offset[1] = texcoord.xyxy + SMAA_PIXEL_SIZE.xyxy * vec4(-0.125, -0.25, -0.125, 1.25); // And these for the searches, they indicate the ends of the loops: offset[2] = vec4(offset[0].xz, offset[1].yw) + vec4(-2.0, 2.0, -2.0, 2.0) * SMAA_PIXEL_SIZE.xxyy * float(SMAA_MAX_SEARCH_STEPS); } /* ------------- Header is over -------------- */ out vec2 texcoord; out vec2 pixcoord; out vec4 offset[3]; out vec4 dummy2; attribute vec3 vPosition; attribute vec2 vTexCoord; uniform mat4 ProjectionMatrix; void main() { texcoord = vTexCoord; vec4 dummy1 = vec4(0); SMAABlendingWeightCalculationVS(dummy1, dummy2, texcoord, pixcoord, offset); gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0); }