#version 450 // (Triforce) SMAA pass 0 (gpu/vk/vk_aa.cpp, the Anti-aliasing row's SMAA Ultra): the luma SMAA looks for edges in, from the // tone mapped picture, in the square-root space the target stores (aa_common.glsl). One channel: SMAA's luma edge detection // takes the dot product of the colour it reads with its luma weights, and a one-channel image reads as (r, 0, 0), so r holds // the luma over the red weight. After NX2navi's shaders/smaa_encode.comp. #extension GL_GOOGLE_include_directive : require layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D src; layout(binding = 1, r16f) uniform writeonly image2D dst; layout(push_constant) uniform Push { vec4 metrics; } pc; #include "aa_common.glsl" void main() { ivec2 p = ivec2(gl_GlobalInvocationID.xy); if (p.x >= int(pc.metrics.z) || p.y >= int(pc.metrics.w)) return; const vec3 W = vec3(0.2126, 0.7152, 0.0722); // (SMAA.hlsl SMAALumaEdgeDetectionPS's weights) imageStore(dst, p, vec4(dot(aa_encode(texelFetch(src, p, 0).rgb), W) / W.r, 0.0, 0.0, 1.0)); }