Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an alphaMap is not providing transparency in my material

I am trying to create chainlink surface. I have 2 textures; a standard map which has the metallic look of the metal links with a white background (diffuse):

I also have an alpha map:

I am trying to apply both of these to a MeshBasicMaterial without luck:

var chainlinkMask = THREE.ImageUtils.loadTexture('textures/chainlink_Large-Panels_mask.png');
chainlinkMask.wrapS = THREE.RepeatWrapping;
chainlinkMask.wrapT = THREE.RepeatWrapping;
chainlinkMask.repeat.set( 2, 2 );

var chainlinkDiffuse = THREE.ImageUtils.loadTexture('textures/chainlink_Large-Panels_Diffuse.png');
chainlinkDiffuse.wrapS = THREE.RepeatWrapping;
chainlinkDiffuse.wrapT = THREE.RepeatWrapping;
chainlinkDiffuse.repeat.set( 2, 2 );

material.map = chainlinkMask;
material.alphaMap = chainlinkDiffuse;
material.transparency = true;
material.side = THREE.DoubleSide;

This gives me the following:

As you can see, the alpha map isn't being applied.

Why not?

Any help appreciated.

like image 395
Mike Avatar asked Oct 13 '25 12:10

Mike


2 Answers

Try setting the transparent parameter to true instead of transparency

material.transparent = true;
like image 129
Soufiane Lasri Avatar answered Oct 15 '25 03:10

Soufiane Lasri


If you are using an alpha map, use one of these two patterns when defining your material:

alphaMap: texture,
transparent: true,

or

alphaMap: texture,
alphaTest: 0.5, // if transparent is false
transparent: false,

Use the latter if possible, and avoid artifacts that can occur when transparent is true.

three.js r.85

like image 34
WestLangley Avatar answered Oct 15 '25 05:10

WestLangley