|
@@ -145,6 +145,20 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ getVideoSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
|
+
|
|
|
+ if ( shaderStage === 'fragment' ) {
|
|
|
+
|
|
|
+ return `textureSampleBaseClampToEdge( ${textureProperty}, ${textureProperty}_sampler, vec2<f32>( ${uvSnippet}.x, 1.0 - ${uvSnippet}.y ) )`;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ console.error( `WebGPURenderer: THREE.VideoTexture does not support ${ shaderStage } shader.` );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
|
|
|
|
|
|
if ( shaderStage === 'fragment' ) {
|
|
@@ -163,42 +177,40 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
|
|
|
}
|
|
|
|
|
|
- getTexture( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
|
+ getTexture( texture, textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
|
|
|
|
- return this.getSampler( textureProperty, uvSnippet, shaderStage );
|
|
|
+ let snippet = null;
|
|
|
|
|
|
- }
|
|
|
+ if ( texture.isVideoTexture === true ) {
|
|
|
|
|
|
- getTextureLevel( textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
|
|
|
+ snippet = this.getVideoSampler( textureProperty, uvSnippet, shaderStage );
|
|
|
|
|
|
- return this.getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage );
|
|
|
+ } else {
|
|
|
|
|
|
- }
|
|
|
+ snippet = this.getSampler( textureProperty, uvSnippet, shaderStage );
|
|
|
|
|
|
- getCubeTexture( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
|
+ }
|
|
|
|
|
|
- return this.getSampler( textureProperty, uvSnippet, shaderStage );
|
|
|
+ return snippet;
|
|
|
|
|
|
}
|
|
|
|
|
|
- getCubeTextureLevel( textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
|
|
|
+ getTextureLevel( texture, textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
|
|
|
|
|
|
- return this.getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage );
|
|
|
+ let snippet = null;
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- getVideoTexture( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
|
+ if ( texture.isVideoTexture === true ) {
|
|
|
|
|
|
- if ( shaderStage === 'fragment' ) {
|
|
|
-
|
|
|
- return `textureSampleBaseClampToEdge( ${textureProperty}, ${textureProperty}_sampler, vec2<f32>( ${uvSnippet}.x, 1.0 - ${uvSnippet}.y ) )`;
|
|
|
+ snippet = this.getVideoSampler( textureProperty, uvSnippet, shaderStage );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- console.error( `WebGPURenderer: THREE.VideoTexture does not support ${ shaderStage } shader.` );
|
|
|
+ snippet = this.getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ return snippet;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
getPropertyName( node, shaderStage = this.shaderStage ) {
|
|
@@ -542,6 +554,10 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
|
|
|
textureType = 'texture_cube<f32>';
|
|
|
|
|
|
+ } else if ( texture.isDepthTexture === true ) {
|
|
|
+
|
|
|
+ textureType = 'texture_depth_2d';
|
|
|
+
|
|
|
} else if ( texture.isVideoTexture === true ) {
|
|
|
|
|
|
textureType = 'texture_external';
|