浏览代码

move getTextureEncodingFromMap to WebGLPrograms enclosure.

Ben Houston 9 年之前
父节点
当前提交
10d75a14fc
共有 1 个文件被更改,包括 22 次插入13 次删除
  1. 22 13
      src/renderers/webgl/WebGLPrograms.js

+ 22 - 13
src/renderers/webgl/WebGLPrograms.js

@@ -67,6 +67,28 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
 
 	}
 
+
+	function getTextureEncodingFromMap ( map, gammaOverrideLinear ) {
+
+		var encoding;
+		if( ! map ) {
+			encoding = THREE.LinearEncoding;
+		}
+		else if( map instanceof THREE.Texture ) {
+			encoding = map.encoding;
+		}
+		else if( map instanceof THREE.WebGLRenderTarget ) {
+			encoding = map.texture.encoding;
+		}
+
+		// add backwards compatibility for WebGLRenderer.gammaInput/gammaOutput parameter, should probably be removed at some point.
+		if( encoding === THREE.LinearEncoding && gammaOverrideLinear ) {
+			encoding = THREE.GammaEncoding;
+		}
+
+		return encoding;
+	}
+
 	this.getParameters = function ( material, lights, fog, object ) {
 		var shaderID = shaderIDs[ material.type ];
 		// heuristics to create shader parameters according to lights in the scene
@@ -87,19 +109,6 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
 
 		}
 
-		var getTextureEncodingFromMap = function( map, gammaOverrideLinear ) {
-			var encoding;
-			if( ! map ) {
-				encoding = THREE.LinearEncoding;
-			}
-			else if( map instanceof THREE.Texture ) {
-			// add backwards compatibility for WebGLRenderer.gammaInput parameter, should probably be removed at some point.
-			if( encoding === THREE.LinearEncoding && renderer.gammaInput ) {
-				encoding = THREE.GammaEncoding;
-			}
-			return encoding;
-		}
-
 		var parameters = {
 
 			shaderID: shaderID,