yum-slop/TaSTT
Free self-hosted STT for VRChat.
git clone https://git.yummers.dev/yum-slop/TaSTT
323eeba
v0.21.0
1#ifndef TASTT_LIGHTING 2#define TASTT_LIGHTING 3 4#include "AutoLight.cginc" 5#include "UnityPBSLighting.cginc" 6#include "ray_march.cginc" 7#include "pbr.cginc" 8#include "poi.cginc" 9#include "stt_generated.cginc" 10#include "stt_text.cginc" 11 12void getVertexLightColor(inout v2f i) 13{ 14 #if defined(VERTEXLIGHT_ON) 15 float3 light_pos = float3(unity_4LightPosX0.x, unity_4LightPosY0.x, 16 unity_4LightPosZ0.x); 17 float3 light_vec = light_pos - i.worldPos; 18 float3 light_dir = normalize(light_vec); 19 float ndotl = DotClamped(i.normal, light_dir); 20 // Light fills an expanding sphere with surface area 4 * pi * r^2. 21 // By conservation of energy, this means that at distance r, light intensity 22 // is proportional to 1/(r^2). 23 float attenuation = 1 / (1 + dot(light_vec, light_vec) * unity_4LightAtten0.x); 24 i.vertexLightColor = unity_LightColor[0].rgb * ndotl * attenuation; 25 26 i.vertexLightColor = Shade4PointLights( 27 unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 28 unity_LightColor[0].rgb, 29 unity_LightColor[1].rgb, 30 unity_LightColor[2].rgb, 31 unity_LightColor[3].rgb, 32 unity_4LightAtten0, i.worldPos, i.normal 33 ); 34 #endif 35} 36 37v2f vert(appdata v) 38{ 39 v2f o; 40 o.position = UnityObjectToClipPos(v.position); 41 o.worldPos = mul(unity_ObjectToWorld, v.position); 42 o.normal = UnityObjectToWorldNormal(v.normal); 43 44 o.uv = v.uv; 45 getVertexLightColor(o); 46 47 return o; 48} 49 50fixed4 frag(v2f i, out float depth : SV_DepthLessEqual) : SV_Target 51{ 52 depth = -1000.0; 53 54 return stt_ray_march(i, depth); 55} 56 57#endif // TASTT_LIGHTING