Browse Source

Merge pull request #13277 from sunag/dev-lightshader

 separates light entities shaders from light maps shaders
Mr.doob 7 years ago
parent
commit
f0936b0c3e

+ 3 - 3
examples/js/ShaderSkin.js

@@ -84,7 +84,7 @@ THREE.ShaderSkin = {
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "bsdfs" ],
 			THREE.ShaderChunk[ "bsdfs" ],
 			THREE.ShaderChunk[ "packing" ],
 			THREE.ShaderChunk[ "packing" ],
-			THREE.ShaderChunk[ "lights_pars" ],
+			THREE.ShaderChunk[ "lights_pars_begin" ],
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "bumpmap_pars_fragment" ],
 			THREE.ShaderChunk[ "bumpmap_pars_fragment" ],
@@ -264,7 +264,7 @@ THREE.ShaderSkin = {
 			"varying vec3 vViewPosition;",
 			"varying vec3 vViewPosition;",
 
 
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "common" ],
-			THREE.ShaderChunk[ "lights_pars" ],
+			THREE.ShaderChunk[ "lights_pars_begin" ],
 			THREE.ShaderChunk[ "shadowmap_pars_vertex" ],
 			THREE.ShaderChunk[ "shadowmap_pars_vertex" ],
 			THREE.ShaderChunk[ "fog_pars_vertex" ],
 			THREE.ShaderChunk[ "fog_pars_vertex" ],
 
 
