Files
NX2navi/runtime/shaders/smaa_encode.comp
chrg6 bfe88e503a Add one anti-aliasing setting: the game's SMAA, off, FXAA, SMAA at its Ultra preset, or TAA.
Ocarina anti-aliases every frame with its own SMAA in three compute passes after the bloom composite. The new aa
setting (nx2navi.ini aa, the Screen tab's Anti-aliasing row) keeps that by default. off, fxaa and smaa leave out the
game's edge and weight passes and replace its composition with a pass of our own that writes the same square-rooted
RGB9E5 words into the scene target: a plain copy, an edge smoothing written here, or the SMAA reference implementation
with its area and search textures (MIT). taa is DLSS or FSR 3.1 at the scene's size, which the row sets through the
upscaler; while either runs, the game's SMAA stays whatever aa says. The game's passes are known by a hash of their
guest code. The shader build now also rebuilds a header when a file its source includes changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:09:16 -05:00

19 lines
992 B
Plaintext

#version 450
// SMAA pass 0 (runtime/vk_aa.c): the luma SMAA looks for edges in, from the game's linear composite, in the square-root
// space the scene 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.
#extension GL_GOOGLE_include_directive : require
#include "aa_common.glsl"
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;
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.glsl SMAALumaEdgeDetectionPS's weights
imageStore(dst, p, vec4(dot(aa_encode(texelFetch(src, p, 0).rgb), W) / W.r, 0.0, 0.0, 1.0));
}