|
|
@@ -7,6 +7,7 @@ import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
|
|
|
import { nodeProxy, vec3, nodeObject, int, Fn } from '../tsl/TSLBase.js';
|
|
|
import { step } from '../math/MathNode.js';
|
|
|
import { NodeUpdateType } from '../core/constants.js';
|
|
|
+import { getTextureType } from '../core/NodeUtils.js';
|
|
|
|
|
|
import { Compatibility, GreaterCompare, GreaterEqualCompare, IntType, LessCompare, LessEqualCompare, NearestFilter, UnsignedIntType } from '../../constants.js';
|
|
|
|
|
|
@@ -228,25 +229,13 @@ class TextureNode extends UniformNode {
|
|
|
*/
|
|
|
generateNodeType( /*builder*/ ) {
|
|
|
|
|
|
- if ( this.value.isDepthTexture === true ) {
|
|
|
-
|
|
|
- if ( this.gatherNode === null ) return 'float';
|
|
|
+ if ( this.gatherNode !== null ) {
|
|
|
|
|
|
return 'vec4';
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( this.value.type === UnsignedIntType ) {
|
|
|
-
|
|
|
- return 'uvec4';
|
|
|
-
|
|
|
- } else if ( this.value.type === IntType ) {
|
|
|
-
|
|
|
- return 'ivec4';
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return 'vec4';
|
|
|
+ return getTextureType( this.value );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -566,7 +555,7 @@ class TextureNode extends UniformNode {
|
|
|
|
|
|
const nodeData = builder.getDataFromNode( this );
|
|
|
|
|
|
- let nodeType = this.getNodeType( builder );
|
|
|
+ const nodeType = this.getNodeType( builder );
|
|
|
|
|
|
let propertyName = nodeData.propertyName;
|
|
|
|
|
|
@@ -585,12 +574,6 @@ class TextureNode extends UniformNode {
|
|
|
const offsetSnippet = offsetNode ? this.generateOffset( builder, offsetNode ) : null;
|
|
|
const flipYSnippet = this._flipYUniform ? this._flipYUniform.build( builder, 'bool' ) : null;
|
|
|
|
|
|
- if ( gatherSnippet ) {
|
|
|
-
|
|
|
- nodeType = 'vec4';
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
let finalDepthSnippet = depthSnippet;
|
|
|
|
|
|
if ( finalDepthSnippet === null && texture.isArrayTexture && this.isTexture3DNode !== true ) {
|
|
|
@@ -605,6 +588,20 @@ class TextureNode extends UniformNode {
|
|
|
|
|
|
let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, finalDepthSnippet, compareSnippet, gradSnippet, gatherSnippet, offsetSnippet, flipYSnippet );
|
|
|
|
|
|
+ let snippetType;
|
|
|
+
|
|
|
+ if ( texture.isDepthTexture === true && gatherSnippet === null ) {
|
|
|
+
|
|
|
+ snippetType = 'float';
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ snippetType = texture.type === UnsignedIntType ? 'uvec4' : ( texture.type === IntType ? 'ivec4' : 'vec4' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ snippet = builder.format( snippet, snippetType, nodeType );
|
|
|
+
|
|
|
if ( compareStepSnippet !== null ) {
|
|
|
|
|
|
const compareFunction = texture.compareFunction;
|