One way or another, with standard shadow mapping, all the objects which will be casting "dynamic" shadows in that spot light need to be in a shadow frustum of that shadow map. You can reduce the size of the frustum so that it more tightly fits the casters, and/or you can increase the resolution of the shadow map(s) or the number of shadow frustum. But you need to balance doing so against the shadow edge flickering you can get as as result.

That may be sufficient for you. There are many other shadow rendering techniques (some variations of simple shadow mapping that perform better filtering) that might be better for you depending on your requirements. For the absolute simplest increase in filtering quality, enable LINEAR filtering on the shadow map, which will (when using hardware depth testing) on some GPUs apply simple PCF.

One way or another, with standard shadow mapping, all the objects which will be casting "dynamic" shadows in that spot light need to be in a shadow frustum of that shadow map. You can reduce the size of the frustum so that it more tightly fits the casters, and/or you can increase the resolution of the shadow map(s) or the number of shadow frustum. But you need to balance doing so against the shadow edge flickering you can get as as result.

That may be sufficient for you. There are many other shadow rendering techniques (some variations of simple shadow mapping that perform better filtering) that might be better for you depending on your requirements. For the absolute simplest increase in filtering quality, enable LINEAR filtering on the shadow map, which will (when using hardware depth testing) on some GPUs apply simple PCF.

I did solved the problem of the blockiness and the "frustum" issue increasing the FOV of the perspective matrix of the light. Now I have a problem to dynamically select the FOV such as in the shadow map the object. Suppose to simplify I have a single bounding sphere whose sphere the "shadow camera" is looking at. I tried to modify the FOV using the formula: FOV = 2 * arctan(radius/distance) to give to glm:: perspective then and where distance is: distance = glm::distance(BBCentre, cameraPosition).

The problem is that if the distance becomes small, the effect I have is like a "zooming out". What's wrong? Thank you again!

The problem is that if the distance becomes small, the effect I have is like a "zooming out". What's wrong? Thank you again!

Not sure exactly what you mean, but a couple possibilities come to mind. Draw a picture with a big sphere, the eyepoint very close to the sphere, and the lines representing the edge of the frustum. Now ask yourself if that FOV is still described by 2*arctan(r/d)...

Also, in this case with such a large view frustum and your obj subtending such a large angle, your shadow map resolution is going to spread out pretty quickly with distance.

Not sure exactly what you mean, but a couple possibilities come to mind. Draw a picture with a big sphere, the eyepoint very close to the sphere, and the lines representing the edge of the frustum. Now ask yourself if that FOV is still described by 2*arctan(r/d)...

Also, in this case with such a large view frustum and your obj subtending such a large angle, your shadow map resolution is going to spread out pretty quickly with distance.

I mean that the object becomes smaller on screen, like I would expect with a larger FOV but without changing the distance. Regarding the 2*arctan thingy, isn't it trigonometry? r and d are perpendicular one another, so the angle to fit the sphere shouldn't always be that as long r and d are perpendicular?

(sorry for the way I calculated d, it should be asin instead of atan, but the issue is the same)

I mean that the object becomes smaller on screen, like I would expect with a larger FOV but without changing the distance.

That does seem odd. If you're fitting the shadow frustum to just that one object, then it shouldn't change size much if at all in that frustum.

Regarding the 2*arctan thingy, isn't it trigonometry?

If the bsphere around an object is sufficiently distant from the light, yes. Then if you consider the bsphere centered within the shadow frustum, it is touching the frustum roughly at its diameter. But up-close... not so much. This picture illustrates:

It's still trig, but not the same problem geometry as 2*arctan presumes.