From 72e3b59ec3ec0dd707b50a4dbbeb88143da0e5e0 Mon Sep 17 00:00:00 2001 From: tschw Date: Fri, 21 Aug 2015 15:30:37 +0200 Subject: [PATCH] Optimized Fresnel (see Epic talk at SIGGRAPH '13). --- src/renderers/shaders/ShaderChunk/common.glsl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderers/shaders/ShaderChunk/common.glsl b/src/renderers/shaders/ShaderChunk/common.glsl index 11cb750413..c7f7d3c0e3 100644 --- a/src/renderers/shaders/ShaderChunk/common.glsl +++ b/src/renderers/shaders/ShaderChunk/common.glsl @@ -54,7 +54,13 @@ float calcLightAttenuation( float lightDistance, float cutoffDistance, float dec vec3 F_Schlick( in vec3 specularColor, in float dotLH ) { - return ( 1.0 - specularColor ) * pow( 1.0 - dotLH, 5.0 ) + specularColor; + // Original approximation by Christophe Schlick '94 + //;float fresnel = pow( 1.0 - dotLH, 5.0 ); + + // Optimized variant (presented by Epic at SIGGRAPH '13) + float fresnel = exp2( ( -5.55437 * dotLH - 6.98316 ) * dotLH ); + + return ( 1.0 - specularColor ) * fresnel + specularColor; } -- GitLab