gpt4 book ai didi

javascript - Three.js 试图添加 alphaMap

转载 作者:行者123 更新时间:2023-12-01 16:21:40 24 4
gpt4 key购买 nike

我正在尝试从两个 jpeg 文件创建云纹理。一个是透明度,另一个是颜色/可见纹理。 three.js 文档在一定程度上有帮助,但缺乏实际实现。因此,虽然我知道 alphaMap 存在,但我不确定这是否是实现它的方法。此代码似乎无法正常工作。纹理是颜色层,而 alpha 是剪贴蒙版。 alpha 蒙版对自身有效,但不会剪切纹理层。

// add clouds
function addClouds(){
loadText.innerText = "Adding Atmosphere";
var cloudsTexture = loader.load( "img/earthcloudmap.jpg" ),
cloudsAlpha = loader.load( "img/earthcloudmaptrans.jpg" ),
materialClouds = new THREE.MeshPhongMaterial( {
map: cloudsTexture,
alphaMap : cloudsAlpha,
transparent : true,
depthWrite : false
} );
meshClouds = new THREE.Mesh(spGeo, materialClouds);
meshClouds.scale.set(1.015, 1.015, 1.015);
scene.add(meshClouds);
}

最佳答案

我觉得代码没问题

alpha jpg 文件里面有什么?

考虑到这一点

.alphaMap

The alpha map is a grayscale texture that controls the opacity across the surface (black: fully transparent; white: fully opaque). Default is null. Only the color of the texture is used, ignoring the alpha channel if one exists. For RGB and RGBA textures, the WebGL renderer will use the green channel when sampling this texture due to the extra bit of precision provided for green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and luminance/alpha textures will also still work as expected.

doc

关于javascript - Three.js 试图添加 alphaMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36509947/

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