yum/3ner
A toon shader for Unity's BIRP.
git clone https://git.yummers.dev/yum/3ner
3e074f9
master
1#ifndef __TRIPLANAR_INC 2#define __TRIPLANAR_INC 3 4#include "burley.cginc" 5#include "globals.cginc" 6#include "math.cginc" 7 8#if defined(TRIPLANAR) 9void sample_triplanar(texture2D tex, float3 uv, out float4 s0, out float4 s1, out float4 s2) { 10 s0 = tex.Sample(aniso4_trilinear_repeat_s, uv.yz); 11 s1 = tex.Sample(aniso4_trilinear_repeat_s, uv.xz); 12 s2 = tex.Sample(aniso4_trilinear_repeat_s, uv.xy); 13} 14 15float3 triplanar_weights(float3 worldNormal, float3 uv) { 16 float3 weights = abs(worldNormal); 17 return weights / (weights.x + weights.y + weights.z); 18} 19#endif 20 21void apply_triplanar_layers(float3 worldPos, float3 normal_world, inout Pbr pbr, inout float3 normal_tangent) { 22#if defined(TRIPLANAR) 23 float3 weights = triplanar_weights(normal_world, worldPos); 24#if defined(_TRIPLANAR_LAYER0) 25 { 26 float3 uv = worldPos * _Triplanar_Layer0_Scale; 27 float4 a0, a1, a2; 28 sample_triplanar(_Triplanar_Layer0_MainTex, uv, a0, a1, a2); 29 float3 albedo = a0 * weights.x + a1 * weights.y + a2 * weights.z; 30#if defined(_TRIPLANAR_LAYER0_BURLEY) 31 float3 burley_weights = burley_apply_blend_gamma(weights, _Triplanar_Layer0_Burley_Blend_Gamma); 32 albedo = burley_degaussianize( 33 _Triplanar_Layer0_MainTex_Burley_LUT, 34 burley_apply_soft_clipping(albedo, burley_weights), 35 true); 36#endif // _TRIPLANAR_LAYER0_BURLEY 37 pbr.albedo.rgb = albedo; 38 } 39#endif // _TRIPLANAR_LAYER0 40#endif // TRIPLANAR 41} 42 43#endif // __TRIPLANAR_INC