gpt4 book ai didi

Three.js:我是否必须为每个纹理设置各向异性纹理过滤?

转载 作者:行者123 更新时间:2023-12-02 18:57:00 25 4
gpt4 key购买 nike

我必须为每个纹理设置各向异性纹理过滤吗?我认为如果您可以为 Material 甚至全局场景设置各向异性级别,那就太酷了。有什么想法吗?

maxA = renderer.getMaxAnisotropy();

var texture1 = THREE.ImageUtils.loadTexture('models/folder/m67/o1.jpg');
texture1.anisotropy = maxA;

var texture2 = THREE.ImageUtils.loadTexture('models/folder/m67/o2.jpg');
texture2.anisotropy = maxA;

var texture3 = THREE.ImageUtils.loadTexture('models/folder/m67/c1.jpg');
texture3.anisotropy = maxA;

var texture4 = THREE.ImageUtils.loadTexture('models/folder/m67/c2.jpg');
texture4.anisotropy = maxA;

var material = {
"logoprint": new THREE.MeshPhongMaterial({
map: texture1
}),
}

最佳答案

您可以将负载包装到一个函数中,imageutils 只是为您提供了另一个实用函数

function loadTexture( url ){
var tex = THREE.ImageUtils.loadTexture(url);
tex.anisotropy = MAXANISO;
return tex;
}

为了澄清这里发生的情况,以及如何处理 ImageUtils 折旧警告:

var tl = new THREE.TextureLoader();

//calling load on it immediately returns a THREE.Texture object
var myTexture = tl.load( 'name.jpg' );

//you can also pass a callback
function onTextureLoaded( tex ){

//tex.image contains data, because textureLoader updated it, before passing it to the callback
handleTexture( tex )...
}
var myTexture = tl.load( 'name.jpg' , onTextureLoaded );

// myTexture is now an instance of THREE.Texture
// myTexture.image contains no data

myTexture.aniso = ...; //texture is configured , but probably waiting for data

纹理对象本身拥有所有这些 3D 属性,例如环绕、映射类型和过滤。图像数据本身与此无关,无论您如何使用它,它都保持不变。当您在纹理加载器上调用 load 时,它会返回一个代理 - 对可以配置、操作并传递给其他要使用的对象(如 Material )的对象的引用。 Material 可以渲染空纹理。加载图像数据时,纹理会更新,下一帧将反射(reflect)这一点。

 var tl = new THREE.TextureLoader()

function myCustomLoad( url ){
var newTex = tl.load(url); //make the proxy
newTex.prop = ... ;//config
return newTex; //return configured texture, it will update itself
}

关于Three.js:我是否必须为每个纹理设置各向异性纹理过滤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35012926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com