Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 207 additions & 205 deletions build/three.cjs

Large diffs are not rendered by default.

412 changes: 207 additions & 205 deletions build/three.core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/three.core.min.js

Large diffs are not rendered by default.

91 changes: 64 additions & 27 deletions build/three.webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ class NodeMaterialObserver {
// check index

const index = geometry.index;
const storedIndexId = storedGeometryData.id;
const storedIndexId = storedGeometryData.indexId;
const storedIndexVersion = storedGeometryData.indexVersion;
const currentIndexId = index ? index.id : null;
const currentIndexVersion = index ? index.version : null;

if ( storedIndexId !== currentIndexId || storedIndexVersion !== currentIndexVersion ) {

storedGeometryData.id = currentIndexId;
storedGeometryData.indexId = currentIndexId;
storedGeometryData.indexVersion = currentIndexVersion;
return false;

Expand Down Expand Up @@ -37857,6 +37857,28 @@ class StorageTextureNode extends TextureNode {

}

/**
* Generates the snippet for the storage texture.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {string} textureProperty - The texture property.
* @param {string} uvSnippet - The uv snippet.
* @param {?string} levelSnippet - The level snippet.
* @param {?string} biasSnippet - The bias snippet.
* @param {?string} depthSnippet - The depth snippet.
* @param {?string} compareSnippet - The compare snippet.
* @param {?Array<string>} gradSnippet - The grad snippet.
* @param {?string} offsetSnippet - The offset snippet.
* @return {string} The generated code snippet.
*/
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet ) {

const texture = this.value;

return builder.generateStorageTextureLoad( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );

}

/**
* Convenience method for configuring a read/write node access.
*
Expand Down Expand Up @@ -61153,7 +61175,7 @@ class Sampler extends Binding {
this._onTextureDispose = () => {

this.generation = null;
this.version = 0;
this.version = -1;

};

Expand All @@ -61165,7 +61187,7 @@ class Sampler extends Binding {
*
* @type {number}
*/
this.version = texture ? texture.version : 0;
this.version = texture ? texture.version : -1;

/**
* The binding's generation which is an additional version
Expand Down Expand Up @@ -61213,7 +61235,7 @@ class Sampler extends Binding {
this._texture = value;

this.generation = null;
this.version = 0;
this.version = -1;

if ( this._texture ) {

Expand Down Expand Up @@ -61268,7 +61290,7 @@ class Sampler extends Binding {
clonedSampler._onTextureDispose = () => {

clonedSampler.generation = null;
clonedSampler.version = 0;
clonedSampler.version = -1;

};

Expand Down Expand Up @@ -73945,7 +73967,7 @@ class WGSLNodeBuilder extends NodeBuilder {
}

/**
* Generates the WGSL snippet that reads a single texel from a texture without sampling or filtering.
* Generates the WGSL snippet that reads a single texel from a storage texture.
*
* @param {Texture} texture - The texture.
* @param {string} textureProperty - The name of the texture uniform in the shader.
Expand All @@ -73955,11 +73977,7 @@ class WGSLNodeBuilder extends NodeBuilder {
* @param {?string} offsetSnippet - A WGSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
* @return {string} The WGSL snippet.
*/
generateTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {

const isStorageTexture = texture.isStorageTexture === true;

if ( levelSnippet === null && ! isStorageTexture ) levelSnippet = '0u';
generateStorageTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {

if ( offsetSnippet ) {

Expand All @@ -73971,33 +73989,52 @@ class WGSLNodeBuilder extends NodeBuilder {

if ( depthSnippet ) {

// Storage textures don't take a level parameter in WGSL
if ( isStorageTexture ) {
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet } )`;

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet } )`;
} else {

} else {
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
}

}
return snippet;

} else {
}

/**
* Generates the WGSL snippet that reads a single texel from a texture without sampling or filtering.
*
* @param {Texture} texture - The texture.
* @param {string} textureProperty - The name of the texture uniform in the shader.
* @param {string} uvIndexSnippet - A WGSL snippet that represents texture coordinates used for sampling.
* @param {?string} levelSnippet - A WGSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
* @param {?string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
* @param {?string} offsetSnippet - A WGSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
* @return {string} The WGSL snippet.
*/
generateTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {

// Storage textures don't take a level parameter in WGSL
if ( isStorageTexture ) {
if ( levelSnippet === null ) levelSnippet = '0u';

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
if ( offsetSnippet ) {

} else {
uvIndexSnippet = `${ uvIndexSnippet } + ${ offsetSnippet }`;

}

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
let snippet;

if ( this.renderer.backend.compatibilityMode && texture.isDepthTexture ) {
if ( depthSnippet ) {

snippet += '.x';
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;

}
} else {

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;

if ( this.renderer.backend.compatibilityMode && texture.isDepthTexture ) {

snippet += '.x';

}

Expand Down
2 changes: 1 addition & 1 deletion build/three.webgpu.min.js

Large diffs are not rendered by default.

91 changes: 64 additions & 27 deletions build/three.webgpu.nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ class NodeMaterialObserver {
// check index

const index = geometry.index;
const storedIndexId = storedGeometryData.id;
const storedIndexId = storedGeometryData.indexId;
const storedIndexVersion = storedGeometryData.indexVersion;
const currentIndexId = index ? index.id : null;
const currentIndexVersion = index ? index.version : null;

if ( storedIndexId !== currentIndexId || storedIndexVersion !== currentIndexVersion ) {

storedGeometryData.id = currentIndexId;
storedGeometryData.indexId = currentIndexId;
storedGeometryData.indexVersion = currentIndexVersion;
return false;

Expand Down Expand Up @@ -37857,6 +37857,28 @@ class StorageTextureNode extends TextureNode {

}

/**
* Generates the snippet for the storage texture.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {string} textureProperty - The texture property.
* @param {string} uvSnippet - The uv snippet.
* @param {?string} levelSnippet - The level snippet.
* @param {?string} biasSnippet - The bias snippet.
* @param {?string} depthSnippet - The depth snippet.
* @param {?string} compareSnippet - The compare snippet.
* @param {?Array<string>} gradSnippet - The grad snippet.
* @param {?string} offsetSnippet - The offset snippet.
* @return {string} The generated code snippet.
*/
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet ) {

const texture = this.value;

return builder.generateStorageTextureLoad( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );

}

/**
* Convenience method for configuring a read/write node access.
*
Expand Down Expand Up @@ -61153,7 +61175,7 @@ class Sampler extends Binding {
this._onTextureDispose = () => {

this.generation = null;
this.version = 0;
this.version = -1;

};

Expand All @@ -61165,7 +61187,7 @@ class Sampler extends Binding {
*
* @type {number}
*/
this.version = texture ? texture.version : 0;
this.version = texture ? texture.version : -1;

/**
* The binding's generation which is an additional version
Expand Down Expand Up @@ -61213,7 +61235,7 @@ class Sampler extends Binding {
this._texture = value;

this.generation = null;
this.version = 0;
this.version = -1;

if ( this._texture ) {

Expand Down Expand Up @@ -61268,7 +61290,7 @@ class Sampler extends Binding {
clonedSampler._onTextureDispose = () => {

clonedSampler.generation = null;
clonedSampler.version = 0;
clonedSampler.version = -1;

};

Expand Down Expand Up @@ -73945,7 +73967,7 @@ class WGSLNodeBuilder extends NodeBuilder {
}

/**
* Generates the WGSL snippet that reads a single texel from a texture without sampling or filtering.
* Generates the WGSL snippet that reads a single texel from a storage texture.
*
* @param {Texture} texture - The texture.
* @param {string} textureProperty - The name of the texture uniform in the shader.
Expand All @@ -73955,11 +73977,7 @@ class WGSLNodeBuilder extends NodeBuilder {
* @param {?string} offsetSnippet - A WGSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
* @return {string} The WGSL snippet.
*/
generateTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {

const isStorageTexture = texture.isStorageTexture === true;

if ( levelSnippet === null && ! isStorageTexture ) levelSnippet = '0u';
generateStorageTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {

if ( offsetSnippet ) {

Expand All @@ -73971,33 +73989,52 @@ class WGSLNodeBuilder extends NodeBuilder {

if ( depthSnippet ) {

// Storage textures don't take a level parameter in WGSL
if ( isStorageTexture ) {
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet } )`;

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet } )`;
} else {

} else {
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
}

}
return snippet;

} else {
}

/**
* Generates the WGSL snippet that reads a single texel from a texture without sampling or filtering.
*
* @param {Texture} texture - The texture.
* @param {string} textureProperty - The name of the texture uniform in the shader.
* @param {string} uvIndexSnippet - A WGSL snippet that represents texture coordinates used for sampling.
* @param {?string} levelSnippet - A WGSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
* @param {?string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
* @param {?string} offsetSnippet - A WGSL snippet that represents the offset that will be applied to the unnormalized texture coordinate before sampling the texture.
* @return {string} The WGSL snippet.
*/
generateTextureLoad( texture, textureProperty, uvIndexSnippet, levelSnippet, depthSnippet, offsetSnippet ) {

// Storage textures don't take a level parameter in WGSL
if ( isStorageTexture ) {
if ( levelSnippet === null ) levelSnippet = '0u';

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
if ( offsetSnippet ) {

} else {
uvIndexSnippet = `${ uvIndexSnippet } + ${ offsetSnippet }`;

}

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
let snippet;

if ( this.renderer.backend.compatibilityMode && texture.isDepthTexture ) {
if ( depthSnippet ) {

snippet += '.x';
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;

}
} else {

snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;

if ( this.renderer.backend.compatibilityMode && texture.isDepthTexture ) {

snippet += '.x';

}

Expand Down
2 changes: 1 addition & 1 deletion build/three.webgpu.nodes.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ CORRECT - modern pattern (always use latest version):
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.0/examples/jsm/"
"three": "https://cdn.jsdelivr.net/npm/three@0.183.1/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.1/examples/jsm/"
}
}
</script>
Expand Down Expand Up @@ -100,8 +100,8 @@ When using TSL, use node-based materials:
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.0/examples/jsm/"
"three": "https://cdn.jsdelivr.net/npm/three@0.183.1/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.1/examples/jsm/"
}
}
</script>
Expand Down Expand Up @@ -175,9 +175,9 @@ renderer.setAnimationLoop( animate );
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.webgpu.js",
"three/tsl": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.tsl.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.0/examples/jsm/"
"three": "https://cdn.jsdelivr.net/npm/three@0.183.1/build/three.webgpu.js",
"three/tsl": "https://cdn.jsdelivr.net/npm/three@0.183.1/build/three.tsl.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.1/examples/jsm/"
}
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions docs/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ CORRECT - modern pattern (always use latest version):
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.183.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.0/examples/jsm/"
"three": "https://cdn.jsdelivr.net/npm/three@0.183.1/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.183.1/examples/jsm/"
}
}
</script>
Expand Down
Loading
Loading