Fog doesn't work on my terrain

I am making a 3d scene with opengl c++, and I applied a fog and it affects correctly my 3d models, but it doesn’t work on my terrain, as shown in the picture, does someone know what is going on?

Usually you do the fog calculation in the fragment shader based on the pixels distance from the camera. Are you doing that or something else?