summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Editor/tooner.cs5
-rw-r--r--globals.cginc1
-rw-r--r--interpolators.cginc8
-rw-r--r--pbr.cginc16
-rw-r--r--tooner.shader9
-rw-r--r--tooner_lighting.cginc5
6 files changed, 33 insertions, 11 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs
index 189cfd0..4ad7fa7 100644
--- a/Editor/tooner.cs
+++ b/Editor/tooner.cs
@@ -1300,6 +1300,11 @@ public class ToonerGUI : ShaderGUI {
bc,
"Direct multiplier");
+ bc = FindProperty("_Vertex_Lighting_Factor");
+ editor.RangeProperty(
+ bc,
+ "Vertex light multiplier");
+
bc = FindProperty("_Indirect_Specular_Lighting_Factor");
editor.RangeProperty(
bc,
diff --git a/globals.cginc b/globals.cginc
index 6e6a01f..e14b1a7 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -14,6 +14,7 @@ float _NormalStr;
float _Lighting_Factor;
float _Direct_Lighting_Factor;
+float _Vertex_Lighting_Factor;
float _Indirect_Specular_Lighting_Factor;
float _Indirect_Diffuse_Lighting_Factor;
float _Reflection_Probe_Saturation;
diff --git a/interpolators.cginc b/interpolators.cginc
index 27db59c..e14831a 100644
--- a/interpolators.cginc
+++ b/interpolators.cginc
@@ -11,6 +11,8 @@ struct appdata
float3 normal : NORMAL;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
+
+ UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
@@ -26,6 +28,8 @@ struct v2f
#if defined(SSR_ENABLED)
float4 screenPos : TEXCOORD5;
#endif
+
+ UNITY_VERTEX_OUTPUT_STEREO
};
#else
@@ -37,6 +41,8 @@ struct appdata
float2 uv1 : TEXCOORD1;
float3 normal : NORMAL;
float4 tangent : TANGENT;
+
+ UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
@@ -58,6 +64,8 @@ struct v2f
#if defined(SSR_ENABLED)
float4 screenPos : TEXCOORD8;
#endif
+
+ UNITY_VERTEX_OUTPUT_STEREO
};
#endif
diff --git a/pbr.cginc b/pbr.cginc
index e16766d..b7ed27d 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -192,6 +192,7 @@ float4 getLitColor(
normal = lerp(normal, spherical_normal, normals_mode == 1);
UnityIndirect indirect_light;
+ vertexLightColor *= _Vertex_Lighting_Factor;
indirect_light.diffuse = getIndirectDiffuse(vertexLightColor, normal);
indirect_light.specular = getIndirectSpecular(view_dir, normal, smoothness,
worldPos, uv);
@@ -229,10 +230,6 @@ float4 getLitColor(
}
#endif
- direct_light.color *= _Lighting_Factor * _Direct_Lighting_Factor * enable_direct;
- indirect_light.specular *= _Lighting_Factor * _Indirect_Specular_Lighting_Factor;
- indirect_light.diffuse *= _Lighting_Factor * _Indirect_Diffuse_Lighting_Factor;
-
if (_Reflection_Probe_Saturation < 1.0) {
direct_light.color = RGBtoHSV(direct_light.color);
direct_light.color[1] *= _Reflection_Probe_Saturation;
@@ -249,6 +246,11 @@ float4 getLitColor(
indirect_light.diffuse = clamp(indirect_light.diffuse, _Min_Brightness, _Max_Brightness);
indirect_light.specular = clamp(indirect_light.specular, _Min_Brightness, _Max_Brightness);
+ // TODO move back before clamping
+ direct_light.color *= _Lighting_Factor * _Direct_Lighting_Factor * enable_direct;
+ indirect_light.specular *= _Lighting_Factor * _Indirect_Specular_Lighting_Factor;
+ indirect_light.diffuse *= _Lighting_Factor * _Indirect_Diffuse_Lighting_Factor;
+
// Apply AO
indirect_light.diffuse *= ao;
float3 direct_color = direct_light.color;
@@ -303,7 +305,7 @@ float4 getLitColor(
cc_LoH,
cc_H);
pbr.rgb += clearcoat * saturate(dot(i.normal, cc_L)) *
- cc_mask * direct_color * 10;
+ cc_mask * direct_color * _Direct_Lighting_Factor;
}
// Indirect specular lighting
#if 1
@@ -319,7 +321,7 @@ float4 getLitColor(
in_LoH,
in_H);
pbr.rgb += clearcoat * saturate(dot(i.normal, in_L)) *
- cc_mask * indirect_light.specular * 1;
+ cc_mask * indirect_light.specular * _Indirect_Specular_Lighting_Factor;
}
#endif
#if defined(VERTEXLIGHT_ON)
@@ -341,7 +343,7 @@ float4 getLitColor(
vlh,
vhalf);
pbr.rgb += clearcoat * saturate(dot(i.normal, vl)) *
- cc_mask * c * 10;
+ cc_mask * c * _Vertex_Lighting_Factor;
}
#endif
#endif
diff --git a/tooner.shader b/tooner.shader
index c4280f7..c58aedf 100644
--- a/tooner.shader
+++ b/tooner.shader
@@ -104,6 +104,7 @@ Shader "yum_food/tooner"
_Cubemap("Cubemap", Cube) = "" {}
_Lighting_Factor("Lighting factor", Range(0, 5)) = 1
_Direct_Lighting_Factor("Direct lighting factor", Range(0, 5)) = 1
+ _Vertex_Lighting_Factor("Vertex lighting factor", Range(0, 5)) = 1
_Indirect_Specular_Lighting_Factor("Indirect specular lighting factor", Range(0, 5)) = 1
_Indirect_Diffuse_Lighting_Factor("Indirect diffuse lighting factor", Range(0, 5)) = 1
_Reflection_Probe_Saturation("Reflection probe saturation", Range(0, 1)) = 1
@@ -345,7 +346,9 @@ Shader "yum_food/tooner"
CGPROGRAM
#pragma target 5.0
- #pragma multi_compile _ VERTEXLIGHT_ON SHADOWS_SCREEN
+ #pragma multi_compile_fwdbase
+ #pragma multi_compile_instancing
+ #pragma multi_compile _ VERTEXLIGHT_ON
#include "feature_macros.cginc"
@@ -376,7 +379,7 @@ Shader "yum_food/tooner"
#pragma target 5.0
#pragma multi_compile_fwdadd_fullshadows
- #pragma multi_compile DIRECTIONAL DIRECTIONAL_COOKIE POINT SPOT
+ #pragma multi_compile_instancing
#include "feature_macros.cginc"
#pragma vertex vert
@@ -403,6 +406,7 @@ Shader "yum_food/tooner"
CGPROGRAM
#pragma target 5.0
+ #pragma multi_compile_instancing
#include "feature_macros.cginc"
#pragma vertex vert
@@ -422,6 +426,7 @@ Shader "yum_food/tooner"
}
CGPROGRAM
#pragma target 5.0
+ #pragma multi_compile_instancing
#include "feature_macros.cginc"
#pragma vertex vert
diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc
index cdc6e34..4531931 100644
--- a/tooner_lighting.cginc
+++ b/tooner_lighting.cginc
@@ -219,10 +219,10 @@ tess_data hull_vertex(appdata v)
{
tess_data o;
- UNITY_INITIALIZE_OUTPUT(tess_data, o);
UNITY_SETUP_INSTANCE_ID(v);
- UNITY_TRANSFER_INSTANCE_ID(v, o);
+ UNITY_INITIALIZE_OUTPUT(tess_data, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+ UNITY_TRANSFER_INSTANCE_ID(v, o);
o.pos = v.vertex;
//o.vertex = UnityObjectToClipPos(v.vertex);
@@ -1340,6 +1340,7 @@ float4 effect(inout v2f i)
fixed4 frag(v2f i) : SV_Target
{
+ UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
return effect(i);
}