summaryrefslogtreecommitdiffstats
path: root/Shaders
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-03-21 17:13:32 -0700
committeryum <yum.food.vr@gmail.com>2023-03-21 17:13:32 -0700
commit1f15133dd985442af20d42a96fbcd0007f03bd2b (patch)
tree15e32f494a1bab1c856f6c8561ed01e5bb436bf8 /Shaders
parent656d7c2092545b18d981acfac000c73fb2128e4a (diff)
Reduce texture memory usage for English speakersv0.10.0
We used to populate 7 4k textures + 1 2k texture for all users. Now if the user has configured `bytes_per_char=1` in the Unity panel, we just populate a single 512x512 texture containing the first 128 ASCII characters. This reduces texture memory usage by 99.74%, from 134.67 MB to 340 KB.
Diffstat (limited to 'Shaders')
-rw-r--r--Shaders/TaSTT_lighting_template.cginc10
1 files changed, 4 insertions, 6 deletions
diff --git a/Shaders/TaSTT_lighting_template.cginc b/Shaders/TaSTT_lighting_template.cginc
index 48d776d..da3a2ec 100644
--- a/Shaders/TaSTT_lighting_template.cginc
+++ b/Shaders/TaSTT_lighting_template.cginc
@@ -275,8 +275,8 @@ float2 GetLetter(float2 uv, int nth_letter,
// Get the value of the parameter for the cell we're in.
uint GetLetterParameter(float2 uv)
{
- float CHAR_COL = floor(uv.x * NCOLS);
- float CHAR_ROW = floor(uv.y * NROWS);
+ float CHAR_COL = floor(uv.x * BOARD_NCOLS);
+ float CHAR_ROW = floor(uv.y * BOARD_NROWS);
int res = 0;
// %TEMPLATE__CG_LETTER_ACCESSOR%
@@ -582,15 +582,13 @@ fixed4 frag(v2f i) : SV_Target
float2 letter_uv;
bool is_emote = false;
if (letter < 0xE000) {
- texture_cols = 128.0;
- texture_rows = 64.0;
- letter_uv = GetLetter(uv_with_margin, letter % 0x2000, texture_cols, texture_rows, NCOLS, NROWS, /*margin=*/0.02);
+ letter_uv = GetLetter(uv_with_margin, letter % 0x2000, TEXTURE_NCOLS, TEXTURE_NROWS, BOARD_NCOLS, BOARD_NROWS, /*margin=*/0.02);
} else {
is_emote = true;
texture_cols = 16.0;
texture_rows = 8.0;
// This will need to be updated if we create multiple emote textures.
- letter_uv = GetLetter(uv_with_margin, letter % 0x2000, texture_cols, texture_rows, NCOLS, NROWS, /*margin=*/0);
+ letter_uv = GetLetter(uv_with_margin, letter % 0x2000, texture_cols, texture_rows, BOARD_NCOLS, BOARD_NROWS, /*margin=*/0);
}
if (letter_uv.x == -1 && letter_uv.y == -1) {