diff options
| author | yum <yum.food.vr@gmail.com> | 2023-08-12 17:49:41 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-08-12 17:51:45 -0700 |
| commit | 5d44c186691f42a8a64c895c67079ebe2515ea71 (patch) | |
| tree | 559bd1f9362eade29bfbfe4049c02848a3432c96 /Shaders/STT_text.cginc | |
| parent | 0434f32e1a510c8c1d3feb21ab4564993d69eead (diff) | |
Improve numerical stability in raymarcher
Increase units by a factor of 100 to avoid running into numerical
instability on 32-bit floats. This comes at zero measured performance
cost. This makes a visible difference in quality.
Other minor changes:
* Raymarching loop tries to get up to 4x closer than
MINIMUM_HIT_DISTANCE before bailing out. This comes at no measured
performance cost.
* Convert `fixed` types to `float` in STT_text.cginc.
Diffstat (limited to 'Shaders/STT_text.cginc')
| -rw-r--r-- | Shaders/STT_text.cginc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Shaders/STT_text.cginc b/Shaders/STT_text.cginc index 095df6a..dae613b 100644 --- a/Shaders/STT_text.cginc +++ b/Shaders/STT_text.cginc @@ -38,7 +38,7 @@ float prng(float2 p) return frac(sin(dot(p, float2(561.0, 885.0))) * 776.2) / 2.0; } -bool f3ltf3(fixed3 a, fixed3 b) +bool f3ltf3(float3 a, float3 b) { return (a[0] < b[0]) * (a[1] < b[1]) * @@ -125,7 +125,7 @@ float4 GetLetter(float2 uv) { letter_uv.x += lerp(0, (noise - 0.5) * iddx / 4.0, add_dithering); letter_uv.y += lerp(0, (noise - 0.5) * iddy / 4.0, add_dithering); - fixed4 text = fixed4(0, 0, 0, 0); + float4 text = float4(0, 0, 0, 0); int which_texture = (int) floor(letter / (uint) (64 * 128)); [forcecase] switch (which_texture) { @@ -165,14 +165,14 @@ float4 GetLetter(float2 uv) { break; default: // Return some distinctive pattern that will look like a bug. - return fixed4(1, 0, _SinTime[0], 1); + return float4(1, 0, _SinTime[0], 1); } // The edges of each letter cell can be slightly grey due to mip maps. // Detect this and shade it as the background. - fixed3 grey = 0.7; + float3 grey = 0.7; bool disc = !(!f3ltf3(text.rgb, grey) * !discard_text * !is_emote); - return lerp(fixed4(text.rgb, 1), 0, disc); + return lerp(float4(text.rgb, 1), 0, disc); } #endif // __STT_TEXT_INC__ |
