Browse Source

TextureUtils: Add `forceContextLoss()` to `decompress()`. (#27136)

Michael Herzog 1 year ago
parent
commit
b8e78a3923
1 changed files with 18 additions and 17 deletions
  1. 18 17
      examples/jsm/utils/TextureUtils.js

+ 18 - 17
examples/jsm/utils/TextureUtils.js

@@ -21,24 +21,24 @@ export function decompress( texture, maxTextureSize = Infinity, renderer = null
 	if ( ! fullscreenQuadMaterial ) fullscreenQuadMaterial = new ShaderMaterial( {
 		uniforms: { blitTexture: new Uniform( texture ) },
 		vertexShader: `
-            varying vec2 vUv;
-            void main(){
-                vUv = uv;
-                gl_Position = vec4(position.xy * 1.0,0.,.999999);
-            }`,
+			varying vec2 vUv;
+			void main(){
+				vUv = uv;
+				gl_Position = vec4(position.xy * 1.0,0.,.999999);
+			}`,
 		fragmentShader: `
-            uniform sampler2D blitTexture; 
-            varying vec2 vUv;
-
-            void main(){ 
-                gl_FragColor = vec4(vUv.xy, 0, 1);
-                
-                #ifdef IS_SRGB
-                gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );
-                #else
-                gl_FragColor = texture2D( blitTexture, vUv);
-                #endif
-            }`
+			uniform sampler2D blitTexture; 
+			varying vec2 vUv;
+
+			void main(){ 
+				gl_FragColor = vec4(vUv.xy, 0, 1);
+				
+				#ifdef IS_SRGB
+				gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );
+				#else
+				gl_FragColor = texture2D( blitTexture, vUv);
+				#endif
+			}`
 	} );
 
 	fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
@@ -76,6 +76,7 @@ export function decompress( texture, maxTextureSize = Infinity, renderer = null
 
 	if ( _renderer ) {
 
+		_renderer.forceContextLoss();
 		_renderer.dispose();
 		_renderer = null;