yum-archive/Tooner
A toon shader for Unity's BIRP.
git clone https://git.yummers.dev/yum-archive/Tooner
3dcb2fd
master
1#ifndef __SHEAR_MATH_INC 2#define __SHEAR_MATH_INC 3 4#if defined(_GIMMICK_SHEAR_LOCATION) 5 6void getMeshRendererMatrices(bool invert, out float3x3 rot_fix, 7 out float4x4 ts_fix) { 8 if (_Gimmick_Shear_Location_Mesh_Renderer_Fix) { 9 float3 theta = float3( 10 _Gimmick_Shear_Location_Mesh_Renderer_Rotation.x, 11 _Gimmick_Shear_Location_Mesh_Renderer_Rotation.y, 12 _Gimmick_Shear_Location_Mesh_Renderer_Rotation.z); 13 theta = invert ? -theta : theta; 14 float3x3 rotate_x = float3x3( 15 1, 0, 0, 16 0, cos(theta.x), -sin(theta.x), 17 0, sin(theta.x), cos(theta.x)); 18 float3x3 rotate_y = float3x3( 19 cos(theta.y), 0, sin(theta.y), 20 0, 1, 0, 21 -sin(theta.y), 0, cos(theta.y)); 22 float3x3 rotate_z = float3x3( 23 cos(theta.z), -sin(theta.z), 0, 24 sin(theta.z), cos(theta.z), 0, 25 0, 0, 1); 26 rot_fix = invert ? 27 mul(rotate_x, mul(rotate_y, rotate_z)) : 28 mul(rotate_z, mul(rotate_y, rotate_x)); 29 float3 scale = float3( 30 _Gimmick_Shear_Location_Mesh_Renderer_Scale.x, 31 _Gimmick_Shear_Location_Mesh_Renderer_Scale.y, 32 _Gimmick_Shear_Location_Mesh_Renderer_Scale.z); 33 scale = invert ? 1 / scale : scale; 34 float3 offset = float3( 35 _Gimmick_Shear_Location_Mesh_Renderer_Offset.x, 36 _Gimmick_Shear_Location_Mesh_Renderer_Offset.y, 37 _Gimmick_Shear_Location_Mesh_Renderer_Offset.z); 38 offset = invert ? -offset : offset; 39 ts_fix = float4x4( 40 scale.x, 0, 0, offset.x, 41 0, scale.y, 0, offset.y, 42 0, 0, scale.z, offset.z, 43 0, 0, 0, 1); 44 } else { 45 rot_fix = float3x3( 46 1, 0, 0, 47 0, 1, 0, 48 0, 0, 1); 49 ts_fix = float4x4( 50 1, 0, 0, 0, 51 0, 1, 0, 0, 52 0, 0, 1, 0, 53 0, 0, 0, 1); 54 } 55} 56 57#endif // _GIMMICK_SHEAR_LOCATION 58 59#endif // __SHEAR_MATH_INC 60