7 hours ago, JoeJ said:
Maybe that's the key. As i have used the normal from triangle directly this often misaligned with neighboring triangles when shadowing.
Ah, i read you plan to do this as well. Let us know how it works out. Also try to render sphere carved out of something, so curvature has the other sign too...
Personally i did this with software rendering for a global illumination many views approach (tiny framebuffers, e.g. 8x8 or 16x16), so that's quite a different scenario.
I'm done with the implementation now. (at least rougly.)
Made a ton of screenshots to show the advantages (and some still existing issues) of this technique.
Now, after testing that technique i understand why you got artifacts/visible wireframes in your implementation. If your sampling resolution is too low, detailed geometry which occupies a single fragment can't be properly reconstructed. (Thus the reconstruction yields wrong results and you get unwanted shadowing.)
I have a similar issue here at the low 512x512 sampling resolution:
ShadowMap (4 cascades, each with 512x512 resolution):
However, if we up the resolution to 2k, the results are a whole lot better (the issue still persists, but is much less noticeable):
ShadowMap (4 cascades, each with 2048x2048 resolution):
There is basically no shadow acne in the distance (well, almost) and the peter-paning effect is kept to a minimum (as the bias value can kept very small due to the plane reconstruction)
Now, the issue is that shadow acne still exists but only on faces which are almost perpendicular to the sun/light vector:
You can see the view-space normals of the cascade in the lower left corner. The face which has shadow acne is almost perpendicular (the face is painted red in the normal buffer preview in the first screenshot). in the Second screenshot the wall is 100% perpendicular to the sun (the wall is not even visible in the normal buffer).
I'm not 100% sure what causes the shadow acne in this case. (Have to investigate further.)
So the remaining issues are:
-
corners of the geometry can experience self-shadowing (most noticeable at lower shadowmap resolutions)
-
Shadow acne on very steep (almost perpendicular) faces
Number 1 can be hopefully fixed by doing additional filtering on the edges of the geometry (the normals of each texel can be used to detect edges rather consistently.)
Number 2 ... no idea at the moment.
/Edit: Issue number 2 is probably bias related. Now that i reconstruct the depth/face normal i'll have to take that into account before applying the bias. (otherwise if you have an almost perpendicular wall from the suns perspective and then apply bias in the direction of the sun, the overall distance from the bias-corrected depth and the reconstructed depth is too small and you get shadow acne.)