I have a scene with a cube using meshphysicalmaterial. I need the scene background to be transparent. However doing so by using setClearColor’s alpha to 0, renders the scene very dark. Here is a comparison between transparent and non-transparent backgrounds:
As far as i understand this has to do with the fact that when the renderer draws the scene, it doesn’t draw it on top of a color. I tried setting a color on the mesh, and also playing around with the lighting, however i’m unable to recreate the same look as without the background.
Here’s the mesh settings:
const plastic = new THREE.MeshPhysicalMaterial({
color: 0x121212,
roughness: 1,
transparent:true,
opacity:0.7,
reflectivity: 1,
metalness:0,
ior: 1,
sheen: 1,
transmission: 1,
thickness: 0.1,
envMap: mapTexture,
envMapIntensity: 2,
clearcoat: 1,
iridescence: 1,
iridescenceIOR:1
});
Here’s the init with the renderer, camera, etc.
//basic init
const renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
const sceneA = new THREE.Scene({background: 0xff0000});
renderer.setClearColor( 0x121212, 0);
const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000 );
const light = new THREE.DirectionalLight(0xffffff, 10);
light.position.set(0, 5, 10);
const Alight = new THREE.AmbientLight( 0x121212,1 );