I've implemented cascading shadow maps, and they by and large are looking great. As per usual, I'm rendering my depth passes using the back faces of the occluders.

Now, I've got a shadow casting terrain, and I see a fair amount of shadow acne on some of the back faces. Specifically, I'm seeing shadow acne on triangles for which at least one vertex normal is facing the light, and the other vertex normal(s) face away. E.g., triangles which are partially illuminated, and partially shadowed. Triangles where the varying normal is interpolated across illumination boundaries.

I've experimented with polygon offset to alleviate this, but frankly that's a little akward, since with an offset large enough to fix the problem, small objects begin to show acne on their illuminated faces. So that's not really a tenable solution.

I was thinking about best approaches to solve this, and realized that there's a pretty simple solution, and I was hoping somebody here could help me with it.

First: shadowed triangles are by definition facing away from the light.

Second: triangles with acne are partially facing and partially facing away from the light, owing to the interpolation of their vertex normals.

So it occurred to me that if the triangle's normal ( as opposed to vertex normal ) faces away from the light, I could zero out illumination all together. E.g., in the fragment shader, in pseudocode:

Code :float illumination = ... if ( triangle faces away from light ) illumination = 0;

The trouble is, I don't know the best way to get the actual triangle normal in my shaders. I know that I could pass triangle normals as vertex attributes ( or as gl_SecondaryColor ) but I'm already pushing my little GPU pretty hard, and was hoping there might be some uniform or attribute already available to GLSL that gives me the triangle normal. Or perhaps there's some way to determine the triangle normal in the vertex ( or fragment ) shader from other data.

If I could simply knock illumination to zero for triangles facing away from the light, my shadow acne woes would dissapear completely. Sure, I'd get a hard boundary between illuminated fragments and shadowed, but correct shadowing does that, anyway.

Here's a screenshot of my terrain showing the shadow acne. I've bumped up the specular to make it a little more obvious...

And here's another pic for detail: