Bug in Skymaterial with SSAO2 in 5.0.0 artifact

Hi!

If you move camera, bad z-fighting will occur in the skymaterial:
https://playground.babylonjs.com/#7D2QDD#30

With 4.2.0 this bug won’t occur, it can be verified in that playground.

adding @julien-moreau and @CraigFeldspar

@CraigFeldspar it looks like the normal RTT of the sky is not correct, do you confirm?
image

The blue face should be green no?

@julien-moreau yep totally. Is the determinant of the world matrix somehow negative ?

Actually no, the normal information is totally correct since the skybox is oriented outwards. If you set backfaceCulling to false, mesh doesn’t render at all.

Z-fighting is a side effect to the fact that indeed we try to render SSAO on a very far mesh wrongly oriented. SSAO2 should actually render it totally black.

@JSa In your case you should not have SSAO2 render on your skybox. Please use skyMaterial.disableDepthWrite = true; to disregard SSAO on the material. Z-fighting should disappear

1 Like

Great solution, thanks!