简体   繁体   English

仅在MacBook Pro(Retina)上在Three.js中使用SSAO的伪像

[英]Artefacts with SSAO in Three.js only on MacBook Pro (Retina)

I'm currently using the SSAO shader provided in the Three.js examples . 我目前正在使用Three.js示例中提供SSAO着色器 It works perfectly on most of my machines aside from my MacBook Pro Retina. 除了MacBook Pro Retina之外,它在我的大多数计算机上都能完美运行。 The MBP rendered SSAO perfectly until a few weeks ago (potentially after a firmware upgrade on the MBP). MBP在数周之前(可能是在MBP上进行固件升级之后)完美地实现了SSAO。

As it stands, the MBP renders SSAO scenes with a huge amount of flickering artefacts all over the screen, like so: 就目前而言,MBP渲染SSAO场景,并在屏幕上显示出大量闪烁的伪像,如下所示:

Scene code here 场景代码在这里 在此处输入图片说明

Scene found here 在这里找到场景 在此处输入图片说明

This same code renders perfectly on other machines. 相同的代码可以在其他计算机上完美呈现。 I have seen this problem on other MBPs so I'm confident that it's not a single issue. 我已经在其他MBP上看到了此问题,因此我相信这不是一个单一的问题。

Aside from the firmware update, I've not changed anything on this MBP between it working and the artefacts appearing (the code is the same). 除了固件更新之外,在此MBP正常工作和出现的伪像之间,我没有进行任何更改(代码相同)。

If I remove the SSAO effect then the scene renders perfectly. 如果删除SSAO效果,则场景将完美呈现。

Any ideas? 有任何想法吗?

I think you need to take into account the devicePixelRatio. 我认为您需要考虑devicePixelRatio。 Take a look at this example http://uihacker.blogspot.gr/2013/03/javascript-antialias-post-processing.html 请看以下示例http://uihacker.blogspot.gr/2013/03/javascript-antialias-post-processing.html

The fact that this is happening on all browsers on the Retina Macbook, but appears works on other devices (looks fine on the Chromebook Pixel) suggests that this may be a driver bug on OSX. 这在Retina Macbook的所有浏览器上都发生了,但在其他设备上也可以显示(在Chromebook Pixel上看起来还不错),这一事实表明这可能是OSX上的驱动程序错误。 There may be a way to work around it in WebGL, but I would recommend filing a bug report with Apple at the very least. WebGL中可能有解决此问题的方法,但我建议至少向Apple提交错误报告

I had the exact same problem on a non-retina MacBook Pro, so it seems to be a bug in the NVidia graphics driver. 我在非视网膜MacBook Pro上遇到了完全相同的问题,因此似乎是NVidia图形驱动程序中的错误。 One thing that seems to influence the behavior is the material blending. 似乎影响行为的一件事是材料混合。 I get better results with the depthmaterial blending set to THREE.NoBlending: 将depthmaterial混合设置为THREE可获得更好的结果。

// depth
var depthShader = THREE.ShaderLib[ "depthRGBA" ];
var depthUniforms = THREE.UniformsUtils.clone( depthShader.uniforms );

depthMaterial = new THREE.ShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms } );
depthMaterial.blending = THREE.NoBlending; //add this

Also the near plane setting of the camera seemingly had effect on the rendering. 相机的近平面设置似乎也对渲染产生影响。

我通过将相机对象的“ near”属性更改为大于1的值来解决此问题。仍不确定为什么可以解决此问题,但SSAO现在可以在Retina MacBook上完美运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM