three.js渲染到纹理alpha不工作

时间:2015-03-18 02:57:57

标签: 3d three.js alpha render-to-texture

我正在尝试使用alpha渲染到纹理,并在场景顶部渲染该纹理。纹理的背景虽然不透明,但在场景上渲染了清晰的颜色。

我用alpha:true创建了渲染器, 清晰的颜色有alpha 0, 纹理的格式是RGBA

我错过了什么?

//creating the texture
rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, 
    window.innerHeight, { minFilter: THREE.LinearFilter, 
    magFilter: THREE.NearestFilter, format: THREE.RGBAFormat } );

//creating renderer
renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.autoClear = false;

//textured quad
var quad = new THREE.PlaneBufferGeometry(camSize,camSize/aspect);
var mat = new THREE.MeshBasicMaterial({map:rtTexture,
    depthWrite:false, depthTest: false});
var quadOb = new THREE.Mesh(quad, mat);

//rendering
renderer.setClearColor(0x000000, 0);
renderer.render(sceneTorus, camera, rtTexture, true);
renderer.render(sceneTet, cameraRTT, null, true);
renderer.render(sceneQuad, cameraRTT, null, false);

1 个答案:

答案 0 :(得分:0)

quadOb.material.transparent = true;