Drawing lines in three.js using CanvasRenderer makes smoother lines than WebGLRenderer

半世苍凉 提交于 2019-12-06 06:11:45

I have been looking at the same problem, and it appears to be that the CanvasRenderer in Three.js makes use of CanvasRenderingContext2D, which does not use WebGL at all. All line-projections are done in software, and then the output is rendered as 2D lines using a regular 2D canvas. As painting is done in software, your browser will more likely be able to handle stroking with antialias.

In my experience, antialias for GL_LINES in WebGL is not widely supported right now, which explains the difference. Antialias only seems to work for triangles. The only workaround is to render to an FBO that is at a higher resolution than your screen, and then perform the antialias yourself.

Hopefully this will be better in the future as I feel that rendering smooth lines in WebGL should be a default feature for all browsers and machines.

AnkitRox
renderer = new THREE.WebGLRenderer({antialias: true});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!