|
@@ -14596,6 +14596,10 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
|
|
|
|
|
|
var planeMesh;
|
|
|
var boxMesh;
|
|
|
+ // Store the current background texture and its `version`
|
|
|
+ // so we can recompile the material accordingly.
|
|
|
+ var currentBackground = null;
|
|
|
+ var currentBackgroundVersion = 0;
|
|
|
|
|
|
function render( renderList, scene, camera, forceClear ) {
|
|
|
|
|
@@ -14604,11 +14608,15 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
|
|
|
if ( background === null ) {
|
|
|
|
|
|
setClear( clearColor, clearAlpha );
|
|
|
+ currentBackground = null;
|
|
|
+ currentBackgroundVersion = 0;
|
|
|
|
|
|
} else if ( background && background.isColor ) {
|
|
|
|
|
|
setClear( background, 1 );
|
|
|
forceClear = true;
|
|
|
+ currentBackground = null;
|
|
|
+ currentBackgroundVersion = 0;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -14660,9 +14668,20 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- boxMesh.material.uniforms.tCube.value = ( background.isWebGLRenderTargetCube ) ? background.texture : background;
|
|
|
+ var texture = background.isWebGLRenderTargetCube ? background.texture : background;
|
|
|
+ boxMesh.material.uniforms.tCube.value = texture;
|
|
|
boxMesh.material.uniforms.tFlip.value = ( background.isWebGLRenderTargetCube ) ? 1 : - 1;
|
|
|
|
|
|
+ if ( currentBackground !== background ||
|
|
|
+ currentBackgroundVersion !== texture.version ) {
|
|
|
+
|
|
|
+ boxMesh.material.needsUpdate = true;
|
|
|
+
|
|
|
+ currentBackground = background;
|
|
|
+ currentBackgroundVersion = texture.version;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// push to the pre-sorted opaque render list
|
|
|
renderList.push( boxMesh, boxMesh.geometry, boxMesh.material, 0, null );
|
|
|
|
|
@@ -14711,6 +14730,17 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
|
|
|
|
|
|
planeMesh.material.uniforms.uvTransform.value.copy( background.matrix );
|
|
|
|
|
|
+ if ( currentBackground !== background ||
|
|
|
+ currentBackgroundVersion !== background.version ) {
|
|
|
+
|
|
|
+ planeMesh.material.needsUpdate = true;
|
|
|
+
|
|
|
+ currentBackground = background;
|
|
|
+ currentBackgroundVersion = background.version;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// push to the pre-sorted opaque render list
|
|
|
renderList.push( planeMesh, planeMesh.geometry, planeMesh.material, 0, null );
|
|
|
|