I have a few different layers I want to combine into a single texture at runtime.
The pictures are simple png’s with transparent background.
private async addStuff() {
const red: THREE.CanvasTexture = await this.loadTexture('red.png');
const blue: THREE.CanvasTexture = await this.loadTexture('blue.png');
this._renderer.copyTextureToTexture(new THREE.Vector2(0, 0), red, blue);
this.addMesh(blue);
}
private async loadTexture(url: string) {
const bitmap = await this._imageBitmapLoader.loadAsync(url);
return new THREE.CanvasTexture(bitmap);
}
private addMesh(tex: THREE.Texture) {
const geo = new THREE.PlaneGeometry(1024, 1024);
const mat = new THREE.MeshBasicMaterial({ map: tex, transparent: true });
const mesh = new THREE.Mesh(geo, mat);
this._scene.add(mesh);
}
But only the red parts are visible in the ‘blue’ texture after this operation, seems like transparency is lost.
If I just put the separate textures on different overlapping tiles without doing copyTextureToTexture, everythings works as expected.
Anyone have any ideas on how I can solve this?