Im experimenting with rendering by trying to make a minecraft-like voxel engine. I want nice visuals, so I implemented basic shadow mapping. On a basic level it works, I do have shadows, and I have already accounted for shadow acne. But I am still encountering weird artifacts and problems which make the scene look rubbish.
This is what I had to begin with
I am guessing that the sawtooth shadow pattern on straight edges is basically a projection of the individual shadow map pixels, so I tried increasing the resolution of the shadow map to a massive 8192x8192 and it did indeed make the sawtooth much finer (though still perfectly visible)

I changed from GL_NEAREST to GL_LINEAR filtering and added Poisson sampling in my shader like this
void main()
{
float visibility = 0.6;
for (int i=0;i<4;i++){
visibility+=0.1*texture( depth_buffer_texture, vec3(shadowCoord.xy + poissonDisk[i]/14000.0,shadowCoord.z-0.0002));
}
fragColor = texture(texture_sampler, outTexCoord)*visibility;
}
(I also tried changing to sampler2DShadow but that did literally nothing)
the result looks better but still has some problems, namely the sawtooth is stiill visible both on the casting surface and on the shadow itself
This does look a lot better but I can still see the following problems:
- I have an 8192x8192 shadow map which does not seem reasonable (though I'm not sure, it does still run at a comfortable fps even without any optimisations at this point, so, maybe, in this case it is ok?)
- The shadow edges are still not smooth both on the casting surface and on the surface the shadow falls on
- As this is an 'infinite' voxel world, the light source, while using a constant ortho projection, has to follow the player arround, and when the source moves with the player the shadow edges move around and flicker in a most annoying way. With the large texture and smoothing it is almost ok but gets worse fast with a smaller texture size. I believe its called shadow swimming but could not find the proper way to fix this
- There is an annoying Moire-like pattern on the farther hill. While it is present without the shadows it is made considerably worse by them and I can't seem to find what its called and, therfore can't really search how to fix it
If anyone can help me fix these problems or even just point me in the right direction I would be very grateful. Thanks in advance!