summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-02-03 19:21:27 -0800
committeryum <yum.food.vr@gmail.com>2023-02-13 14:36:59 -0800
commitf53a8af3a6b60ff486b984f473f75ab7e13cafc9 (patch)
tree1385c45773024f7bd8d6c96e8299e2991e0e85f3
parent1cb5bdfe8cba6fe4647448cd3cf0c63ecbd7dfc2 (diff)
Add hack to reduce outlines around emotes
Don't render any part of an emote with alpha < 0.5. Improves visual clarity in the common case at the cost of generality. * Emotes now use physically-based shading. * Use round() to denoise shader parameters instead of floor()
-rw-r--r--Scripts/generate_shader.py6
-rw-r--r--Shaders/TaSTT_lighting_template.cginc8
2 files changed, 9 insertions, 5 deletions
diff --git a/Scripts/generate_shader.py b/Scripts/generate_shader.py
index 15dc9b9..cf46533 100644
--- a/Scripts/generate_shader.py
+++ b/Scripts/generate_shader.py
@@ -64,8 +64,8 @@ def generateCgConstants(nbytes: int, nrows: int, ncols: int, prefix: str = "") -
# case 1:
# ...
#
-# res |= ((uint) round(_Letter_Row00_Col00_Byte0)) << (0 * 8);
-# res |= ((uint) round(_Letter_Row00_Col00_Byte1)) << (1 * 8);
+# res |= ((uint) _Letter_Row00_Col00_Byte0) << (0 * 8);
+# res |= ((uint) _Letter_Row00_Col00_Byte1) << (1 * 8);
# continue;
# }
# }
@@ -84,7 +84,7 @@ def generateLetterAccessor(nbytes: int, nrows: int, ncols: int, prefix: str = ""
lines.append(prefix + " case {}:".format(col))
for byte in range(0, nbytes):
param_name = generate_utils.getShaderParamByRowColByte(row, col, byte)
- lines.append(prefix + " res |= ((uint) round({})) << ({} * 8);".format(param_name, byte))
+ lines.append(prefix + " res |= ((uint) {}) << ({} * 8);".format(param_name, byte))
lines.append(prefix + " return res;")
lines.append(prefix + " default:")
lines.append(prefix + " return 0;")
diff --git a/Shaders/TaSTT_lighting_template.cginc b/Shaders/TaSTT_lighting_template.cginc
index aa20751..48d776d 100644
--- a/Shaders/TaSTT_lighting_template.cginc
+++ b/Shaders/TaSTT_lighting_template.cginc
@@ -688,8 +688,12 @@ fixed4 frag(v2f i) : SV_Target
} else {
bg = light(i, Background_Color);
}
- if (is_emote) {
- bg.rgb = lerp(bg.rgb, text.rgb, text.w);
+ // Hack: If alpha (text.w) is less than 0.5, don't render it. This
+ // eliminates outlines around simple emotes with transparent backgrounds.
+ if (is_emote && text.w > 0.5) {
+ // Use emote alpha to mix emote color with background color (compositing).
+ text.rgb = lerp(bg.rgb, text.rgb, text.w);
+ bg = light(i, fixed4(text.rgb, 1.0));
}
return bg;
} else {