@@ -368,7 +368,7 @@ THREE.ShaderSkin = {
 			"varying vec3 vViewPosition;",
 			"varying vec3 vViewPosition;",
 
 
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "common" ],
-			THREE.ShaderChunk[ "lights_pars" ],
+			THREE.ShaderChunk[ "lights_pars_begin" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 
 
 			"float fresnelReflectance( vec3 H, vec3 V, float F0 ) {",
 			"float fresnelReflectance( vec3 H, vec3 V, float F0 ) {",

+ 1 - 1
examples/js/ShaderTerrain.js

@@ -87,7 +87,7 @@ THREE.ShaderTerrain = {
 
 
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "bsdfs" ],
 			THREE.ShaderChunk[ "bsdfs" ],
-			THREE.ShaderChunk[ "lights_pars" ],
+			THREE.ShaderChunk[ "lights_pars_begin" ],
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 
 

+ 3 - 2
examples/js/nodes/materials/PhongNode.js

@@ -144,7 +144,7 @@ THREE.PhongNode.prototype.build = function ( builder ) {
 			"#include <common>",
 			"#include <common>",
 			"#include <fog_pars_fragment>",
 			"#include <fog_pars_fragment>",
 			"#include <bsdfs>",
 			"#include <bsdfs>",
-			"#include <lights_pars>",
+			"#include <lights_pars_begin>",
 			"#include <lights_phong_pars_fragment>",
 			"#include <lights_phong_pars_fragment>",
 			"#include <shadowmap_pars_fragment>",
 			"#include <shadowmap_pars_fragment>",
 			"#include <logdepthbuf_pars_fragment>"
 			"#include <logdepthbuf_pars_fragment>"
@@ -208,7 +208,8 @@ THREE.PhongNode.prototype.build = function ( builder ) {
 			'material.specularShininess = shininess;',
 			'material.specularShininess = shininess;',
 			'material.specularStrength = specularStrength;',
 			'material.specularStrength = specularStrength;',
 
 
-			"#include <lights_template>"
+			"#include <lights_fragment_begin>",
+			"#include <lights_fragment_end>"
 		);
 		);
 
 
 		if ( light ) {
 		if ( light ) {

+ 4 - 7
examples/js/nodes/materials/StandardNode.js

@@ -182,7 +182,7 @@ THREE.StandardNode.prototype.build = function ( builder ) {
 			"#include <common>",
 			"#include <common>",
 			"#include <fog_pars_fragment>",
 			"#include <fog_pars_fragment>",
 			"#include <bsdfs>",
 			"#include <bsdfs>",
-			"#include <lights_pars>",
+			"#include <lights_pars_begin>",
 			"#include <lights_physical_pars_fragment>",
 			"#include <lights_physical_pars_fragment>",
 			"#include <shadowmap_pars_fragment>",
 			"#include <shadowmap_pars_fragment>",
 			"#include <logdepthbuf_pars_fragment>",
 			"#include <logdepthbuf_pars_fragment>",
@@ -287,7 +287,8 @@ THREE.StandardNode.prototype.build = function ( builder ) {
 		}
 		}
 
 
 		output.push(
 		output.push(
-			"#include <lights_template>"
+			"#include <lights_fragment_begin>",
+			"#include <lights_fragment_end>"
 		);
 		);
 
 
 		if ( light ) {
 		if ( light ) {
@@ -355,13 +356,9 @@ THREE.StandardNode.prototype.build = function ( builder ) {
 
 
 				output.push(
 				output.push(
 					clearCoatEnv.code,
 					clearCoatEnv.code,
-					"vec3 clearCoatRadiance = " + clearCoatEnv.result + ";"
+					"clearCoatRadiance += " + clearCoatEnv.result + ";"
 				);
 				);
 
 
-			} else {
-
-				output.push( "vec3 clearCoatRadiance = vec3( 0.0 );" );
-
 			}
 			}
 
 
 			output.push( "RE_IndirectSpecular(" + environment.result + ", clearCoatRadiance, geometry, material, reflectedLight );" );
 			output.push( "RE_IndirectSpecular(" + environment.result + ", clearCoatRadiance, geometry, material, reflectedLight );" );

+ 1 - 1
examples/js/objects/Water.js

@@ -144,7 +144,7 @@ THREE.Water = function ( geometry, options ) {
 			THREE.ShaderChunk[ 'packing' ],
 			THREE.ShaderChunk[ 'packing' ],
 			THREE.ShaderChunk[ 'bsdfs' ],
 			THREE.ShaderChunk[ 'bsdfs' ],
 			THREE.ShaderChunk[ 'fog_pars_fragment' ],
 			THREE.ShaderChunk[ 'fog_pars_fragment' ],
-			THREE.ShaderChunk[ 'lights_pars' ],
+			THREE.ShaderChunk[ 'lights_pars_begin' ],
 			THREE.ShaderChunk[ 'shadowmap_pars_fragment' ],
 			THREE.ShaderChunk[ 'shadowmap_pars_fragment' ],
 			THREE.ShaderChunk[ 'shadowmask_pars_fragment' ],
 			THREE.ShaderChunk[ 'shadowmask_pars_fragment' ],
 
 

+ 10 - 4
src/renderers/shaders/ShaderChunk.js

@@ -36,12 +36,15 @@ import gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.g
 import lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl';
 import lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl';
 import lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl';
 import lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl';
 import lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl';
 import lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl';
-import lights_pars from './ShaderChunk/lights_pars.glsl';
+import lights_pars_begin from './ShaderChunk/lights_pars_begin.glsl';
+import lights_pars_maps from './ShaderChunk/lights_pars_maps.glsl';
 import lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl';
 import lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl';
 import lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl';
 import lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl';
 import lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl';
 import lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl';
 import lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl';
 import lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl';
-import lights_template from './ShaderChunk/lights_template.glsl';
+import lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl';
+import lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl';
+import lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl';
 import logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl';
 import logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl';
 import logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl';
 import logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl';
 import logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl';
 import logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl';
@@ -148,12 +151,15 @@ export var ShaderChunk = {
 	lightmap_fragment: lightmap_fragment,
 	lightmap_fragment: lightmap_fragment,
 	lightmap_pars_fragment: lightmap_pars_fragment,
 	lightmap_pars_fragment: lightmap_pars_fragment,
 	lights_lambert_vertex: lights_lambert_vertex,
 	lights_lambert_vertex: lights_lambert_vertex,
-	lights_pars: lights_pars,
+	lights_pars_begin: lights_pars_begin,
+	lights_pars_maps: lights_pars_maps,
 	lights_phong_fragment: lights_phong_fragment,
 	lights_phong_fragment: lights_phong_fragment,
 	lights_phong_pars_fragment: lights_phong_pars_fragment,
 	lights_phong_pars_fragment: lights_phong_pars_fragment,
 	lights_physical_fragment: lights_physical_fragment,
 	lights_physical_fragment: lights_physical_fragment,
 	lights_physical_pars_fragment: lights_physical_pars_fragment,
 	lights_physical_pars_fragment: lights_physical_pars_fragment,
-	lights_template: lights_template,
+	lights_fragment_begin: lights_fragment_begin,
+	lights_fragment_maps: lights_fragment_maps,
+	lights_fragment_end: lights_fragment_end,
 	logdepthbuf_fragment: logdepthbuf_fragment,
 	logdepthbuf_fragment: logdepthbuf_fragment,
 	logdepthbuf_pars_fragment: logdepthbuf_pars_fragment,
 	logdepthbuf_pars_fragment: logdepthbuf_pars_fragment,
 	logdepthbuf_pars_vertex: logdepthbuf_pars_vertex,
 	logdepthbuf_pars_vertex: logdepthbuf_pars_vertex,

+ 3 - 34
src/renderers/shaders/ShaderChunk/lights_template.glsl → src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl

@@ -102,20 +102,6 @@ IncidentLight directLight;
 
 
 	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
 	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
 
 
-	#ifdef USE_LIGHTMAP
-
-		vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
-
-		#ifndef PHYSICALLY_CORRECT_LIGHTS
-
-			lightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage
-
-		#endif
-
-		irradiance += lightMapIrradiance;
-
-	#endif
-
 	#if ( NUM_HEMI_LIGHTS > 0 )
 	#if ( NUM_HEMI_LIGHTS > 0 )
 
 
 		#pragma unroll_loop
 		#pragma unroll_loop
@@ -127,28 +113,11 @@ IncidentLight directLight;
 
 
 	#endif
 	#endif
 
 
-	#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )
-
-		// TODO, replace 8 with the real maxMIPLevel
-		irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, 8 );
-
-	#endif
-
-	RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
-
 #endif
 #endif
 
 
-#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
-
-	// TODO, replace 8 with the real maxMIPLevel
-	vec3 radiance = getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_BlinnShininessExponent( material ), 8 );
-
-	#ifndef STANDARD
-		vec3 clearCoatRadiance = getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );
-	#else
-		vec3 clearCoatRadiance = vec3( 0.0 );
-	#endif
+#if defined( RE_IndirectSpecular )
 
 
-	RE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );
+	vec3 radiance = vec3( 0.0 );
+	vec3 clearCoatRadiance = vec3( 0.0 );
 
 
 #endif
 #endif

+ 11 - 0
src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl

@@ -0,0 +1,11 @@
+#if defined( RE_IndirectDiffuse )
+
+	RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
+
+#endif
+
+#if defined( RE_IndirectSpecular )
+
+	RE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );
+
+#endif

+ 35 - 0
src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl

@@ -0,0 +1,35 @@
+#if defined( RE_IndirectDiffuse )
+
+	#ifdef USE_LIGHTMAP
+
+		vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
+
+		#ifndef PHYSICALLY_CORRECT_LIGHTS
+
+			lightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage
+
+		#endif
+
+		irradiance += lightMapIrradiance;
+
+	#endif
+
+	#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )
+
+		// TODO, replace 8 with the real maxMIPLevel
+		irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, 8 );
+
+	#endif
+
+#endif
+
+#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
+
+	// TODO, replace 8 with the real maxMIPLevel
+	radiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_BlinnShininessExponent( material ), 8 );
+
+	#ifndef STANDARD
+		clearCoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );
+	#endif
+
+#endif

