Closed xiaoiver closed 1 month ago
目前 WebGL2 下支持 MSAA 的方式可以参考这个例子:首先关闭 antialias,在创建 pipeline 和 renderTarget 时指定 sampleCount。但 WebGL1 就没办法使用了。
如果一定要开启 antialias,并应用上述方式在 WebGL2 下就会报错: https://stackoverflow.com/questions/47934444/webgl-framebuffer-multisampling https://discourse.threejs.org/t/why-is-a-custom-fbo-not-antialiased/1329
解决办法有两个:
我想了下还是使用第二种方式,WebGL 1/2 都透传 antialias
。
修改方式如下,在创建 RenderPass 时,如果 colorResolveTo
仅有一个且是直接输出到屏幕的,就跳过 FBO 绑定以及后续的 blit:
const renderPass = device.createRenderPass({
colorAttachment: [renderTarget],
colorResolveTo: [onscreenTexture],
colorClearColor: [TransparentWhite],
});
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
I thought about it and used the second method. WebGL 1/2 transparently transmits
antialias
. The modification is as follows. When creating RenderPass, if there is only onecolorResolveTo
and it is output directly to the screen, the FBO binding and subsequent blit will be skipped:
const renderPass = device.createRenderPass({
colorAttachment: [renderTarget],
colorResolveTo: [onscreenTexture],
colorClearColor: [TransparentWhite],
});
现在会透传
antialias
属性: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#antialias https://stackoverflow.com/questions/50255282/webgl2-has-anti-alias-automatically-built-in但 WebGL2 下报错,WebGL1 正常:
https://github.com/antvis/L7/pull/2416/