Can't alter offset/repeat of texture used as alphaMap

那年仲夏 提交于 2019-12-12 05:48:56

问题


demo:

https://dl.dropboxusercontent.com/u/123374/so-pages/20160601/index.html

the alphaTexture is having it's offset altered during each render. as a "map" property it changes, but as an "alphaMap" it does not change. the 2nd mesh's alphaMap

relevant code from demo link:

var colorTexture = new THREE.TextureLoader().load('blue.png')
  , alphaTexture = new THREE.TextureLoader().load('alpha.png')
  , offset = 0
  , colorFill = new THREE.Mesh(
        new THREE.Geometry(),
        new THREE.MeshPhongMaterial({
            map:      colorTexture,
            alphaMap: alphaTexture,
            side:     THREE.DoubleSide,
            shading:  THREE.FlatShading
        })
    )

function render() {
    requestAnimationFrame(render)

    offset += .01
    alphaTexture.offset.x = Math.sin(offset)
    renderer.render(scene, camera)
}

render()

expected:

the transparent part of the object would shift as the offset of the alphaTexture changes.

actual:

transparent part stays fixed on the material. However, if I edit the offset of the texture set to the map property (instead of alphaMap) it * is * able to shift, which seems like inconsistent behavior to me.


回答1:


What you are seeing is a current "feature" of three.js: only one offset/repeat pair is allowed per mesh. mesh.map has priority.

For more info, see https://stackoverflow.com/a/14372235/1461008

This may be changed in the future to allow separate offset/repeat settings per texture or per material property.

three.js r.84




回答2:


I tried commenting out the USE_ALPHAMAP with the latest version(82) but it didn't work. However, changing the vUv to vUv2 in the alpha_fragment chunk worked.

Jim



来源:https://stackoverflow.com/questions/37579923/cant-alter-offset-repeat-of-texture-used-as-alphamap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!