Преглед изворни кода

Optimized Fresnel (see Epic talk at SIGGRAPH '13).

tschw пре 10 година
родитељ
комит
72e3b59ec3
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7 1
      src/renderers/shaders/ShaderChunk/common.glsl

+ 7 - 1
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;
 
 }