summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-04-09 22:17:29 -0700
committeryum <yum.food.vr@gmail.com>2023-04-09 22:17:29 -0700
commit7d69c268cb20d8264b903cfaebb3b84564e56eed (patch)
tree5340c130a36fee417866ab603690e762357716e3
parent40f81f1dcd4a3055244c17b08f707a04b30c82a4 (diff)
Fix cubemap glare on rough materials
Switch to unlit shading when roughness == 1.0.
-rw-r--r--Shaders/parallax/parallax_lighting.cginc13
1 files changed, 10 insertions, 3 deletions
diff --git a/Shaders/parallax/parallax_lighting.cginc b/Shaders/parallax/parallax_lighting.cginc
index 2d7386f..a3a7eb1 100644
--- a/Shaders/parallax/parallax_lighting.cginc
+++ b/Shaders/parallax/parallax_lighting.cginc
@@ -302,8 +302,16 @@ float4 effect(inout v2f i, out float depth)
const float metallic = getLayerMetallic(uv, (int) layer);
const float smoothness = 1.0 - getLayerRoughness(uv, (int) layer);
- bool custom_cubemap = (layer == 1);
- float4 lit_color = getLitColor(i, color, pp, normal, metallic, smoothness, custom_cubemap);
+ bool custom_cubemap = true;
+ float4 lit_color;
+
+ // Hack: Bright cubemaps cause glare on rough surfaces. To prevent this,
+ // switch to unlit shading when shading a perfectly rough material.
+ if (smoothness == 0.0) {
+ lit_color = color;
+ } else {
+ lit_color = getLitColor(i, color, pp, normal, metallic, smoothness, custom_cubemap);
+ }
lit_color.rgb += color.rgb * getLayerEmission(layer);
@@ -315,7 +323,6 @@ float4 effect(inout v2f i, out float depth)
}
}
-
// No ray hit: return default material
float base_depth = depth;
float metallic = 1.0;