summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x3ner.shader14
-rwxr-xr-xbrdf.cginc8
-rwxr-xr-xfeatures.cginc2
-rwxr-xr-xglobals.cginc9
-rwxr-xr-xlighting.cginc7
5 files changed, 39 insertions, 1 deletions
diff --git a/3ner.shader b/3ner.shader
index 8558abf..1c3b51a 100755
--- a/3ner.shader
+++ b/3ner.shader
@@ -704,6 +704,20 @@ Shader "yum_food/3ner"
[IntRange] _Glitter_Angular_Cells("Angular Cells", Range(1, 4)) = 4
_Glitter_Filter_Size("Filter Size", Range(0.1, 2.0)) = 0.7
_Glitter_Tint("Tint", Color) = (1, 1, 1, 1)
+
+ //ifex _Glitter_Mask_Enabled==0
+ [HideInInspector] m_start_Glitter_Mask("Mask", Float) = 0
+ [ThryToggle(_GLITTER_MASK)] _Glitter_Mask_Enabled("Enable", Float) = 0
+ _Glitter_Mask("Mask", 2D) = "white" {}
+ [HideInInspector] m_end_Glitter_Mask("Mask", Float) = 0
+ //endex
+
+ //ifex _Glitter_Base_Roughness_Override_Enabled==0
+ [HideInInspector] m_start_Glitter_Base_Roughness_Override("Base Roughness Override", Float) = 0
+ [ThryToggle(_GLITTER_BASE_ROUGHNESS_OVERRIDE)] _Glitter_Base_Roughness_Override_Enabled("Enable", Float) = 0
+ _Glitter_Base_Roughness_Override("Base Roughness Override", Range(0, 1)) = 0.5
+ [HideInInspector] m_end_Glitter_Base_Roughness_Override("Base Roughness Override", Float) = 0
+ //endex
[HideInInspector] m_end_Glitter("Glitter", Float) = 0
//endex
diff --git a/brdf.cginc b/brdf.cginc
index 219a04b..65a25c9 100755
--- a/brdf.cginc
+++ b/brdf.cginc
@@ -188,6 +188,10 @@ float4 brdf(v2f i, Pbr pbr, LightData data, out BrdfData bd) {
* _Glitter_Tint;
// No spec ao for glitter, please.
direct_specular_glitter *= remainder;
+#if defined(_GLITTER_MASK)
+ float glitter_mask = _Glitter_Mask.Sample(bilinear_clamp_s, i.uv01.xy).r;
+ direct_specular_glitter *= glitter_mask;
+#endif
specular += direct_specular_glitter;
#endif
@@ -239,6 +243,10 @@ float4 brdf(v2f i, Pbr pbr, LightData data, out BrdfData bd) {
* indirect_f_glitter * max(0, data.indirect.L00) * data.glitter.indirect_NoL
* _Glitter_Tint;
// No spec ao for glitter, please.
+#if defined(_GLITTER_MASK)
+ float glitter_mask = _Glitter_Mask.Sample(bilinear_clamp_s, i.uv01.xy).r;
+ indirect_specular_glitter *= glitter_mask;
+#endif
specular += indirect_specular_glitter * remainder;
remainder *= saturate(1 - indirect_specular_glitter * remainder);
#endif
diff --git a/features.cginc b/features.cginc
index 99e5593..47ee80f 100755
--- a/features.cginc
+++ b/features.cginc
@@ -69,6 +69,8 @@
//ifex _Glitter_Enabled==0
#pragma shader_feature_local _GLITTER
+#pragma shader_feature_local _GLITTER_MASK
+#pragma shader_feature_local _GLITTER_BASE_ROUGHNESS_OVERRIDE
//endex
//ifex _Vertex_Deformation_Enabled==0
diff --git a/globals.cginc b/globals.cginc
index b7d13dd..6974ee0 100755
--- a/globals.cginc
+++ b/globals.cginc
@@ -160,6 +160,15 @@ float _Glitter_Filter_Size;
float3 _Glitter_Tint;
#endif // _GLITTER
+#if defined(_GLITTER_MASK)
+texture2D _Glitter_Mask;
+float4 _Glitter_Mask_ST;
+#endif // _GLITTER_MASK
+
+#if defined(_GLITTER_BASE_ROUGHNESS_OVERRIDE)
+float _Glitter_Base_Roughness_Override;
+#endif // _GLITTER_BASE_ROUGHNESS_OVERRIDE
+
#if defined(_UV_SCROLL)
float2 _UV_Scroll_Speed;
#endif // _UV_SCROLL
diff --git a/lighting.cginc b/lighting.cginc
index 825671b..6653bba 100755
--- a/lighting.cginc
+++ b/lighting.cginc
@@ -280,9 +280,14 @@ void GetLighting(v2f i, Pbr pbr, out LightData data) {
data.indirect.L01g,
data.indirect.L01b,
data.indirect.dir);
+#if defined(_GLITTER_BASE_ROUGHNESS_OVERRIDE)
+ float glitter_roughness = _Glitter_Base_Roughness_Override;
+#else
+ float glitter_roughness = pbr.roughness;
+#endif
data.glitter = GetGlitterLighting(
_Glitter_Amount, _Glitter_Roughness, _Glitter_Angular_Cells,
- _Glitter_Filter_Size, i.uv01.xy, pbr.tbn, pbr.roughness, pbr.normal,
+ _Glitter_Filter_Size, i.uv01.xy, pbr.tbn, glitter_roughness, pbr.normal,
data.common.V, data.direct.H, glitter_indirect_dir);
#endif