فهرست منبع

Added clamping to spotLight term in shaders.

This is necessary for OpenGL where pow(0,0) is undefined and can be negative (in DirectX you just get zero), leading to negative light creating black areas artefacts.

Fixes #1805 and #2615 (related already fixed #998).
alteredq 13 سال پیش
والد
کامیت
5cb7155208
4فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 3 3
      build/three.js
  2. 0 0
      build/three.min.js
  3. 1 1
      src/extras/ShaderUtils.js
  4. 2 2
      src/renderers/WebGLShaders.js

+ 3 - 3
build/three.js

@@ -14281,7 +14281,7 @@ THREE.ShaderChunk = {
 
 
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 
 
-					"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+					"spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );",
 
 
 					"float lDistance = 1.0;",
 					"float lDistance = 1.0;",
 					"if ( spotLightDistance[ i ] > 0.0 )",
 					"if ( spotLightDistance[ i ] > 0.0 )",
@@ -14640,7 +14640,7 @@ THREE.ShaderChunk = {
 
 
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 
 
-					"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+					"spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );",
 
 
 					// diffuse
 					// diffuse
 
 
@@ -25447,7 +25447,7 @@ THREE.ShaderUtils = {
 
 
 							"if ( spotEffect > spotLightAngle[ i ] ) {",
 							"if ( spotEffect > spotLightAngle[ i ] ) {",
 
 
-								"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+								"spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );",
 
 
 								// diffuse
 								// diffuse
 
 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
build/three.min.js


+ 1 - 1
src/extras/ShaderUtils.js

@@ -365,7 +365,7 @@ THREE.ShaderUtils = {
 
 
 							"if ( spotEffect > spotLightAngle[ i ] ) {",
 							"if ( spotEffect > spotLightAngle[ i ] ) {",
 
 
-								"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+								"spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );",
 
 
 								// diffuse
 								// diffuse
 
 

+ 2 - 2
src/renderers/WebGLShaders.js

@@ -610,7 +610,7 @@ THREE.ShaderChunk = {
 
 
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 
 
-					"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+					"spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );",
 
 
 					"float lDistance = 1.0;",
 					"float lDistance = 1.0;",
 					"if ( spotLightDistance[ i ] > 0.0 )",
 					"if ( spotLightDistance[ i ] > 0.0 )",
@@ -969,7 +969,7 @@ THREE.ShaderChunk = {
 
 
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 				"if ( spotEffect > spotLightAngle[ i ] ) {",
 
 
-					"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+					"spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );",
 
 
 					// diffuse
 					// diffuse
 
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است