javascript 我可以在 Firefox 上以编程方式启用 WebGL 抗锯齿吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23501703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 01:00:23  来源:igfitidea点击:

Can I programmatically enable WebGL antialiasing on Firefox?

javascriptfirefoxwebglantialiasing

提问by user3609340

For example, on a page like this one, in Safari 7 it's antialiased, but in Firefox 29 (OS X 10.9) it's not.

例如,一个页面上像这样的,在Safari 7它的抗锯齿,但在Firefox 29(OS X 10.9),它不是。

Firefox does seem to have the capability to antialias. If I set the about:config setting "webgl.msaa-force" to "true", then it is antialiased.

Firefox似乎确实具有抗锯齿功能。如果我将 about:config 设置“webgl.msaa-force”设置为“true”,则它是抗锯齿的。

Is there any way to make Firefox antialias for my particular webpage, without relying on the user to mess with their about:config?

有什么方法可以为我的特定网页制作 Firefox 抗锯齿,而无需依赖用户来弄乱他们的 about:config?

I'm using three.js, and it has an "antialias" flag, but it seems to only make a difference on Safari, not Firefox.

我使用的是three.js,它有一个“抗锯齿”标志,但它似乎只对Safari有影响,而不是Firefox。

采纳答案by gman

The short answer is "no".

最简洁的答案是不”。

It's up the browser whether or not to support anti aliasing. Many drivers crash with antialiasing under certain conditions so browsers often disable antialiasing on those machines.

是否支持抗锯齿取决于浏览器。许多驱动程序在某些情况下会因抗锯齿而崩溃,因此浏览器通常会在这些机器上禁用抗锯齿。

Note that the antialiasflag is trueby default. In other words the default for WebGL is to antialias though it's still up to the browser. Specifically setting antialiasto truecould at most act as a hint (hey, I really want antialiasing please) but I know of no browsers that use it as a hint. They generally turn antialiasing on if they can.

请注意,该antialias标志是true默认的。换句话说,WebGL 的默认设置是抗锯齿,尽管它仍然取决于浏览器。具体设置antialiastrue最多可以作为提示(嘿,我真的想要抗锯齿),但我知道没有浏览器使用它作为提示。如果可以,他们通常会打开抗锯齿。

On the other hand, setting antialiasto falsedoes specifically mean "do NOT antialias".

另一方面,设置antialiasfalse确实意味着“不要抗锯齿”。

You can try to do anti-aliasing yourself. For example you can render at a higher resolution and using CSS to display the canvas smaller in which case the browser will most likely bilinear interpolation when compositing your WebGL into the page. You could also render to a texture and then apply some kind of anti-aliasing filter to it when rendering it to the canvas.

您可以尝试自己进行抗锯齿。例如,您可以以更高的分辨率渲染并使用 CSS 将画布显示得更小,在这种情况下,浏览器在将 WebGL 合成到页面中时很可能会进行双线性插值。您还可以渲染到纹理,然后在将其渲染到画布时对其应用某种抗锯齿过滤器。