diff options
| author | yum <yum.food.vr@gmail.com> | 2024-05-11 14:35:59 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-05-11 14:35:59 -0700 |
| commit | 47d32c9b5a4c809b10b3c198089cd4992281fa36 (patch) | |
| tree | 45dffa4353c2ac95f654b4d325c84f28cc6aa1bf /pbr.cginc | |
| parent | 6eed98ff4e57326ebf7a41f0c180635a7bcac626 (diff) | |
Make flat normals adjustable
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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; |
