Browse Source

Quick fix nexus5 point/spot light issues (#9948)

* remove testLightInRange, not equivalent to calcLightAttenuation.

* convert vec3( 0.0, 0.0, 0.0 ) -> vec3( 0.0 ), smaller, equivalent.

* fix merge issue in SpotLight glsl code.
Ben Houston (Clara.io) 8 years ago
parent
commit
a56405c4ff

+ 0 - 6
src/renderers/shaders/ShaderChunk/bsdfs.glsl

@@ -1,9 +1,3 @@
-bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {
-
-	return any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );
-
-}
-
 float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
 float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
 
 
 		if( decayExponent > 0.0 ) {
 		if( decayExponent > 0.0 ) {

+ 5 - 16
src/renderers/shaders/ShaderChunk/lights_pars.glsl

@@ -63,19 +63,9 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
 
 
 		float lightDistance = length( lVector );
 		float lightDistance = length( lVector );
 
 
-		if ( testLightInRange( lightDistance, pointLight.distance ) ) {
-
-			directLight.color = pointLight.color;
-			directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
-
-			directLight.visible = true;
-
-		} else {
-
-			directLight.color = vec3( 0.0 );
-			directLight.visible = false;
-
-		}
+		directLight.color = pointLight.color;
+		directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
+		directLight.visible = ( directLight.color != vec3( 0.0 ) );
 
 
 	}
 	}
 
 
@@ -110,14 +100,13 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
 		float lightDistance = length( lVector );
 		float lightDistance = length( lVector );
 		float angleCos = dot( directLight.direction, spotLight.direction );
 		float angleCos = dot( directLight.direction, spotLight.direction );
 
 
-		if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {
+		if ( angleCos > spotLight.coneCos ) {
 
 
 			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
 			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
 
 
 			directLight.color = spotLight.color;
 			directLight.color = spotLight.color;
 			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
 			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
-
-			directLight.visible = true;
+			directLight.visible = true;//( directLight.color != vec3( 0.0 ) );
 
 
 		} else {
 		} else {