Переглянути джерело

ensure no mipmaps or linear filters for non-monotonic encoded texture.

Ben Houston 9 роки тому
батько
коміт
1c41df2ae6
1 змінених файлів з 18 додано та 11 видалено
  1. 18 11
      examples/js/pmrem/PMREMGenerator.js

+ 18 - 11
examples/js/pmrem/PMREMGenerator.js

@@ -3,27 +3,34 @@
  * @author Ben Houston / bhouston, https://clara.io
  */
 
- THREE.PMREMGenerator = function( cubeTexture ) {
-	if ( cubeTexture instanceof THREE.CubeTexture ) {
+ THREE.PMREMGenerator = function( sourceTexture ) {
+	if ( sourceTexture instanceof THREE.CubeTexture ) {
 
-		if ( cubeTexture.images[ 0 ] === undefined )
-		  console.error( "CubeTexture Not Initialized" );
-      if(cubeTexture.images[ 0 ] instanceof THREE.DataTexture) {
-          this.resolution = cubeTexture.images[ 0 ].image.width;
+		if ( sourceTexture.images[ 0 ] === undefined )
+		  console.error( "sourceTexture Not Initialized" );
+      if(sourceTexture.images[ 0 ] instanceof THREE.DataTexture) {
+          this.resolution = sourceTexture.images[ 0 ].image.width;
       }
       else {
-          this.resolution = cubeTexture.images[ 0 ].width;
+          this.resolution = sourceTexture.images[ 0 ].width;
       }
 
 	}
-	else if ( cubeTexture instanceof THREE.WebGLRenderTargetCube ) {
-		if ( cubeTexture === undefined ) console.error( "Render Target Not Initialized" );
-		this.resolution = cubeTexture.width;
+	else if ( sourceTexture instanceof THREE.WebGLRenderTargetCube ) {
+		if ( sourceTexture === undefined ) console.error( "Render Target Not Initialized" );
+		this.resolution = sourceTexture.width;
 	}
 	else {
 		console.error( "Wrong Input to PMREMGenerator" );
 	}
-	this.sourceTexture = cubeTexture;
+	this.sourceTexture = sourceTexture;
+
+  var monotonicEncoding = ( sourceTexture.encoding === THREE.LinearEncoding ) ||
+    ( sourceTexture.encoding === THREE.GammaEncoding ) || ( sourceTexture.encoding === THREE.sRGBEncoding );
+
+  this.sourceTexture.minFilter = ( monotonicEncoding ) ? THREE.LinearFilter : THREE.NearestFilter;
+  this.sourceTexture.magFilter = ( monotonicEncoding ) ? THREE.LinearFilter : THREE.NearestFilter;
+  this.sourceTexture.generateMipmaps = this.sourceTexture.generateMipmaps && monotonicEncoding;
 
 	this.cubeLods = [];