简体   繁体   中英

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

I'm currently using the SSAO shader provided in the Three.js examples . It works perfectly on most of my machines aside from my MacBook Pro Retina. The MBP rendered SSAO perfectly until a few weeks ago (potentially after a firmware upgrade on the MBP).

As it stands, the MBP renders SSAO scenes with a huge amount of flickering artefacts all over the screen, like so:

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.

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).

If I remove the SSAO effect then the scene renders perfectly.

Any ideas?

I think you need to take into account the devicePixelRatio. Take a look at this example 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. 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.

I had the exact same problem on a non-retina MacBook Pro, so it seems to be a bug in the NVidia graphics driver. One thing that seems to influence the behavior is the material blending. I get better results with the depthmaterial blending set to THREE.NoBlending:

// 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上完美运行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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