Browse Source

Refactoring only (#22373)

WestLangley 4 years ago
parent
commit
ccfb1c45b8

+ 0 - 50
src/renderers/shaders/ShaderChunk/bsdfs.glsl.js

@@ -98,56 +98,6 @@ vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 view
 
 
 	return F * ( V * D );
 	return F * ( V * D );
 
 
-} // validated
-
-// Analytical approximation of the DFG LUT, one half of the
-// split-sum approximation used in indirect specular lighting.
-// via 'environmentBRDF' from "Physically Based Shading on Mobile"
-// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
-vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
-
-	float dotNV = saturate( dot( normal, viewDir ) );
-
-	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
-
-	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
-
-	vec4 r = roughness * c0 + c1;
-
-	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
-
-	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
-
-	return fab;
-
-}
-
-vec3 BRDF_Specular_GGX_Environment( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
-
-	vec2 fab = DFGApprox( normal, viewDir, roughness );
-
-	return specularColor * fab.x + specularF90 * fab.y;
-
-}
-
-// Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
-// Approximates multiscattering in order to preserve energy.
-// http://www.jcgt.org/published/0008/01/03/
-void BRDF_Specular_Multiscattering_Environment( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
-
-	vec2 fab = DFGApprox( normal, viewDir, roughness );
-
-	vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
-
-	float Ess = fab.x + fab.y;
-	float Ems = 1.0 - Ess;
-
-	vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21
-	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
-
-	singleScatter += FssEss;
-	multiScatter += Fms * Ems;
-
 }
 }
 
 
 // Rect Area Light
 // Rect Area Light

+ 50 - 0
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js

@@ -25,6 +25,56 @@ float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
 
 
 }
 }
 
 
+// Analytical approximation of the DFG LUT, one half of the
+// split-sum approximation used in indirect specular lighting.
+// via 'environmentBRDF' from "Physically Based Shading on Mobile"
+// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
+vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
+
+	float dotNV = saturate( dot( normal, viewDir ) );
+
+	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
+
+	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
+
+	vec4 r = roughness * c0 + c1;
+
+	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
+
+	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
+
+	return fab;
+
+}
+
+vec3 BRDF_Specular_GGX_Environment( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
+
+	vec2 fab = DFGApprox( normal, viewDir, roughness );
+
+	return specularColor * fab.x + specularF90 * fab.y;
+
+}
+
+// Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
+// Approximates multiscattering in order to preserve energy.
+// http://www.jcgt.org/published/0008/01/03/
+void BRDF_Specular_Multiscattering_Environment( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
+
+	vec2 fab = DFGApprox( normal, viewDir, roughness );
+
+	vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
+
+	float Ess = fab.x + fab.y;
+	float Ems = 1.0 - Ess;
+
+	vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21
+	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
+
+	singleScatter += FssEss;
+	multiScatter += Fms * Ems;
+
+}
+
 #if NUM_RECT_AREA_LIGHTS > 0
 #if NUM_RECT_AREA_LIGHTS > 0
 
 
 	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
 	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {

+ 1 - 1
src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js

@@ -53,7 +53,6 @@ varying vec3 vViewPosition;
 #include <lightmap_pars_fragment>
 #include <lightmap_pars_fragment>
 #include <emissivemap_pars_fragment>
 #include <emissivemap_pars_fragment>
 #include <bsdfs>
 #include <bsdfs>
-#include <transmission_pars_fragment>
 #include <cube_uv_reflection_fragment>
 #include <cube_uv_reflection_fragment>
 #include <envmap_common_pars_fragment>
 #include <envmap_common_pars_fragment>
 #include <envmap_physical_pars_fragment>
 #include <envmap_physical_pars_fragment>
@@ -61,6 +60,7 @@ varying vec3 vViewPosition;
 #include <lights_pars_begin>
 #include <lights_pars_begin>
 #include <normal_pars_fragment>
 #include <normal_pars_fragment>
 #include <lights_physical_pars_fragment>
 #include <lights_physical_pars_fragment>
+#include <transmission_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <bumpmap_pars_fragment>
 #include <bumpmap_pars_fragment>
 #include <normalmap_pars_fragment>
 #include <normalmap_pars_fragment>