Просмотр исходного кода

TextureNode: Add `.blur()` check and warning (#30722)

sunag 1 год назад
Родитель
Сommit
aac0cb59fd
1 измененных файлов с 11 добавлено и 1 удалено
  1. 11 1
      src/nodes/accessors/TextureNode.js

+ 11 - 1
src/nodes/accessors/TextureNode.js

@@ -7,7 +7,7 @@ import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
 import { nodeProxy, vec3, nodeObject, int } from '../tsl/TSLBase.js';
 import { NodeUpdateType } from '../core/constants.js';
 
-import { IntType, UnsignedIntType } from '../../constants.js';
+import { IntType, NearestFilter, UnsignedIntType } from '../../constants.js';
 
 /**
  * This type of uniform node represents a 2D texture.
@@ -562,6 +562,16 @@ class TextureNode extends UniformNode {
 		textureNode.biasNode = nodeObject( amountNode ).mul( maxMipLevel( textureNode ) );
 		textureNode.referenceNode = this.getSelf();
 
+		const map = textureNode.value;
+
+		if ( map && map.generateMipmaps === false || map.minFilter === NearestFilter || map.magFilter === NearestFilter ) {
+
+			console.warn( 'THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.' );
+
+			textureNode.biasNode = null;
+
+		}
+
 		return nodeObject( textureNode );
 
 	}

粤ICP备19079148号