Material with a opacity map - strange white outlines

I have a problem with a material which uses a texture for it’s opacity map. I made a simple example and this the result (THERE IS A WHITE OUTLINE AROUND THE CIRCLE WHICH SHOULDN’T BE THERE):

There are two planes. One for the floor:

        let mat = new pc.StandardMaterial();
        mat.diffuse.set(0, 0, 0);
        mat.emissive.set(0.75, 1, 1);
        mat.useLighting = false;

        let floor = new pc.Entity();
        floor.addComponent("mode", {
            type: "plane",
            material: mat
        floor.setLocalScale(4, 1, 4);

And one for the circle:

        mat = new pc.StandardMaterial();
        mat.blendType = pc.BLEND_NORMAL;
        mat.diffuse.set(0, 0, 0);
        mat.opacityMap = texture;
        mat.useLighting = false;

        let circle = new pc.Entity();
        circle.addComponent("model", {
            type: "plane",
            material: mat
        circle.setPosition(0, 0.015, 0);
        circle.setLocalScale(0.75, 1, 0.75);

The material for the circle use a texture as it’s opacity map. The texture is just a 64x64 black circle with smooth edge.


I do not use Playcanvas Editor. I use just the engine. If I do the same inside the editor, the white outline around the circle will disappear.

I tried to download the material from the editor and load it as an asset and use it instead of my own coded material, but the result is exactly the same.

This the result from the editor (as you can see there isn’t the white outline around the circle):

Does anybody know why there is a white outline around the circle? Thanks.

it may be the model itself, see if that ring is not flat then let me know.

The model is just a plane. The circle is drawn by the material.

Can you share your engine repo for people to look at please?

wait, is around the circle transparent? if not, then that white exists in the image itself.

Hi Yaustar,

here is the repo: It’s written in Typescript but the example is super simple.

Running build is here:

It seems to me that pixels in the source texture with alpha < 1 is blended with white color. But why?

Currently looking at this. I’m in the Editor with the texture from the GitHub repo (thanks for that!) and I get the same white outline:

Edit: Ignore me, I was using the wrong diffuse texture.

Okay, managed to replicated this in the Editor

It’s related to the canvas and clear colour of the camera. Still looking at the fix.

Thank you for the efforts.
How did you manage to reproduce that in the Editor?

I enabled the transparent canvas and changed the background colour of the body to white on the HTML document. We had a similar issue with another project where something similar happened. I also saw in Spector.js when I had transparent canvas enabled, this was rendered:

Which meant that the background colour of the HTML was leaking through.

The fix is to change your app creation to the following:

        // Create the app and start the update loop
        let canvas = document.getElementById(canvasID) as HTMLCanvasElement;
        let app = new pc.Application(canvas, {
            graphicsDeviceOptions: {
                alpha: false

1 Like

Thank you very much.

For reference, this is because canvas’ are transparent by default but PlayCanvas Editor options have it disabled by default and we have a darker body background colour which makes these issues less obvious.