+ 170 - 0
src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl

@@ -0,0 +1,170 @@
+uniform vec3 ambientLightColor;
+
+vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
+
+	vec3 irradiance = ambientLightColor;
+
+	#ifndef PHYSICALLY_CORRECT_LIGHTS
+
+		irradiance *= PI;
+
+	#endif
+
+	return irradiance;
+
+}
+
+#if NUM_DIR_LIGHTS > 0
+
+	struct DirectionalLight {
+		vec3 direction;
+		vec3 color;
+
+		int shadow;
+		float shadowBias;
+		float shadowRadius;
+		vec2 shadowMapSize;
+	};
+
+	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
+
+	void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
+
+		directLight.color = directionalLight.color;
+		directLight.direction = directionalLight.direction;
+		directLight.visible = true;
+
+	}
+
+#endif
+
+
+#if NUM_POINT_LIGHTS > 0
+
+	struct PointLight {
+		vec3 position;
+		vec3 color;
+		float distance;
+		float decay;
+
+		int shadow;
+		float shadowBias;
+		float shadowRadius;
+		vec2 shadowMapSize;
+		float shadowCameraNear;
+		float shadowCameraFar;
+	};
+
+	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
+
+	// directLight is an out parameter as having it as a return value caused compiler errors on some devices
+	void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
+
+		vec3 lVector = pointLight.position - geometry.position;
+		directLight.direction = normalize( lVector );
+
+		float lightDistance = length( lVector );
+
+		directLight.color = pointLight.color;
+		directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
+		directLight.visible = ( directLight.color != vec3( 0.0 ) );
+
+	}
+
+#endif
+
+
+#if NUM_SPOT_LIGHTS > 0
+
+	struct SpotLight {
+		vec3 position;
+		vec3 direction;
+		vec3 color;
+		float distance;
+		float decay;
+		float coneCos;
+		float penumbraCos;
+
+		int shadow;
+		float shadowBias;
+		float shadowRadius;
+		vec2 shadowMapSize;
+	};
+
+	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
+
+	// directLight is an out parameter as having it as a return value caused compiler errors on some devices
+	void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {
+
+		vec3 lVector = spotLight.position - geometry.position;
+		directLight.direction = normalize( lVector );
+
+		float lightDistance = length( lVector );
+		float angleCos = dot( directLight.direction, spotLight.direction );
+
+		if ( angleCos > spotLight.coneCos ) {
+
+			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
+
+			directLight.color = spotLight.color;
+			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
+			directLight.visible = true;
+
+		} else {
+
+			directLight.color = vec3( 0.0 );
+			directLight.visible = false;
+
+		}
+	}
+
+#endif
+
+
+#if NUM_RECT_AREA_LIGHTS > 0
+
+	struct RectAreaLight {
+		vec3 color;
+		vec3 position;
+		vec3 halfWidth;
+		vec3 halfHeight;
+	};
+
+	// Pre-computed values of LinearTransformedCosine approximation of BRDF
+	// BRDF approximation Texture is 64x64
+	uniform sampler2D ltc_1; // RGBA Float
+	uniform sampler2D ltc_2; // RGBA Float
+
+	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
+
+#endif
+
+
+#if NUM_HEMI_LIGHTS > 0
+
+	struct HemisphereLight {
+		vec3 direction;
+		vec3 skyColor;
+		vec3 groundColor;
+	};
+
+	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
+
+	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
+
+		float dotNL = dot( geometry.normal, hemiLight.direction );
+		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
+
+		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
+
+		#ifndef PHYSICALLY_CORRECT_LIGHTS
+
+			irradiance *= PI;
+
+		#endif
+
+		return irradiance;
+
+	}
+
+#endif

