Browse Source

WebGPUBindings: Make texture update more robust.

Mugen87 4 years ago
parent
commit
16353c9ccf
1 changed files with 18 additions and 10 deletions
  1. 18 10
      examples/jsm/renderers/webgpu/WebGPUBindings.js

+ 18 - 10
examples/jsm/renderers/webgpu/WebGPUBindings.js

@@ -121,14 +121,18 @@ class WebGPUBindings {
 				const material = object.material;
 				const texture = material[ binding.name ];
 
-				textures.updateSampler( texture );
+				if ( texture !== null ) {
 
-				const samplerGPU = textures.getSampler( texture );
+					textures.updateSampler( texture );
 
-				if ( binding.samplerGPU !== samplerGPU ) {
+					const samplerGPU = textures.getSampler( texture );
 
-					binding.samplerGPU = samplerGPU;
-					needsBindGroupRefresh = true;
+					if ( binding.samplerGPU !== samplerGPU ) {
+
+						binding.samplerGPU = samplerGPU;
+						needsBindGroupRefresh = true;
+
+					}
 
 				}
 
@@ -137,13 +141,17 @@ class WebGPUBindings {
 				const material = object.material;
 				const texture = material[ binding.name ];
 
-				const forceUpdate = textures.updateTexture( texture );
-				const textureGPU = textures.getTextureGPU( texture );
+				if ( texture !== null ) {
+
+					const forceUpdate = textures.updateTexture( texture );
+					const textureGPU = textures.getTextureGPU( texture );
+
+					if ( binding.textureGPU !== textureGPU || forceUpdate === true ) {
 
-				if ( binding.textureGPU !== textureGPU || forceUpdate === true ) {
+						binding.textureGPU = textureGPU;
+						needsBindGroupRefresh = true;
 
-					binding.textureGPU = textureGPU;
-					needsBindGroupRefresh = true;
+					}
 
 				}