Feat: Add SMAA as a anti-alliasing option and the buttom for FXAA becomes a switch. (#2708)

* Add SMAA screen effect option

* Atualizar o smaa_frag.h

* Atualizar o smaa.frag

* Fix SMAA endpoint and crossing-edge area weights

* Atualizar o smaa.frag

* Fix SMAA diagonal edge blending

* Regenerate SMAA fragment shader header

* Fix SMAA diagonal fallback detection

* Add anti-aliasing translations

* Fix Korean anti-aliasing label
This commit is contained in:
LunaDL authored and GitHub committed 2026-11-16 14:36:02 -05:00
1 parent 25cbcf0c1f
commit d116021ff3
41 files changed
+711 -1034

No files matched your search

@@ -16,30 +16,36 @@ data class ScreenEffects(
val hdr: Boolean = false,
val deband: Boolean = false,
val debandStrength: Int = 100,
val fxaa: Boolean = false,
val aaMode: Int = AA_OFF,
val toon: Boolean = false,
val crt: Boolean = false,
val ntsc: Boolean = false,
) {
val fxaa: Boolean get() = aaMode == AA_FXAA
val smaa: Boolean get() = aaMode == AA_SMAA
val effectiveCas: Int get() = if (cas) casLevel else 0
val any: Boolean get() = brightness != 0 || contrast != 0 || abs(gamma - 1f) > 0.005f || saturation != 100 ||
effectiveCas > 0 || hdr || deband || fxaa || toon || crt || ntsc
effectiveCas > 0 || hdr || deband || aaMode != AA_OFF || toon || crt || ntsc
fun push(upscaler: Int) {
WaylandCompositor.nativeSetCas(cas, casLevel)
WaylandCompositor.nativeSetHdr(hdr)
WaylandCompositor.nativeSetDeband(deband, debandStrength)
WaylandCompositor.nativeSetScreenEffects(brightness.toFloat(), contrast.toFloat(), gamma, saturation.toFloat(), fxaa, toon, crt, ntsc)
WaylandCompositor.nativeSetScreenEffects(brightness.toFloat(), contrast.toFloat(), gamma, saturation.toFloat(), aaMode, toon, crt, ntsc)
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(this, upscaler)?.name)
}
fun encode(): JSONObject = JSONObject()
.put("brightness", brightness).put("contrast", contrast).put("gamma", gamma.toDouble()).put("saturation", saturation)
.put("cas", cas).put("casLevel", casLevel).put("hdr", hdr).put("deband", deband).put("debandStrength", debandStrength)
.put("fxaa", fxaa).put("toon", toon).put("crt", crt).put("ntsc", ntsc)
.put("aaMode", aaMode).put("fxaa", fxaa).put("toon", toon).put("crt", crt).put("ntsc", ntsc)
companion object {
const val AA_OFF = 0
const val AA_FXAA = 1
const val AA_SMAA = 2
val OFF = ScreenEffects()
fun decode(json: JSONObject): ScreenEffects = ScreenEffects(
@@ -52,7 +58,7 @@ data class ScreenEffects(
hdr = json.optBoolean("hdr", false),
deband = json.optBoolean("deband", false),
debandStrength = json.optInt("debandStrength", 100).coerceIn(0, 200),
fxaa = json.optBoolean("fxaa", false),
aaMode = json.optInt("aaMode", if (json.optBoolean("fxaa", false)) AA_FXAA else AA_OFF).coerceIn(AA_OFF, AA_SMAA),
toon = json.optBoolean("toon", false),
crt = json.optBoolean("crt", false),
ntsc = json.optBoolean("ntsc", false),
@@ -79,13 +85,13 @@ object ScreenEffectLooks {
desc = "Sharpening with a touch of contrast - the everyday one.", label = R.string.look_game_clarity, descRes = R.string.look_game_clarity_desc),
Look("Vivid", ScreenEffects(brightness = 3, contrast = 10, gamma = 0.98f, saturation = 145, cas = true, casLevel = 30, deband = true),
desc = "Colour pushed hard. Deband on so skies don't stripe.", label = R.string.look_vivid, descRes = R.string.look_vivid_desc),
Look("Cinematic", ScreenEffects(brightness = -4, contrast = 22, gamma = 1.10f, saturation = 88, cas = true, casLevel = 20, fxaa = true, deband = true),
Look("Cinematic", ScreenEffects(brightness = -4, contrast = 22, gamma = 1.10f, saturation = 88, cas = true, casLevel = 20, aaMode = ScreenEffects.AA_FXAA, deband = true),
desc = "Deeper contrast, cooler colour, edges smoothed.", label = R.string.look_cinematic, descRes = R.string.look_cinematic_desc),
Look("Competitive", ScreenEffects(brightness = 16, contrast = 18, gamma = 0.92f, saturation = 82, cas = true, casLevel = 75),
desc = "Shadows lifted and heavy sharpening - spot people first.", label = R.string.look_competitive, descRes = R.string.look_competitive_desc),
Look("Adaptive Sharpen", ScreenEffects(cas = true, casLevel = 85),
desc = "Sharpening only, colour untouched.", label = R.string.look_adaptive_sharpen, descRes = R.string.look_adaptive_sharpen_desc),
Look("Filmic", ScreenEffects(brightness = -2, contrast = 16, gamma = 1.14f, saturation = 92, cas = true, casLevel = 15, fxaa = true, deband = true),
Look("Filmic", ScreenEffects(brightness = -2, contrast = 16, gamma = 1.14f, saturation = 92, cas = true, casLevel = 15, aaMode = ScreenEffects.AA_FXAA, deband = true),
desc = "Film-like curve, slightly muted.", label = R.string.look_filmic, descRes = R.string.look_filmic_desc),
Look("Arcade", ScreenEffects(brightness = 6, contrast = 20, gamma = 0.95f, saturation = 170, cas = true, casLevel = 45, deband = true),
desc = "Loud and punchy.", label = R.string.look_arcade, descRes = R.string.look_arcade_desc),
@@ -103,7 +109,7 @@ object ScreenEffectLooks {
val t = l.effects
t.brightness == e.brightness && t.contrast == e.contrast && abs(t.gamma - e.gamma) < 0.005f &&
t.saturation == e.saturation && t.effectiveCas == e.effectiveCas &&
t.fxaa == e.fxaa && t.crt == e.crt && t.toon == e.toon && t.ntsc == e.ntsc && t.deband == e.deband &&
t.aaMode == e.aaMode && t.crt == e.crt && t.toon == e.toon && t.ntsc == e.ntsc && t.deband == e.deband &&
(l.scalingMode == null || l.scalingMode == upscaler)
}
}
@@ -1122,7 +1122,24 @@ private fun ScreenEffectsGroup(
a.onEffects(picked.effects)
}
}
ToggleRow(host, "fxaa", stringResource(R.string.drawer_fxaa), null, e.fxaa, chipModifier = track("fxaa")) { a.onEffects(e.copy(fxaa = it)) }
ChoiceRow(host, "antialiasing", stringResource(R.string.drawer_antialiasing), null,
listOf(
"off" to stringResource(R.string.frame_gen_off),
"fxaa" to stringResource(R.string.drawer_fxaa),
"smaa" to stringResource(R.string.drawer_smaa),
),
when (e.aaMode) {
ScreenEffects.AA_FXAA -> "fxaa"
ScreenEffects.AA_SMAA -> "smaa"
else -> "off"
}, chipModifier = track("antialiasing")) { mode ->
val aaMode = when (mode) {
"fxaa" -> ScreenEffects.AA_FXAA
"smaa" -> ScreenEffects.AA_SMAA
else -> ScreenEffects.AA_OFF
}
a.onEffects(e.copy(aaMode = aaMode))
}
ToggleRow(host, "toon", stringResource(R.string.drawer_toon), null, e.toon, chipModifier = track("toon")) { a.onEffects(e.copy(toon = it)) }
ToggleRow(host, "crt", stringResource(R.string.drawer_crt), null, e.crt, chipModifier = track("crt")) { a.onEffects(e.copy(crt = it)) }
ToggleRow(host, "ntsc", stringResource(R.string.drawer_ntsc), null, e.ntsc, chipModifier = track("ntsc")) { a.onEffects(e.copy(ntsc = it)) }
@@ -304,7 +304,7 @@ public final class WaylandCompositor {
public static native void nativeSetDeband(boolean enabled, int strength);
public static native void nativeSetScreenEffects(float brightness, float contrast, float gamma, float saturation,
boolean fxaa, boolean toon, boolean crt, boolean ntsc);
int aaMode, boolean toon, boolean crt, boolean ntsc);
public static native void nativeSetLookName(String name);