From 6686b328c7a4aed70c2a1595eb10a0df9fec75db Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 16 Jan 2018 10:47:46 +0100 Subject: [PATCH] Fixed error in Specular shader which gave low key specular highlights --- libraries/render-utils/src/LightingModel.slh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/LightingModel.slh b/libraries/render-utils/src/LightingModel.slh index d96c565b81..7d08fdabaf 100644 --- a/libraries/render-utils/src/LightingModel.slh +++ b/libraries/render-utils/src/LightingModel.slh @@ -133,7 +133,7 @@ SurfaceData initSurfaceData(float roughness, vec3 normal, vec3 eyeDir) { SurfaceData surface; surface.eyeDir = eyeDir; surface.normal = normal; - surface.roughness = mix(0.001, 1.0, roughness); + surface.roughness = mix(0.01, 1.0, roughness); surface.roughness2 = surface.roughness * surface.roughness; surface.roughness4 = surface.roughness2 * surface.roughness2; surface.ndotv = clamp(dot(normal, eyeDir), 0.0, 1.0); @@ -181,7 +181,7 @@ float fresnelSchlickScalar(float fresnelScalar, SurfaceData surface) { float specularDistribution(SurfaceData surface) { // See https://www.khronos.org/assets/uploads/developers/library/2017-web3d/glTF-2.0-Launch_Jun17.pdf // for details of equations, especially page 20 - float denom = (surface.ndoth*surface.ndoth * (surface.roughness2 - 1.0) + 1.0); + float denom = (surface.ndoth*surface.ndoth * (surface.roughness4 - 1.0) + 1.0); denom *= denom; // Add geometric factors G1(n,l) and G1(n,v) float smithInvG1NdotL = evalSmithInvG1(surface.roughness4, surface.ndotl);