summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--2ner.shader6
-rw-r--r--features.cginc8
-rw-r--r--filamented.cginc7
-rw-r--r--globals.cginc8
-rw-r--r--yum_lighting.cginc9
5 files changed, 37 insertions, 1 deletions
diff --git a/2ner.shader b/2ner.shader
index 323d7cd..b3dd563 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -255,6 +255,12 @@ Shader "yum_food/2ner"
_Quantize_NoL_Steps("Steps", Float) = 1
[HideInInspector] m_end_Quantize_NoL("Quantize NoL", Float) = 0
//endex
+ //ifex _Quantize_Specular_Enabled==0
+ [HideInInspector] m_start_Quantize_Specular("Quantize Specular", Float) = 0
+ [ThryToggle(_QUANTIZE_SPECULAR)] _Quantize_Specular_Enabled("Enable", Float) = 0
+ _Quantize_Specular_Steps("Steps", Float) = 1
+ [HideInInspector] m_end_Quantize_Specular("Quantize Specular", Float) = 0
+ //endex
[HideInInspector] m_renderingOptions("Rendering Options", Float) = 0
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2
diff --git a/features.cginc b/features.cginc
index 48f836d..3f720ec 100644
--- a/features.cginc
+++ b/features.cginc
@@ -17,6 +17,14 @@
#pragma shader_feature_local _QUANTIZE_NOL
//endex
+//ifex _Quantize_Specular_Enabled==0
+#pragma shader_feature_local _QUANTIZE_SPECULAR
+//endex
+
+//ifex _Quantize_Diffuse_Enabled==0
+#pragma shader_feature_local _QUANTIZE_DIFFUSE
+//endex
+
//ifex _Outlines_Enabled==0
#pragma shader_feature_local _OUTLINES
//endex
diff --git a/filamented.cginc b/filamented.cginc
index 9edfca5..9895361 100644
--- a/filamented.cginc
+++ b/filamented.cginc
@@ -343,7 +343,12 @@ half3 Unity_GlossyEnvironment_local (UNITY_ARGS_TEXCUBE(tex), half4 hdr, Unity_G
half3 R = glossIn.reflUVW;
half4 rgbm = UNITY_SAMPLE_TEXCUBE_LOD(tex, R, mip);
- return DecodeHDR(rgbm, hdr);
+ half3 color = DecodeHDR(rgbm, hdr);
+#if defined(_QUANTIZE_SPECULAR)
+ float luminance = dot(color, float3(0.2126, 0.7152, 0.0722)); // convert to luminance
+ color = color * floor(luminance * _Quantize_Specular_Steps) / _Quantize_Specular_Steps;
+#endif
+ return color;
}
inline half3 UnityGI_prefilteredRadiance(const UnityGIInput data,
diff --git a/globals.cginc b/globals.cginc
index b0cce77..0deee5e 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -35,6 +35,14 @@ float _Min_Brightness;
float _Quantize_NoL_Steps;
#endif
+#if defined(_QUANTIZE_SPECULAR)
+float _Quantize_Specular_Steps;
+#endif
+
+#if defined(_QUANTIZE_DIFFUSE)
+float _Quantize_Diffuse_Steps;
+#endif
+
float _Clip;
int _Mode;
float _Smoothness;
diff --git a/yum_lighting.cginc b/yum_lighting.cginc
index 604133f..a7cb4ab 100644
--- a/yum_lighting.cginc
+++ b/yum_lighting.cginc
@@ -132,6 +132,15 @@ YumLighting GetYumLighting(v2f i, YumPbr pbr) {
light.specular = getIndirectSpecular(i, pbr, light.view_dir);
+#if defined(_QUANTIZE_SPECULAR)
+ float specular_luminance = dot(light.specular, float3(0.2126, 0.7152, 0.0722)); // convert to luminance
+ light.specular = light.specular * floor(specular_luminance * _Quantize_Specular_Steps) / _Quantize_Specular_Steps;
+#endif
+#if defined(_QUANTIZE_DIFFUSE)
+ float diffuse_luminance = dot(light.diffuse, float3(0.2126, 0.7152, 0.0722)); // convert to luminance
+ light.diffuse = light.diffuse * floor(diffuse_luminance * _Quantize_Diffuse_Steps) / _Quantize_Diffuse_Steps;
+#endif
+
light.NoL = saturate(dot(pbr.normal, light.dir));
#if defined(_QUANTIZE_NOL)
light.NoL = floor(light.NoL * _Quantize_NoL_Steps) / _Quantize_NoL_Steps;