From 5460dbc62fe6f404cb244410af949864cce286f5 Mon Sep 17 00:00:00 2001 From: yum Date: Wed, 25 Feb 2026 19:19:55 -0800 Subject: Add second matcap slot --- matcap.cginc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'matcap.cginc') diff --git a/matcap.cginc b/matcap.cginc index 55eff5a..d9391af 100644 --- a/matcap.cginc +++ b/matcap.cginc @@ -6,7 +6,7 @@ #include "pbr.cginc" #include "texture_utils.cginc" -#if defined(_MATCAP0) || defined(_RIM_LIGHTING0) +#if defined(_MATCAP0) || defined(_MATCAP1) || defined(_RIM_LIGHTING0) float2 getMatcapUV(v2f i, Pbr pbr) { const float3 cam_normal = normalize(mul(UNITY_MATRIX_V, float4(pbr.normal, 0))); const float3 cam_view_dir = normalize(mul(UNITY_MATRIX_V, float4(-i.eyeVec.xyz, 0))); @@ -55,7 +55,7 @@ float2 quantizeMatcapUV(float2 muv, float muv_r, float steps) { #endif // _MATCAP0 || _RIM_LIGHTING0 void applyMatcapsAndRimLighting(v2f i, inout Pbr pbr, inout LightData light_data) { -#if defined(_MATCAP0) || defined(_RIM_LIGHTING0) +#if defined(_MATCAP0) || defined(_MATCAP1) || defined(_RIM_LIGHTING0) float2 muv = getMatcapUV(i, pbr); float2 muv_centered = muv * 2 - 1; float muv_r = length(muv_centered); @@ -78,6 +78,23 @@ void applyMatcapsAndRimLighting(v2f i, inout Pbr pbr, inout LightData light_data applyMatcap(pbr, m0, _Matcap0_Mode, m0_mask); #endif // _MATCAP0 +#if defined(_MATCAP1) +#if defined(_MATCAP1_QUANTIZATION) + float2 m1uv = quantizeMatcapUV(muv, muv_r, _Matcap1_Quantization_Steps); +#else + float2 m1uv = muv; +#endif + float3 m1 = _Matcap1.Sample(linear_repeat_s, m1uv); + m1 = _Matcap1_Invert ? 1 - m1 : m1; + m1 *= _Matcap1_Strength; +#if defined(_MATCAP1_MASK) + float m1_mask = _Matcap1_Mask.Sample(linear_repeat_s, UV_SCOFF(i, _Matcap1_Mask_ST, /*which_channel=*/0)); +#else + float m1_mask = 1; +#endif + applyMatcap(pbr, m1, _Matcap1_Mode, m1_mask); +#endif // _MATCAP1 + #if defined(_RIM_LIGHTING0) // 1 at rim center, 0 outside blur radius. float rl0_inner = smoothstep( -- cgit v1.2.3