[英]three.js render to texture alpha not working
I am trying to render to a texture with alpha and render that texture on top of a scene. 我正在尝试渲染为带有alpha的纹理,并在场景顶部渲染该纹理。 The texture's background is not transparent though, the clear color is rendered over the scene.
尽管纹理的背景不是透明的,但清晰的颜色会在场景上渲染。
I created the renderer with alpha:true, the clear color has alpha 0, And the texture's format is RGBA 我使用alpha:true创建了渲染器,透明色的alpha为0,纹理的格式为RGBA
What am I missing? 我想念什么?
//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);
quadOb.material.transparent = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.