summaryrefslogtreecommitdiffstats
path: root/pbr.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'pbr.cginc')
-rw-r--r--pbr.cginc10
1 files changed, 7 insertions, 3 deletions
diff --git a/pbr.cginc b/pbr.cginc
index a699a53..1ceef09 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -127,8 +127,12 @@ float4 getLitColor(
float3 view_dir = normalize(_WorldSpaceCameraPos - worldPos);
bool flat = round(_Flatten_Mesh_Normals) == 1.0;
+ float3 flat_normal = normalize(
+ (1.0 / _Flatten_Mesh_Normals_Str) * normal +
+ _Flatten_Mesh_Normals_Str * view_dir);
+
UnityIndirect indirect_light = CreateIndirectLight(vertexLightColor,
- view_dir, flat ? view_dir : normal, smoothness, worldPos, uv);
+ view_dir, flat ? flat_normal : normal, smoothness, worldPos, uv);
UnityLight direct_light = CreateDirectLight(normal, i);
if (flat) {
@@ -148,7 +152,7 @@ float4 getLitColor(
one_minus_reflectivity,
smoothness,
view_dir,
- flat ? view_dir : normal,
+ flat ? flat_normal : normal,
direct_light,
indirect_light).xyz;
} else {
@@ -157,7 +161,7 @@ float4 getLitColor(
specular_tint,
one_minus_reflectivity,
smoothness,
- flat ? view_dir : normal,
+ flat ? flat_normal : normal,
view_dir,
direct_light,
indirect_light).xyz;