summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x3ner.shader22
-rwxr-xr-xfeatures.cginc5
-rwxr-xr-xglobals.cginc12
-rwxr-xr-xlighting.cginc32
4 files changed, 67 insertions, 4 deletions
diff --git a/3ner.shader b/3ner.shader
index 6735229..f38b614 100755
--- a/3ner.shader
+++ b/3ner.shader
@@ -103,6 +103,28 @@ Shader "yum_food/3ner"
[HideInInspector] m_end_Outlines("Outlines", Float) = 0
//endex
+ //ifex _Shadows_Enabled==0
+ [HideInInspector] m_start_Shadows("Shadows", Float) = 0
+ [ThryToggle(_SHADOWS)] _Shadows_Enabled("Enable", Float) = 0
+
+ [HideInInspector] m_start_Shadow_0("Shadow 0", Float) = 0
+ _Shadow_0_Color("Color 0", Color) = (0, 0, 0, 0)
+ _Shadow_0_Threshold("Threshold 0", Range(0, 1)) = 0.5
+ _Shadow_0_Blur("Blur 0", Range(0, 1)) = 0.1
+ [HideInInspector] m_end_Shadow_0("Shadow 0", Float) = 0
+
+ //ifex _Shadow_1_Enabled==0
+ [HideInInspector] m_start_Shadow_1("Shadow 1", Float) = 0
+ [ThryToggle(_SHADOW_1)] _Shadow_1_Enabled("Enable", Float) = 0
+ _Shadow_1_Color("Color 1", Color) = (0, 0, 0, 0)
+ _Shadow_1_Threshold("Threshold 1", Range(0, 1)) = 0.5
+ _Shadow_1_Blur("Blur 1", Range(0, 1)) = 0.1
+ [HideInInspector] m_end_Shadow_1("Shadow 1", Float) = 0
+ //endex
+
+ [HideInInspector] m_end_Shadows("Shadows", Float) = 0
+ //endex
+
[HideInInspector] m_end_Main("Main", Float) = 0
[HideInInspector] m_start_Gimmicks("Gimmicks", Float) = 0
diff --git a/features.cginc b/features.cginc
index 4ad5c88..53ed832 100755
--- a/features.cginc
+++ b/features.cginc
@@ -31,6 +31,11 @@
#pragma shader_feature_local _OUTLINES
//endex
+//ifex _Shadows_Enabled==0
+#pragma shader_feature_local _SHADOWS
+#pragma shader_feature_local _SHADOW_1
+//endex
+
//ifex _Bent_Normals_Enabled==0
#pragma shader_feature_local _BENT_NORMALS
//endex
diff --git a/globals.cginc b/globals.cginc
index 3dcb0ea..600ecce 100755
--- a/globals.cginc
+++ b/globals.cginc
@@ -38,6 +38,18 @@ float _Outlines_Width;
texture2D _Outlines_Thickness;
#endif // _OUTLINES
+#if defined(_SHADOWS)
+float4 _Shadow_0_Color;
+float _Shadow_0_Threshold;
+float _Shadow_0_Blur;
+
+#if defined(_SHADOW_1)
+float4 _Shadow_1_Color;
+float _Shadow_1_Threshold;
+float _Shadow_1_Blur;
+#endif // _SHADOW_1
+#endif // _SHADOWS
+
#if defined(_BRIGHTNESS_CLAMP)
float _Brightness_Clamp_Min;
float _Brightness_Clamp_Max;
diff --git a/lighting.cginc b/lighting.cginc
index 51b0c8f..04cff3c 100755
--- a/lighting.cginc
+++ b/lighting.cginc
@@ -183,14 +183,14 @@ float3 yumSH9(float4 n, float3 worldPos, inout LightIndirect light) {
return L0 + L1 + L2;
}
-float4 getIndirectDiffuse(v2f i, Pbr pbr, inout LightIndirect light) {
+float4 getIndirectDiffuse(v2f i, Pbr pbr, inout LightData light) {
float4 diffuse = 0;
#if defined(FORWARD_BASE_PASS) || defined(OUTLINES_PASS)
#if defined(_BENT_NORMALS)
- diffuse.xyz += max(0, yumSH9(float4(pbr.bent_normal, 1.0), i.worldPos, light));
+ diffuse.xyz += max(0, yumSH9(float4(pbr.bent_normal, 1.0), i.worldPos, light.indirect));
#else
- diffuse.xyz += max(0, yumSH9(float4(i.normal, 1.0), i.worldPos, light));
+ diffuse.xyz += max(0, yumSH9(float4(i.normal, 1.0), i.worldPos, light.indirect));
#endif
#endif
@@ -200,6 +200,30 @@ float4 getIndirectDiffuse(v2f i, Pbr pbr, inout LightIndirect light) {
diffuse.xyz = HSVtoRGB(diffuse_hsv);
#endif
+#if defined(_SHADOWS)
+ //diffuse.xyz = lerp(diffuse.xyz, _Shadow_0_Color.rgb, _Shadow_0_Threshold);
+ float3x3 mat = float3x3(
+ light.indirect.L01r,
+ light.indirect.L01g,
+ light.indirect.L01b
+ );
+ float3 dom_dir = normalize(mul(mat, diffuse.xyz));
+ float light_amount = dot(dom_dir, pbr.normal);
+ float3 shadow_color = lerp(
+ _Shadow_0_Color.rgb,
+ 1,
+ smoothstep(_Shadow_0_Threshold - _Shadow_0_Blur, _Shadow_0_Threshold + _Shadow_0_Blur, light_amount));
+
+#if defined(_SHADOW_1)
+ shadow_color = lerp(
+ _Shadow_1_Color.rgb,
+ shadow_color,
+ smoothstep(_Shadow_1_Threshold - _Shadow_1_Blur, _Shadow_1_Threshold + _Shadow_1_Blur, light_amount));
+#endif // _SHADOW_1
+
+ diffuse.xyz *= shadow_color;
+#endif
+
#if defined(_AMBIENT_OCCLUSION)
diffuse.xyz *= pbr.ao;
#endif
@@ -291,7 +315,7 @@ void GetLighting(v2f i, Pbr pbr, out LightData data) {
data.indirect.LoV = saturate(indirect_LoV);
data.indirect.double_LoV = saturate(2.0f * indirect_LoV * indirect_LoV - 1.0f);
- data.indirect.diffuse = getIndirectDiffuse(i, pbr, data.indirect);
+ data.indirect.diffuse = getIndirectDiffuse(i, pbr, data);
data.indirect.specular = getIndirectSpecular(i, pbr.roughness_perceptual, view_dir, -data.indirect.dir);
data.common.spec_ao = getSpecularAO(i, pbr, data, reflect_dir);