summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Fonts/Bitmaps/font-0.png.meta14
-rw-r--r--Fonts/Bitmaps/font-1.png.meta14
-rw-r--r--Fonts/Bitmaps/font-2.png.meta14
-rw-r--r--Fonts/Bitmaps/font-3.png.meta14
-rw-r--r--Fonts/Bitmaps/font-4.png.meta14
-rw-r--r--Fonts/Bitmaps/font-5.png.meta14
-rw-r--r--Fonts/Bitmaps/font-6.png.meta14
-rw-r--r--Shaders/TaSTT_lighting_template.cginc46
-rw-r--r--Shaders/TaSTT_template.shader2
9 files changed, 83 insertions, 63 deletions
diff --git a/Fonts/Bitmaps/font-0.png.meta b/Fonts/Bitmaps/font-0.png.meta
index e7d9c33..ccd4af5 100644
--- a/Fonts/Bitmaps/font-0.png.meta
+++ b/Fonts/Bitmaps/font-0.png.meta
@@ -5,13 +5,13 @@ TextureImporter:
externalObjects: {}
serializedVersion: 11
mipmaps:
- mipMapMode: 0
- enableMipMap: 0
+ mipMapMode: 1
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
- mipMapsPreserveCoverage: 0
+ mipMapsPreserveCoverage: 1
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
@@ -33,7 +33,7 @@ TextureImporter:
serializedVersion: 2
filterMode: 1
aniso: 1
- mipBias: 0
+ mipBias: 1
wrapU: 0
wrapV: 0
wrapW: 0
@@ -61,7 +61,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -73,7 +73,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -85,7 +85,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
diff --git a/Fonts/Bitmaps/font-1.png.meta b/Fonts/Bitmaps/font-1.png.meta
index 4f7a87a..4eab3a4 100644
--- a/Fonts/Bitmaps/font-1.png.meta
+++ b/Fonts/Bitmaps/font-1.png.meta
@@ -5,13 +5,13 @@ TextureImporter:
externalObjects: {}
serializedVersion: 11
mipmaps:
- mipMapMode: 0
- enableMipMap: 0
+ mipMapMode: 1
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
- mipMapsPreserveCoverage: 0
+ mipMapsPreserveCoverage: 1
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
@@ -33,7 +33,7 @@ TextureImporter:
serializedVersion: 2
filterMode: 1
aniso: 1
- mipBias: 0
+ mipBias: 1
wrapU: 0
wrapV: 0
wrapW: 0
@@ -61,7 +61,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -73,7 +73,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -85,7 +85,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
diff --git a/Fonts/Bitmaps/font-2.png.meta b/Fonts/Bitmaps/font-2.png.meta
index 07d8ca0..5c6c1a2 100644
--- a/Fonts/Bitmaps/font-2.png.meta
+++ b/Fonts/Bitmaps/font-2.png.meta
@@ -5,13 +5,13 @@ TextureImporter:
externalObjects: {}
serializedVersion: 11
mipmaps:
- mipMapMode: 0
- enableMipMap: 0
+ mipMapMode: 1
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
- mipMapsPreserveCoverage: 0
+ mipMapsPreserveCoverage: 1
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
@@ -33,7 +33,7 @@ TextureImporter:
serializedVersion: 2
filterMode: 1
aniso: 1
- mipBias: 0
+ mipBias: 1
wrapU: 0
wrapV: 0
wrapW: 0
@@ -61,7 +61,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -73,7 +73,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -85,7 +85,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
diff --git a/Fonts/Bitmaps/font-3.png.meta b/Fonts/Bitmaps/font-3.png.meta
index d2fc0e3..5328401 100644
--- a/Fonts/Bitmaps/font-3.png.meta
+++ b/Fonts/Bitmaps/font-3.png.meta
@@ -5,13 +5,13 @@ TextureImporter:
externalObjects: {}
serializedVersion: 11
mipmaps:
- mipMapMode: 0
- enableMipMap: 0
+ mipMapMode: 1
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
- mipMapsPreserveCoverage: 0
+ mipMapsPreserveCoverage: 1
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
@@ -33,7 +33,7 @@ TextureImporter:
serializedVersion: 2
filterMode: 1
aniso: 1
- mipBias: 0
+ mipBias: 1
wrapU: 0
wrapV: 0
wrapW: 0
@@ -61,7 +61,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -73,7 +73,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -85,7 +85,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
diff --git a/Fonts/Bitmaps/font-4.png.meta b/Fonts/Bitmaps/font-4.png.meta
index 55f89ef..54a3e23 100644
--- a/Fonts/Bitmaps/font-4.png.meta
+++ b/Fonts/Bitmaps/font-4.png.meta
@@ -5,13 +5,13 @@ TextureImporter:
externalObjects: {}
serializedVersion: 11
mipmaps:
- mipMapMode: 0
- enableMipMap: 0
+ mipMapMode: 1
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
- mipMapsPreserveCoverage: 0
+ mipMapsPreserveCoverage: 1
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
@@ -33,7 +33,7 @@ TextureImporter:
serializedVersion: 2
filterMode: 1
aniso: 1
- mipBias: 0
+ mipBias: 1
wrapU: 0
wrapV: 0
wrapW: 0
@@ -61,7 +61,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -73,7 +73,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -85,7 +85,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
diff --git a/Fonts/Bitmaps/font-5.png.meta b/Fonts/Bitmaps/font-5.png.meta
index d40c504..4125f52 100644
--- a/Fonts/Bitmaps/font-5.png.meta
+++ b/Fonts/Bitmaps/font-5.png.meta
@@ -5,13 +5,13 @@ TextureImporter:
externalObjects: {}
serializedVersion: 11
mipmaps:
- mipMapMode: 0
- enableMipMap: 0
+ mipMapMode: 1
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
- mipMapsPreserveCoverage: 0
+ mipMapsPreserveCoverage: 1
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
@@ -33,7 +33,7 @@ TextureImporter:
serializedVersion: 2
filterMode: 1
aniso: 1
- mipBias: 0
+ mipBias: 1
wrapU: 0
wrapV: 0
wrapW: 0
@@ -61,7 +61,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -73,7 +73,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -85,7 +85,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
diff --git a/Fonts/Bitmaps/font-6.png.meta b/Fonts/Bitmaps/font-6.png.meta
index e96c5da..af32846 100644
--- a/Fonts/Bitmaps/font-6.png.meta
+++ b/Fonts/Bitmaps/font-6.png.meta
@@ -5,13 +5,13 @@ TextureImporter:
externalObjects: {}
serializedVersion: 11
mipmaps:
- mipMapMode: 0
- enableMipMap: 0
+ mipMapMode: 1
+ enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
- mipMapsPreserveCoverage: 0
+ mipMapsPreserveCoverage: 1
alphaTestReferenceValue: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
@@ -33,7 +33,7 @@ TextureImporter:
serializedVersion: 2
filterMode: 1
aniso: 1
- mipBias: 0
+ mipBias: 1
wrapU: 0
wrapV: 0
wrapW: 0
@@ -61,7 +61,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -73,7 +73,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
@@ -85,7 +85,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
- maxTextureSize: 8192
+ maxTextureSize: 4096
resizeAlgorithm: 1
textureFormat: -1
textureCompression: 2
diff --git a/Shaders/TaSTT_lighting_template.cginc b/Shaders/TaSTT_lighting_template.cginc
index e86df16..99cca58 100644
--- a/Shaders/TaSTT_lighting_template.cginc
+++ b/Shaders/TaSTT_lighting_template.cginc
@@ -26,6 +26,8 @@ struct v2f
float Use_Custom_Background;
sampler2D Custom_Background;
+float Enable_Dithering;
+
sampler2D _Font_0x0000_0x1FFF;
float4 _Font_0x0000_0x1FFF_TexelSize;
sampler2D _Font_0x2000_0x3FFF;
@@ -407,6 +409,13 @@ fixed4 light(v2f i, fixed4 unlit)
return fixed4(pbr, unlit.a);
}
+bool f3ltf3(fixed3 a, fixed3 b)
+{
+ return a[0] < b[0] &&
+ a[1] < b[1] &&
+ a[2] < b[2];
+}
+
fixed4 frag (v2f i) : SV_Target
{
float2 uv = i.uv;
@@ -451,16 +460,8 @@ fixed4 frag (v2f i) : SV_Target
uv_margin *= 4;
float2 uv_with_margin = AddMarginToUV(uv, uv_margin);
- // We use ddx/ddy to get the correct mipmaps of the font textures. This
- // confers 2 main benefits:
- // 1. We don't use as much VRAM for distant players.
- // 2. Glyphs anti-alias much more nicely.
- // Dividing the derivative subjectively makes the resulting mip-maps look a
- // little more legible.
- float2 iddx = ddx(i.uv.x) / 2;
- float2 iddy = ddy(i.uv.y) / 2;
-
fixed4 text = fixed4(0, 0, 0, 0);
+ bool discard_text = false;
{
int letter = GetLetterParameter(uv_with_margin);
@@ -477,12 +478,25 @@ fixed4 frag (v2f i) : SV_Target
letter_uv = GetLetter(uv_with_margin, letter, texture_cols, texture_rows, 8, 4);
}
+ if (letter_uv.x == 0 && letter_uv.y == 0) {
+ discard_text = true;
+ }
+
// Add a small amount of temporal noise to the letter UV. This makes text
// more readable at intermediate distances.
// Assume that all glyph bitmaps have the same texelsize.
- float noise = frac(i.position.x * i.position.y) + _SinTime[3]/2;
- letter_uv.x += noise * _Font_0x0000_0x1FFF_TexelSize[0];
- letter_uv.y += noise * _Font_0x0000_0x1FFF_TexelSize[1];
+ if (Enable_Dithering) {
+ float noise = (2 * frac(i.position.x * i.position.y) + (_SinTime[3] + 1)) / 4;
+ letter_uv.x += noise * _Font_0x0000_0x1FFF_TexelSize[0];
+ letter_uv.y += noise * _Font_0x0000_0x1FFF_TexelSize[1];
+ }
+
+ // We use ddx/ddy to get the correct mipmaps of the font textures. This
+ // confers 2 main benefits:
+ // 1. We don't use as much VRAM for distant players.
+ // 2. Glyphs anti-alias much more nicely.
+ float2 iddx = ddx(letter_uv.x);
+ float2 iddy = ddy(letter_uv.y);
int which_texture = (int) floor(letter / (64 * 128));
[forcecase] switch (which_texture)
@@ -513,9 +527,13 @@ fixed4 frag (v2f i) : SV_Target
break;
}
}
- fixed4 black = fixed4(0,0,0,1);
- if (text.r == black.r && text.g == black.g && text.b == black.b && text.a == black.a) {
+ // The edges of each letter cell can be slightly grey due to mip maps.
+ // Detect this and shade it as the background.
+ fixed3 grey = fixed3(.1,.1,.1);
+ if (f3ltf3(text.rgb, grey) || discard_text) {
if (Use_Custom_Background) {
+ float2 iddx = ddx(uv.x);
+ float2 iddy = ddy(uv.y);
return light(
i,
tex2Dgrad(Custom_Background, uv, iddx, iddy));
diff --git a/Shaders/TaSTT_template.shader b/Shaders/TaSTT_template.shader
index f30fc44..e6fd50e 100644
--- a/Shaders/TaSTT_template.shader
+++ b/Shaders/TaSTT_template.shader
@@ -18,6 +18,8 @@
[MaterialToggle] Enable_Margin_Effect_Squares(
"Enable margin effect: Squares", float) = 0
+ [MaterialToggle] Enable_Dithering("Enable font dithering", float) = 1
+
[MaterialToggle] Use_Custom_Background("Enable custom background", float) = 0
Custom_Background("Custom background", 2D) = "black" {}