Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

White image is getting grey edges when rendered #14668

Closed
5 tasks done
ivan-i1 opened this issue Aug 8, 2018 · 4 comments
Closed
5 tasks done

White image is getting grey edges when rendered #14668

ivan-i1 opened this issue Aug 8, 2018 · 4 comments

Comments

@ivan-i1
Copy link

ivan-i1 commented Aug 8, 2018

White image is getting grey edges when rendered

I first noticed this grey-edge thing when using a white materials on custom meshes. I was blaming the geometries but then I tried to render a white image in the most straight-forward way I know without any special meshes and I got the grey edges. I also tried rendering a full opacity image (no antialias or anything else) and that one also got the grey edges. Is this known issue?

Below the white PNG image I used for testing.
snowflake

Here a screenshot of the codepen with the snowflake being rendered on a white background.
(Please note how the grey edges make the snowflake visible)
screen shot 2018-08-08 at 11 37 34 am

Three.js version
  • 87
Browser
  • Chrome
  • Firefox
  • Safari
OS
  • macOS
@WestLangley
Copy link
Collaborator

Please do not cross-post stackoverflow help question here.

You can try the forum if you want.

@ivan-i1
Copy link
Author

ivan-i1 commented Aug 8, 2018

Ok, let me rephrase and sorry in advance if I seem stubborn.

I have a perfectly white image.
Using the last ThreeJS release (95) and the 87 version for the example only (no additional libraries or anything).
I render this image using only ThreeJS in the path:
Image->Texture->Material->Render
The render has white background.

So there is no reason for other than white pixels to appear.
But they do.

I'm claiming here that this is a bug, are you already aware of it?

@mrdoob
Copy link
Owner

mrdoob commented Aug 9, 2018

Can you please post this in the forum instead?

@WestLangley
Copy link
Collaborator

Mipmapping is most likely the cause of your issue.

You can turn off mipmapping:

texture.generateMipmaps = false;
texture.magFilter = THREE.LinearFilter;
texture.minFilter = THREE.LinearFilter;

Alternatively, you can premultiply alpha on upload to the GPU, but that requires that you specify a custom blending function. Assuming you still want normal alpha blending, you would do this:

texture.premultiplyAlpha = true;

material = new THREE.MeshBasicMaterial( {
    map: texture,

    blending: THREE.CustomBlending,
    blendEquation: THREE.AddEquation,
    blendSrc: THREE.OneFactor,
    blendDst: THREE.OneMinusSrcAlphaFactor,
    blendSrcAlpha: THREE.OneFactor,
    blendDstAlpha: THREE.OneMinusSrcAlphaFactor,

    transparent: true
} );

See https://developer.nvidia.com/content/alpha-blending-pre-or-not-pre.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants