I have a renderer that displays some blobs, this works fine, but somehow I fail to make its background transparent. What’s odd is, that so far, the background is still white, covering everything underneath, but the blobs have some lowered opacity kind of showing what beneath them. But I want the background to be transparent.
// Create Renderer
const renderer = new WebGLRenderer({antialias: false, alpha: true})
renderer.setClearColor( 0x000000, 0 )
// Create Scene
const scene = new Scene()
// Create Camera
const camera = new Camera()
camera.position.z = 1
// Append Element to window
container.appendChild(renderer.domElement)
calculateShaderColors(rgbColors, colors)
createShader()
createBlob()
resize()
function calculateShaderColors(originalColors, convertedColors) {
originalColors.forEach((color) => {
convertedColors.push(new Vector3(color[0] / 255, color[1] / 255, color[2] / 255))
})
}
function resize() {
if ((Math.abs(windowWidth() - lastSizeW)) >= 10) {
renderer.setSize(windowWidth(), (windowHeight() * 2))
camera.aspect = windowWidth() / windowHeight() * 2
uniforms.u_resolution.value.x = windowWidth()
uniforms.u_resolution.value.y = windowWidth()
maxAnchorX = windowWidth() / 4
maxAnchorY = windowHeight() / 2.5
blobElements.forEach((blob) => {
blob.resize(windowWidth(), centered ? windowHeight() * 2 : windowHeight() * 3)
})
lastSizeW = windowWidth()
}
}
function createShader() {
geometry = new PlaneBufferGeometry(2, 2)
uniforms = {
u_time: {type: "f", value: 1.0},
u_resolution: {type: "v2", value: new Vector2(windowWidth(), windowWidth())},
u_mouse: {type: "v2", value: new Vector2()},
u_blobs: {type: "v3v", value: []},
u_colors: {"value": colors}
}
material = new ShaderMaterial({
uniforms: uniforms,
vertexShader: vertexShader,
transparent: true,
fragmentShader: fragmentShaderContent
})
mesh = new Mesh(geometry, material)
scene.add(mesh)
}
What it looks like - I don’t want the Blob to be transparent, but the background: