I'm using a low poly artstyle and I would like to add SSAO. Unfortunately I also like to interpolate my normals over low poly meshes, I feel like that makes my lighting looks nice. However this messes up the SSAO effect because the interpolated normal will cause self occlusion on the perfectly flat surface, darkening a surface that should get no ambient occlusion. Is this a known problem? Any trick to solve this?
#SSAO normal issue
9 messages · Page 1 of 1 (latest)
You can reconstruct the 'face-normals' from the depth buffer which will give you hard edges and avoid false occlusion.
Simplest way is normalize(cross(ddx(reconstructedWorldPosition), ddy(reconstructedWorldPosition)), but this can fail on thin surfaces and depth discontinuities, so there are some more expensive but better approaches: https://wickedengine.net/2019/09/improved-normal-reconstruction-from-depth/
You can also write out the triangle normal (using the same formula above) to a seperate rener target so you don't have to reconstruct from depth, which will also avoid the edge cases.
Indeed, works great but introduces edge cases
How would you compute the surface normal in the forward rendering pass?
in vertex shader I get per vertex normals which are then interpolated
oh I guess I could to the derivative trick in the fragment shader there? hopefully it won't introduce discontuinities
That worked with no artifacts, thank you so much!
Neat trick
Yep, computing in the fragment shader should work.
Otherwise you can also pass through a 2nd set of normals, but shouldn't be required.