yum-slop/TaSTT
Free self-hosted STT for VRChat.
git clone https://git.yummers.dev/yum-slop/TaSTT
175965d
v0.19.2
1#!/usr/bin/env python3 2 3# This is the algorithm that the anti-aliasing logic inside 4# TaSTT_lighting_template.cginc uses. 5 6from math import fmod 7 8x = .5 9y = .1 10aa = 10 11 12# This lets us handle values smaller than 1. We're creating an m*n rectangle 13# and walking a path left-to-right, top-to-bottom through it. 14x_cap = max ( x , 1.0 / x ) 15y_cap = max ( y , 1.0 / y ) 16 17( f" { x_cap } { y_cap } " ) 18 19def lerp ( lo , hi , fract ) : 20return lo + ( hi - lo ) * fract 21 22for i in range ( 0 , aa ) : 23# We want to subdivide an x*y area into `aa` evenly spaced pieces. 24region = x_cap * y_cap 25 26stride = region / aa 27 28region_i = i * stride + stride / 2 29region_x = region_i / y_cap 30region_y = fmod ( region_i , y_cap ) 31 32( f" { region_x } { region_y } " ) 33 34region_x = lerp ( 0 , x , region_x / x_cap ) 35region_y = lerp ( 0 , y , region_y / y_cap ) 36 37( f" { region_x } { region_y } " ) 38 39assert ( region_x >= 0 ) 40assert ( region_x <= x ) 41assert ( region_y >= 0 ) 42assert ( region_y <= y ) 43