summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--2ner.shader30
-rw-r--r--features.cginc6
-rw-r--r--globals.cginc15
-rw-r--r--matcaps.cginc24
4 files changed, 70 insertions, 5 deletions
diff --git a/2ner.shader b/2ner.shader
index 8bf7934..48846f6 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -104,8 +104,8 @@ Shader "yum_food/2ner"
[HideInInspector] m_end_Outlines("Outlines", Float) = 0
//endex
- //ifex _Matcap0_Enabled==0
[HideInInspector] m_start_Matcaps("Matcaps", Float) = 0
+ //ifex _Matcap0_Enabled==0
[HideInInspector] m_start_Matcap0("Matcap 0", Float) = 0
[ThryToggle(_MATCAP0)]_Matcap0_Enabled("Enable", Float) = 0
_Matcap0("Matcap", 2D) = "white" {}
@@ -127,9 +127,33 @@ Shader "yum_food/2ner"
_Matcap0_Quantization_Steps("Steps", Float) = 1
[HideInInspector] m_end_Matcap0_Quantization("Quantization", Float) = 0
//endex
- [HideInInspector] m_end_Matcap0("Matcaps", Float) = 0
+ [HideInInspector] m_end_Matcap0("Matcap 0", Float) = 0
+ //endex
+ //ifex _Matcap1_Enabled==0
+ [HideInInspector] m_start_Matcap1("Matcap 1", Float) = 0
+ [ThryToggle(_MATCAP1)]_Matcap1_Enabled("Enable", Float) = 0
+ _Matcap1("Matcap", 2D) = "white" {}
+ [Toggle(_)]_Matcap1_Invert("Invert", Float) = 0
+ [ThryWideEnum(Replace, 0, Add, 1, Multiply, 2, Subtract, 3, AddProduct, 4)]
+ _Matcap1_Mode("Mode", Int) = 0
+ [ThryWideEnum(_0000b, 0, _0001b, 1, _0010b, 2, _0011b, 3, _0100b, 4, _0101b, 5, _0110b, 6, _0111b, 7, _1000b, 8, _1001b, 9, _1010b, 10, _1011b, 11, _1100b, 12, _1101b, 13, _1110b, 14, _1111b, 15)]
+ _Matcap1_Target_Mask("Target mask (albedo|diffuse<<1|specular<<2)", Int) = 1
+ _Matcap1_Strength("Strength", Float) = 1
+ //ifex _Matcap1_Mask_Enabled==0
+ [HideInInspector] m_start_Matcap1_Mask("Mask", Float) = 0
+ [ThryToggle(_MATCAP1_MASK)]_Matcap1_Mask_Enabled("Enable", Float) = 0
+ _Matcap1_Mask("Mask", 2D) = "white" {}
+ [HideInInspector] m_end_Matcap1_Mask("Mask", Float) = 0
+ //endex
+ //ifex _Matcap1_Quantization_Enabled==0
+ [HideInInspector] m_start_Matcap1_Quantization("Quantization", Float) = 0
+ [ThryToggle(_MATCAP1_QUANTIZATION)]_Matcap1_Quantization_Enabled("Enable", Float) = 0
+ _Matcap1_Quantization_Steps("Steps", Float) = 1
+ [HideInInspector] m_end_Matcap1_Quantization("Quantization", Float) = 0
+ //endex
+ [HideInInspector] m_end_Matcap1("Matcap 1", Float) = 0
+ //endex
[HideInInspector] m_end_Matcaps("Matcaps", Float) = 0
- //endex
[HideInInspector] m_start_Rim_Lighting("Rim lighting", Float) = 0
//ifex _Rim_Lighting0_Enabled==0
diff --git a/features.cginc b/features.cginc
index 64c0480..9e444ab 100644
--- a/features.cginc
+++ b/features.cginc
@@ -58,6 +58,12 @@
#pragma shader_feature_local _MATCAP0_QUANTIZATION
//endex
+//ifex _Matcap1_Enabled==0
+#pragma shader_feature_local _MATCAP1
+#pragma shader_feature_local _MATCAP1_MASK
+#pragma shader_feature_local _MATCAP1_QUANTIZATION
+//endex
+
//ifex _Rim_Lighting0_Enabled==0
#pragma shader_feature_local _RIM_LIGHTING0
#pragma shader_feature_local _RIM_LIGHTING0_MASK
diff --git a/globals.cginc b/globals.cginc
index c5fa966..67fb1a5 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -121,6 +121,21 @@ float _Matcap0_Quantization_Steps;
#endif
#endif
+#if defined(_MATCAP1)
+texture2D _Matcap1;
+uint _Matcap1_Mode;
+uint _Matcap1_Target_Mask;
+float _Matcap1_Invert;
+float _Matcap1_Strength;
+#if defined(_MATCAP1_MASK)
+texture2D _Matcap1_Mask;
+float4 _Matcap1_Mask_ST;
+#endif
+#if defined(_MATCAP1_QUANTIZATION)
+float _Matcap1_Quantization_Steps;
+#endif
+#endif
+
#if defined(_RIM_LIGHTING0)
uint _Rim_Lighting0_Mode;
float _Rim_Lighting0_Center;
diff --git a/matcaps.cginc b/matcaps.cginc
index 8cc983b..00a4ea6 100644
--- a/matcaps.cginc
+++ b/matcaps.cginc
@@ -7,7 +7,7 @@
#include "yum_lighting.cginc"
#include "yum_pbr.cginc"
-#if defined(_MATCAP0) || defined(_RIM_LIGHTING0) || defined(_RIM_LIGHTING1) || defined(_RIM_LIGHTING2) || defined(_RIM_LIGHTING3)
+#if defined(_MATCAP0) || defined(_MATCAP1) || defined(_RIM_LIGHTING0) || defined(_RIM_LIGHTING1) || defined(_RIM_LIGHTING2) || defined(_RIM_LIGHTING3)
float2 getMatcapUV(v2f i, inout YumPbr 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)));
@@ -69,7 +69,7 @@ float getAngleAttenuation(float2 muv, float2 target_vector, float power) {
}
void applyMatcapsAndRimLighting(v2f i, inout YumPbr pbr, inout YumLighting l) {
-#if defined(_MATCAP0) || defined(_RIM_LIGHTING0) || defined(_RIM_LIGHTING1)
+#if defined(_MATCAP0) || defined(_MATCAP1) || defined(_RIM_LIGHTING0) || defined(_RIM_LIGHTING1) || defined(_RIM_LIGHTING2) || defined(_RIM_LIGHTING3)
float2 muv = getMatcapUV(i, pbr);
#endif
#if defined(_MATCAP0)
@@ -92,6 +92,26 @@ void applyMatcapsAndRimLighting(v2f i, inout YumPbr pbr, inout YumLighting l) {
#endif
applyMatcap(pbr, l, m0, _Matcap0_Mode, _Matcap0_Target_Mask, m0_mask);
#endif // _MATCAP0
+#if defined(_MATCAP1)
+#if defined(_MATCAP1_QUANTIZATION)
+ float2 m1uv = muv * 2 - 1;
+ float m1uv_r = length(m1uv);
+ float m1uv_r_q = floor(m1uv_r * _Matcap1_Quantization_Steps) / _Matcap1_Quantization_Steps;
+ m1uv = m1uv_r_q * (m1uv / max(1E-4, m1uv_r));
+ m1uv = m1uv * 0.5 + 0.5;
+#else
+ float2 m1uv = muv;
+#endif // _MATCAP1_QUANTIZATION
+ float3 m1 = _Matcap1.Sample(linear_repeat_s, m1uv);
+ m1 = lerp(m1, 1 - m1, _Matcap1_Invert);
+ 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, l, m1, _Matcap1_Mode, _Matcap1_Target_Mask, m1_mask);
+#endif // _MATCAP1
#if defined(_RIM_LIGHTING0) || defined(_RIM_LIGHTING1) || defined(_RIM_LIGHTING2) || defined(_RIM_LIGHTING3)
float rl_radius = length(muv - 0.5);