How to use projective texturing or similar method to draw a grid on a texture

I’m trying to wrap around how to draw a grid system that I can nicely overlay on top of an existing background texture. For simplicity, let’s assume the this is a flat plane covered by a texture. How would I ‘project’ a rectangular grid on to it? The purpose here is to select each grid (ie change color), and move units around, and so forth?

I am able to render a a texture on to a quad in world space. Then, I render a grid on top of this space separately. But, the purpose here is defeated as I want to make this grid work even when it’s a height map, similar to how games like Civ5 has done it (I think).

Example where the grid is overlayed even as the height varied in Civ 5 -https://vignette.wikia.nocookie.net/civilization/images/1/13/Standard-Earth-map.jpg/revision/latest?cb=20101105112509?

This is relatively simple using a shader. Pass the world space vertex position from the vertex shader to the fragment shader, then render a grid in the fragment shader. For more information, see this link: http://www.madebyevan.com/shaders/grid/