+ 0 - 172
src/renderers/shaders/ShaderChunk/lights_pars.glsl → src/renderers/shaders/ShaderChunk/lights_pars_maps.glsl

@@ -1,175 +1,3 @@
-uniform vec3 ambientLightColor;
-
-vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
-
-	vec3 irradiance = ambientLightColor;
-
-	#ifndef PHYSICALLY_CORRECT_LIGHTS
-
-		irradiance *= PI;
-
-	#endif
-
-	return irradiance;
-
-}
-
-#if NUM_DIR_LIGHTS > 0
-
-	struct DirectionalLight {
-		vec3 direction;
-		vec3 color;
-
-		int shadow;
-		float shadowBias;
-		float shadowRadius;
-		vec2 shadowMapSize;
-	};
-
-	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
-
-	void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
-
-		directLight.color = directionalLight.color;
-		directLight.direction = directionalLight.direction;
-		directLight.visible = true;
-
-	}
-
-#endif
-
-
-#if NUM_POINT_LIGHTS > 0
-
-	struct PointLight {
-		vec3 position;
-		vec3 color;
-		float distance;
-		float decay;
-
-		int shadow;
-		float shadowBias;
-		float shadowRadius;
-		vec2 shadowMapSize;
-		float shadowCameraNear;
-		float shadowCameraFar;
-	};
-
-	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
-
-	// directLight is an out parameter as having it as a return value caused compiler errors on some devices
-	void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
-
-		vec3 lVector = pointLight.position - geometry.position;
-		directLight.direction = normalize( lVector );
-
-		float lightDistance = length( lVector );
-
-		directLight.color = pointLight.color;
-		directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
-		directLight.visible = ( directLight.color != vec3( 0.0 ) );
-
-	}
-
-#endif
-
-
-#if NUM_SPOT_LIGHTS > 0
-
-	struct SpotLight {
-		vec3 position;
-		vec3 direction;
-		vec3 color;
-		float distance;
-		float decay;
-		float coneCos;
-		float penumbraCos;
-
-		int shadow;
-		float shadowBias;
-		float shadowRadius;
-		vec2 shadowMapSize;
-	};
-
-	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
-
-	// directLight is an out parameter as having it as a return value caused compiler errors on some devices
-	void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {
-
-		vec3 lVector = spotLight.position - geometry.position;
-		directLight.direction = normalize( lVector );
-
-		float lightDistance = length( lVector );
-		float angleCos = dot( directLight.direction, spotLight.direction );
-
-		if ( angleCos > spotLight.coneCos ) {
-
-			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
-
-			directLight.color = spotLight.color;
-			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
-			directLight.visible = true;
-
-		} else {
-
-			directLight.color = vec3( 0.0 );
-			directLight.visible = false;
-
-		}
-	}
-
-#endif
-
-
-#if NUM_RECT_AREA_LIGHTS > 0
-
-	struct RectAreaLight {
-		vec3 color;
-		vec3 position;
-		vec3 halfWidth;
-		vec3 halfHeight;
-	};
-
-	// Pre-computed values of LinearTransformedCosine approximation of BRDF
-	// BRDF approximation Texture is 64x64
-	uniform sampler2D ltc_1; // RGBA Float
-	uniform sampler2D ltc_2; // RGBA Float
-
-	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
-
-#endif
-
-
-#if NUM_HEMI_LIGHTS > 0
-
-	struct HemisphereLight {
-		vec3 direction;
-		vec3 skyColor;
-		vec3 groundColor;
-	};
-
-	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
-
-	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
-
-		float dotNL = dot( geometry.normal, hemiLight.direction );
-		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
-
-		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
-
-		#ifndef PHYSICALLY_CORRECT_LIGHTS
-
-			irradiance *= PI;
-
-		#endif
-
-		return irradiance;
-
-	}
-
-#endif
-
-
 #if defined( USE_ENVMAP ) && defined( PHYSICAL )
 #if defined( USE_ENVMAP ) && defined( PHYSICAL )
 
 
 	vec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {
 	vec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {

+ 2 - 1
src/renderers/shaders/ShaderLib/meshlambert_frag.glsl

@@ -23,7 +23,8 @@ varying vec3 vLightFront;
 #include <emissivemap_pars_fragment>
 #include <emissivemap_pars_fragment>
 #include <envmap_pars_fragment>
 #include <envmap_pars_fragment>
 #include <bsdfs>
 #include <bsdfs>
-#include <lights_pars>
+#include <lights_pars_begin>
+#include <lights_pars_maps>
 #include <fog_pars_fragment>
 #include <fog_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <shadowmask_pars_fragment>
 #include <shadowmask_pars_fragment>

+ 2 - 1
src/renderers/shaders/ShaderLib/meshlambert_vert.glsl

@@ -13,7 +13,8 @@ varying vec3 vLightFront;
 #include <uv2_pars_vertex>
 #include <uv2_pars_vertex>
 #include <envmap_pars_vertex>
 #include <envmap_pars_vertex>
 #include <bsdfs>
 #include <bsdfs>
-#include <lights_pars>
+#include <lights_pars_begin>
+#include <lights_pars_maps>
 #include <color_pars_vertex>
 #include <color_pars_vertex>
 #include <fog_pars_vertex>
 #include <fog_pars_vertex>
 #include <morphtarget_pars_vertex>
 #include <morphtarget_pars_vertex>

+ 5 - 2
src/renderers/shaders/ShaderLib/meshphong_frag.glsl

@@ -21,7 +21,8 @@ uniform float opacity;
 #include <gradientmap_pars_fragment>
 #include <gradientmap_pars_fragment>
 #include <fog_pars_fragment>
 #include <fog_pars_fragment>
 #include <bsdfs>
 #include <bsdfs>
-#include <lights_pars>
+#include <lights_pars_begin>
+#include <lights_pars_maps>
 #include <lights_phong_pars_fragment>
 #include <lights_phong_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <bumpmap_pars_fragment>
 #include <bumpmap_pars_fragment>
@@ -49,7 +50,9 @@ void main() {
 
 
 	// accumulation
 	// accumulation
 	#include <lights_phong_fragment>
 	#include <lights_phong_fragment>
-	#include <lights_template>
+	#include <lights_fragment_begin>
+	#include <lights_fragment_maps>
+	#include <lights_fragment_end>
 
 
 	// modulation
 	// modulation
 	#include <aomap_fragment>
 	#include <aomap_fragment>

+ 5 - 2
src/renderers/shaders/ShaderLib/meshphysical_frag.glsl

@@ -34,7 +34,8 @@ varying vec3 vViewPosition;
 #include <fog_pars_fragment>
 #include <fog_pars_fragment>
 #include <bsdfs>
 #include <bsdfs>
 #include <cube_uv_reflection_fragment>
 #include <cube_uv_reflection_fragment>
-#include <lights_pars>
+#include <lights_pars_begin>
+#include <lights_pars_maps>
 #include <lights_physical_pars_fragment>
 #include <lights_physical_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <bumpmap_pars_fragment>
 #include <bumpmap_pars_fragment>
@@ -64,7 +65,9 @@ void main() {
 
 
 	// accumulation
 	// accumulation
 	#include <lights_physical_fragment>
 	#include <lights_physical_fragment>
-	#include <lights_template>
+	#include <lights_fragment_begin>
+	#include <lights_fragment_maps>
+	#include <lights_fragment_end>
 
 
 	// modulation
 	// modulation
 	#include <aomap_fragment>
 	#include <aomap_fragment>

+ 1 - 1
src/renderers/shaders/ShaderLib/shadow_frag.glsl

@@ -5,7 +5,7 @@ uniform float opacity;
 #include <packing>
 #include <packing>
 #include <fog_pars_fragment>
 #include <fog_pars_fragment>
 #include <bsdfs>
 #include <bsdfs>
-#include <lights_pars>
+#include <lights_pars_begin>
 #include <shadowmap_pars_fragment>
 #include <shadowmap_pars_fragment>
 #include <shadowmask_pars_fragment>
 #include <shadowmask_pars_fragment>