Skip to content

Instantly share code, notes, and snippets.

@henrytriplette
Last active July 5, 2016 13:27
Show Gist options
  • Save henrytriplette/17626e5a8a9d3301e1455639839f376d to your computer and use it in GitHub Desktop.
Save henrytriplette/17626e5a8a9d3301e1455639839f376d to your computer and use it in GitHub Desktop.
Three.js - Remove White Border on Alpha Renderer/AntiAliasing
/* -------------------------------------------------- */
// With Three.js transparent backgound enabled (alpha)//
// and model white textures on dark background //
// sometimes artifacts pop up on the edges. //
// To avoid that, slightly raise the clearcolor //
// opacity instead of disabilng antialias. //
/* -------------------------------------------------- */
// Standard Renderer
renderer = new THREE.WebGLRenderer( {
antialias: true,
alpha: true
});
// renderer.setClearColor(0x000000, 0);
renderer.setClearColor(0xFFFFFF, 0.5); // YAY!
// DPR calculation
var maxDPR = 2 // usually between 2 - 3
var dpr = Math.min(maxDPR, window.devicePixelRatio);
renderer.setPixelRatio(dpr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment