diff options
| author | yum <yum.food.vr@gmail.com> | 2023-02-02 18:00:18 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-02-13 14:36:25 -0800 |
| commit | 1cb5bdfe8cba6fe4647448cd3cf0c63ecbd7dfc2 (patch) | |
| tree | e338264fbf6f75911246ca61c934110e00f144c8 /Shaders | |
| parent | 7c6894614dcc3ebc5d4c8839b64f4da761b5ccf0 (diff) | |
Finish emotes
Emotes require 2 bytes per char. They're encoded into the region
[0xE000, infinity). The texture is 4k, and uses 1k vertical pixels
per emote segment, for a maximum of 32 segments.
* Reduce volume of noise indicator by 90%. Quiet is probably better.
Might want to add a volume slider idk.
* Bugfix: emotes without a transparency channel now work
* Address a couple Unity performance complaints about the shader
Diffstat (limited to 'Shaders')
| -rw-r--r-- | Shaders/TaSTT_lighting_template.cginc | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/Shaders/TaSTT_lighting_template.cginc b/Shaders/TaSTT_lighting_template.cginc index 15b4e41..aa20751 100644 --- a/Shaders/TaSTT_lighting_template.cginc +++ b/Shaders/TaSTT_lighting_template.cginc @@ -273,7 +273,7 @@ float2 GetLetter(float2 uv, int nth_letter, } // Get the value of the parameter for the cell we're in. -int GetLetterParameter(float2 uv) +uint GetLetterParameter(float2 uv) { float CHAR_COL = floor(uv.x * NCOLS); float CHAR_ROW = floor(uv.y * NROWS); @@ -575,7 +575,7 @@ fixed4 frag(v2f i) : SV_Target fixed4 text = fixed4(0, 0, 0, 0); bool discard_text = false; - int letter = GetLetterParameter(uv_with_margin); + uint letter = GetLetterParameter(uv_with_margin); float texture_cols; float texture_rows; @@ -587,8 +587,8 @@ fixed4 frag(v2f i) : SV_Target letter_uv = GetLetter(uv_with_margin, letter % 0x2000, texture_cols, texture_rows, NCOLS, NROWS, /*margin=*/0.02); } else { is_emote = true; - texture_cols = 8.0; - texture_rows = 4.0; + 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); } @@ -604,7 +604,7 @@ fixed4 frag(v2f i) : SV_Target const float iddx = ddx(letter_uv.x); const float iddy = ddy(letter_uv.y); - if (Enable_Dithering) { + if (Enable_Dithering && !is_emote) { // Add noise to UV. // Here, iddx and iddy tell us how big the current UV cell is with respect to // screen space (i.e. how many pixels wide it is). @@ -635,17 +635,8 @@ fixed4 frag(v2f i) : SV_Target //float2 cur_letter_uv = letter_uv + float2(aa_region_x, aa_region_y); float2 cur_letter_uv = letter_uv; - - if (is_emote) { - // Emotes are broken up into several pieces and packed tightly. Thus one - // emote may wrap around the edge of the texture. Clamping near the edge - // of the texture avoids a small line from appearing in the middle of - // these textures. - float epsilon = 0.002; - cur_letter_uv.x = clamp(cur_letter_uv.x, epsilon, 1.0 - epsilon); - } - int which_texture = (int) floor(letter / (64 * 128)); + int which_texture = (int) floor(letter / (uint) (64 * 128)); [forcecase] switch (which_texture) { case 0: |
