2
0
Эх сурвалжийг харах

CubeTexture: Add needsFlipEnvMap flag.

Mugen87 5 жил өмнө
parent
commit
1732817d59

+ 2 - 0
src/renderers/WebGLCubeRenderTarget.js

@@ -23,6 +23,8 @@ function WebGLCubeRenderTarget( size, options, dummy ) {
 
 
 	this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
 	this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
 
 
+	this.texture._needsFlipEnvMap = false;
+
 }
 }
 
 
 WebGLCubeRenderTarget.prototype = Object.create( WebGLRenderTarget.prototype );
 WebGLCubeRenderTarget.prototype = Object.create( WebGLRenderTarget.prototype );

+ 1 - 1
src/renderers/webgl/WebGLBackground.js

@@ -109,7 +109,7 @@ function WebGLBackground( renderer, cubemaps, state, objects, premultipliedAlpha
 			}
 			}
 
 
 			boxMesh.material.uniforms.envMap.value = background;
 			boxMesh.material.uniforms.envMap.value = background;
-			boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture ? - 1 : 1;
+			boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background._needsFlipEnvMap ) ? - 1 : 1;
 
 
 			if ( currentBackground !== background ||
 			if ( currentBackground !== background ||
 				currentBackgroundVersion !== background.version ||
 				currentBackgroundVersion !== background.version ||

+ 1 - 1
src/renderers/webgl/WebGLMaterials.js

@@ -145,7 +145,7 @@ function WebGLMaterials( properties ) {
 
 
 			uniforms.envMap.value = envMap;
 			uniforms.envMap.value = envMap;
 
 
-			uniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1;
+			uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap._needsFlipEnvMap ) ? - 1 : 1;
 
 
 			uniforms.reflectivity.value = material.reflectivity;
 			uniforms.reflectivity.value = material.reflectivity;
 			uniforms.refractionRatio.value = material.refractionRatio;
 			uniforms.refractionRatio.value = material.refractionRatio;

+ 2 - 0
src/textures/CubeTexture.js

@@ -11,6 +11,8 @@ function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, forma
 
 
 	this.flipY = false;
 	this.flipY = false;
 
 
+	this._needsFlipEnvMap = true;
+
 }
 }
 
 
 CubeTexture.prototype = Object.create( Texture.prototype );
 CubeTexture.prototype = Object.create( Texture.prototype );