0

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.

WestLangley
  • 102,557
  • 10
  • 276
  • 276
quinn
  • 5,508
  • 10
  • 34
  • 54
  • this might be related? https://github.com/mrdoob/three.js/pull/8278 – quinn Jun 02 '16 at 00:10
  • 1
    If you are not getting help, improve your question by making a simpler example with a single mesh and a single material. It is not clear what you expect to see. – WestLangley Jun 05 '16 at 18:13
  • @WestLangley thanks, I trimmed it down a bit and added expected vs actual – quinn Jun 05 '16 at 18:44

2 Answers2

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

Community
  • 1
  • 1
WestLangley
  • 102,557
  • 10
  • 276
  • 276
  • thanks. Is there a work-around that I could look into? or a dev branch i could use? – quinn Jun 05 '16 at 20:13
  • 1
    Not yet. You can write your own `ShaderMaterial`, or update the `alphaMap` itself if updates are infrequent -- or hack the library. – WestLangley Jun 05 '16 at 20:55
  • thanks! i'm gonna try to hack the lib. sounds easier than writing a shader. i'm going to start with where materials are instantiated and work my way down, if there is a better starting point let me know.. thank you! – quinn Jun 05 '16 at 21:58
  • 2
    Comment out offset/repeat in `uv_vertex.glsl` and hardwire offset/repeat in `alphamap_fragment.glsl`. – WestLangley Jun 05 '16 at 22:09
0

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

user3661557
  • 138
  • 12