浏览代码

Merge remote-tracking branch 'chandlerprall/master'

Mr.doob 14 年之前
父节点
当前提交
4dd2df1545
共有 1 个文件被更改,包括 9 次插入17 次删除
  1. 9 17
      src/renderers/WebGLRenderer.js

+ 9 - 17
src/renderers/WebGLRenderer.js

@@ -7,18 +7,9 @@
 
 
 THREE.WebGLRenderer = function ( parameters ) {
 THREE.WebGLRenderer = function ( parameters ) {
 
 
-	// Currently you can use just up to 4 directional / point lights total.
-	// Chrome barfs on shader linking when there are more than 4 lights :(
-
-	// The problem comes from shader using too many varying vectors.
-
-	// This is not GPU limitation as the same shader works ok in Firefox
-	// and Chrome with "--use-gl=desktop" flag.
-
-	// Difference comes from Chrome on Windows using by default ANGLE,
-	// thus going DirectX9 route (while FF uses OpenGL).
-
-	// See http://code.google.com/p/chromium/issues/detail?id=63491
+	// By default you can use just up to 4 directional / point lights total.
+	// ANGLE implementation (Chrome/Firefox on Windows) is bound to
+	// 10 varying vectors due to DirectX9 limitation.
 
 
 	var _this = this,
 	var _this = this,
 	_gl, _programs = [],
 	_gl, _programs = [],
@@ -79,6 +70,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 	_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
 	_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
 	_clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 ),
 	_clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 ),
 	_clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0;
 	_clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0;
+	_maxLights = parameters.maxLights !== undefined ? parameters.maxLights : 4;
 
 
 	this.data = {
 	this.data = {
 
 
@@ -2480,7 +2472,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		// heuristics to create shader parameters according to lights in the scene
 		// heuristics to create shader parameters according to lights in the scene
 		// (not to blow over maxLights budget)
 		// (not to blow over maxLights budget)
 
 
-		maxLightCount = allocateLights( lights, 4 );
+		maxLightCount = allocateLights( lights );
 
 
 		maxShadows = allocateShadows( lights );
 		maxShadows = allocateShadows( lights );
 
 
@@ -5345,7 +5337,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	function allocateLights( lights, maxLights ) {
+	function allocateLights( lights ) {
 
 
 		var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
 		var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
 		dirLights = pointLights = maxDirLights = maxPointLights = 0;
 		dirLights = pointLights = maxDirLights = maxPointLights = 0;
@@ -5360,15 +5352,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		}
 		}
 
 
-		if ( ( pointLights + dirLights ) <= maxLights ) {
+		if ( ( pointLights + dirLights ) <= _maxLights ) {
 
 
 			maxDirLights = dirLights;
 			maxDirLights = dirLights;
 			maxPointLights = pointLights;
 			maxPointLights = pointLights;
 
 
 		} else {
 		} else {
 
 
-			maxDirLights = Math.ceil( maxLights * dirLights / ( pointLights + dirLights ) );
-			maxPointLights = maxLights - maxDirLights;
+			maxDirLights = Math.ceil( _maxLights * dirLights / ( pointLights + dirLights ) );
+			maxPointLights = _maxLights - maxDirLights;
 
 
 		}
 		}