yum-archive/Tooner
A toon shader for Unity's BIRP.
git clone https://git.yummers.dev/yum-archive/Tooner
ffc4bb2
master
1#ifndef __TEXTURE_MACROS_INC 2#define __TEXTURE_MACROS_INC 3 4#include "interpolators.cginc" 5 6float2 get_uv_by_channel(v2f i, uint which_channel) { 7 switch (which_channel) { 8 case 0: 9 return i.uv0; 10 break; 11#if !defined(_OPTIMIZE_INTERPOLATORS) 12 case 1: 13 return i.uv1; 14 break; 15#if !defined(LIGHTMAP_ON) 16 case 2: 17 return i.uv2; 18 break; 19 case 3: 20 return i.uv3; 21 break; 22 case 4: 23 return i.uv4; 24 break; 25 case 5: 26 return i.uv5; 27 break; 28 case 6: 29 return i.uv6; 30 break; 31 case 7: 32 return i.uv7; 33 break; 34#endif 35#endif // _OPTIMIZE_INTERPOLATORS 36 default: 37 return 0; 38 break; 39 } 40} 41 42#define UV_SCOFF(i, tex_st, which_channel) get_uv_by_channel(i, round(which_channel)) * (tex_st).xy + (tex_st).zw 43 44#if defined(_PBR_SAMPLER_LINEAR_REPEAT) 45#define GET_SAMPLER_PBR linear_repeat_s 46#elif defined(_PBR_SAMPLER_LINEAR_CLAMP) 47#define GET_SAMPLER_PBR linear_clamp_s 48#elif defined(_PBR_SAMPLER_POINT_REPEAT) 49#define GET_SAMPLER_PBR point_repeat_s 50#elif defined(_PBR_SAMPLER_POINT_CLAMP) 51#define GET_SAMPLER_PBR point_clamp_s 52#elif defined(_PBR_SAMPLER_BILINEAR_REPEAT) 53#define GET_SAMPLER_PBR bilinear_repeat_s 54#elif defined(_PBR_SAMPLER_BILINEAR_CLAMP) 55#define GET_SAMPLER_PBR bilinear_clamp_s 56#else 57#define GET_SAMPLER_PBR bilinear_clamp_s 58#endif 59 60#if defined(_PBR_OVERLAY0_SAMPLER_LINEAR_REPEAT) 61#define GET_SAMPLER_OV0 linear_repeat_s 62#elif defined(_PBR_OVERLAY0_SAMPLER_LINEAR_CLAMP) 63#define GET_SAMPLER_OV0 linear_clamp_s 64#elif defined(_PBR_OVERLAY0_SAMPLER_POINT_REPEAT) 65#define GET_SAMPLER_OV0 point_repeat_s 66#elif defined(_PBR_OVERLAY0_SAMPLER_POINT_CLAMP) 67#define GET_SAMPLER_OV0 point_clamp_s 68#elif defined(_PBR_OVERLAY0_SAMPLER_BILINEAR_REPEAT) 69#define GET_SAMPLER_OV0 bilinear_repeat_s 70#elif defined(_PBR_OVERLAY0_SAMPLER_BILINEAR_CLAMP) 71#define GET_SAMPLER_OV0 bilinear_clamp_s 72#else 73#define GET_SAMPLER_OV0 linear_clamp_s 74#endif 75 76#if defined(_PBR_OVERLAY1_SAMPLER_LINEAR_REPEAT) 77#define GET_SAMPLER_OV1 linear_repeat_s 78#elif defined(_PBR_OVERLAY1_SAMPLER_LINEAR_CLAMP) 79#define GET_SAMPLER_OV1 linear_clamp_s 80#elif defined(_PBR_OVERLAY1_SAMPLER_POINT_REPEAT) 81#define GET_SAMPLER_OV1 point_repeat_s 82#elif defined(_PBR_OVERLAY1_SAMPLER_POINT_CLAMP) 83#define GET_SAMPLER_OV1 point_clamp_s 84#elif defined(_PBR_OVERLAY1_SAMPLER_BILINEAR_REPEAT) 85#define GET_SAMPLER_OV1 bilinear_repeat_s 86#elif defined(_PBR_OVERLAY1_SAMPLER_BILINEAR_CLAMP) 87#define GET_SAMPLER_OV1 bilinear_clamp_s 88#else 89#define GET_SAMPLER_OV1 linear_clamp_s 90#endif 91 92#if defined(_PBR_OVERLAY2_SAMPLER_LINEAR_REPEAT) 93#define GET_SAMPLER_OV2 linear_repeat_s 94#elif defined(_PBR_OVERLAY2_SAMPLER_LINEAR_CLAMP) 95#define GET_SAMPLER_OV2 linear_clamp_s 96#elif defined(_PBR_OVERLAY2_SAMPLER_POINT_REPEAT) 97#define GET_SAMPLER_OV2 point_repeat_s 98#elif defined(_PBR_OVERLAY2_SAMPLER_POINT_CLAMP) 99#define GET_SAMPLER_OV2 point_clamp_s 100#elif defined(_PBR_OVERLAY2_SAMPLER_BILINEAR_REPEAT) 101#define GET_SAMPLER_OV2 bilinear_repeat_s 102#elif defined(_PBR_OVERLAY2_SAMPLER_BILINEAR_CLAMP) 103#define GET_SAMPLER_OV2 bilinear_clamp_s 104#else 105#define GET_SAMPLER_OV2 linear_clamp_s 106#endif 107 108#if defined(_PBR_OVERLAY3_SAMPLER_LINEAR_REPEAT) 109#define GET_SAMPLER_OV3 linear_repeat_s 110#elif defined(_PBR_OVERLAY3_SAMPLER_LINEAR_CLAMP) 111#define GET_SAMPLER_OV3 linear_clamp_s 112#elif defined(_PBR_OVERLAY3_SAMPLER_POINT_REPEAT) 113#define GET_SAMPLER_OV3 point_repeat_s 114#elif defined(_PBR_OVERLAY3_SAMPLER_POINT_CLAMP) 115#define GET_SAMPLER_OV3 point_clamp_s 116#elif defined(_PBR_OVERLAY3_SAMPLER_BILINEAR_REPEAT) 117#define GET_SAMPLER_OV3 bilinear_repeat_s 118#elif defined(_PBR_OVERLAY3_SAMPLER_BILINEAR_CLAMP) 119#define GET_SAMPLER_OV3 bilinear_clamp_s 120#else 121#define GET_SAMPLER_OV3 linear_clamp_s 122#endif 123 124#if defined(_RIM_LIGHTING0_SAMPLER_LINEAR_REPEAT) 125#define GET_SAMPLER_RL0 linear_repeat_s 126#elif defined(_RIM_LIGHTING0_SAMPLER_LINEAR_CLAMP) 127#define GET_SAMPLER_RL0 linear_clamp_s 128#elif defined(_RIM_LIGHTING0_SAMPLER_POINT_REPEAT) 129#define GET_SAMPLER_RL0 point_repeat_s 130#elif defined(_RIM_LIGHTING0_SAMPLER_POINT_CLAMP) 131#define GET_SAMPLER_RL0 point_clamp_s 132#elif defined(_RIM_LIGHTING0_SAMPLER_BILINEAR_REPEAT) 133#define GET_SAMPLER_RL0 bilinear_repeat_s 134#elif defined(_RIM_LIGHTING0_SAMPLER_BILINEAR_CLAMP) 135#define GET_SAMPLER_RL0 bilinear_clamp_s 136#else 137#define GET_SAMPLER_RL0 linear_clamp_s 138#endif 139 140#if defined(_RIM_LIGHTING1_SAMPLER_LINEAR_REPEAT) 141#define GET_SAMPLER_RL1 linear_repeat_s 142#elif defined(_RIM_LIGHTING1_SAMPLER_LINEAR_CLAMP) 143#define GET_SAMPLER_RL1 linear_clamp_s 144#elif defined(_RIM_LIGHTING1_SAMPLER_POINT_REPEAT) 145#define GET_SAMPLER_RL1 point_repeat_s 146#elif defined(_RIM_LIGHTING1_SAMPLER_POINT_CLAMP) 147#define GET_SAMPLER_RL1 point_clamp_s 148#elif defined(_RIM_LIGHTING1_SAMPLER_BILINEAR_REPEAT) 149#define GET_SAMPLER_RL1 bilinear_repeat_s 150#elif defined(_RIM_LIGHTING1_SAMPLER_BILINEAR_CLAMP) 151#define GET_SAMPLER_RL1 bilinear_clamp_s 152#else 153#define GET_SAMPLER_RL1 linear_clamp_s 154#endif 155 156#if defined(_RIM_LIGHTING2_SAMPLER_LINEAR_REPEAT) 157#define GET_SAMPLER_RL2 linear_repeat_s 158#elif defined(_RIM_LIGHTING2_SAMPLER_LINEAR_CLAMP) 159#define GET_SAMPLER_RL2 linear_clamp_s 160#elif defined(_RIM_LIGHTING2_SAMPLER_POINT_REPEAT) 161#define GET_SAMPLER_RL2 point_repeat_s 162#elif defined(_RIM_LIGHTING2_SAMPLER_POINT_CLAMP) 163#define GET_SAMPLER_RL2 point_clamp_s 164#elif defined(_RIM_LIGHTING2_SAMPLER_BILINEAR_REPEAT) 165#define GET_SAMPLER_RL2 bilinear_repeat_s 166#elif defined(_RIM_LIGHTING2_SAMPLER_BILINEAR_CLAMP) 167#define GET_SAMPLER_RL2 bilinear_clamp_s 168#else 169#define GET_SAMPLER_RL2 linear_clamp_s 170#endif 171 172#if defined(_RIM_LIGHTING3_SAMPLER_LINEAR_REPEAT) 173#define GET_SAMPLER_RL3 linear_repeat_s 174#elif defined(_RIM_LIGHTING3_SAMPLER_LINEAR_CLAMP) 175#define GET_SAMPLER_RL3 linear_clamp_s 176#elif defined(_RIM_LIGHTING3_SAMPLER_POINT_REPEAT) 177#define GET_SAMPLER_RL3 point_repeat_s 178#elif defined(_RIM_LIGHTING3_SAMPLER_POINT_CLAMP) 179#define GET_SAMPLER_RL3 point_clamp_s 180#elif defined(_RIM_LIGHTING3_SAMPLER_BILINEAR_REPEAT) 181#define GET_SAMPLER_RL3 bilinear_repeat_s 182#elif defined(_RIM_LIGHTING3_SAMPLER_BILINEAR_CLAMP) 183#define GET_SAMPLER_RL3 bilinear_clamp_s 184#else 185#define GET_SAMPLER_RL3 linear_clamp_s 186#endif 187 188#endif // __TEXTURE_MACROS_INC 189