From 39574e7fee7c37ea51c12d11c58c0b909ceeef46 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Fri, 13 Nov 2020 15:24:12 -0600 Subject: [PATCH] clamp factor entriely for getXXXLight calcs, and take metalness into account for reducing direct light diffusion imact (while this seems to make it match the tooling, I can't say I've seen this exact approach used, so might want to re-review the methodology) --- .../BaseGame/game/core/rendering/shaders/gl/lighting.glsl | 4 ++-- Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 01de17b3e..3a5453fbf 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -229,14 +229,14 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) vec3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float shadow) { - vec3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity; + vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity*(1.0-surface.metalness), 0.0f); return evaluateStandardBRDF(surface,surfaceToLight) * factor; } vec3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float radius, float shadow) { float attenuation = getDistanceAtt(surfaceToLight.Lu, radius); - vec3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity * attenuation; + vec3 factor = lightColor * max(surfaceToLight.NdotL * shadow * lightIntensity * attenuation*(1.0-surface.metalness), 0.0f); return evaluateStandardBRDF(surface,surfaceToLight) * factor; } diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 617aa7a3b..2b9443a5a 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -230,14 +230,14 @@ float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) float3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float shadow) { - float3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity; + float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity*(1.0-surface.metalness), 0.0f) ; return evaluateStandardBRDF(surface,surfaceToLight) * factor; } float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float radius, float shadow) { float attenuation = getDistanceAtt(surfaceToLight.Lu, radius); - float3 factor = lightColor * max(surfaceToLight.NdotL, 0.0f) * shadow * lightIntensity * attenuation; + float3 factor = lightColor * max(surfaceToLight.NdotL* shadow * lightIntensity * attenuation*(1.0-surface.metalness), 0.0f) ; return evaluateStandardBRDF(surface,surfaceToLight) * factor; }