That could be very difficult, depending on how you do it. If you want the light to simply cut off, why not just do it on the CPU? I mean if you really want to do that with shaders (and if I understand what you want to do, it’s not necessary and will make things more complicated) then I suppose you could generate a texture on the CPU that shows the game where The highest block is at. So you could generate the texture so that the top layer of blocks would be red, all other blocks would be green and air would be blue or something. Then, in the shader sample the block reference texture and, if the pixel is red, calculate the lighting for it. If it’s green make it black, if it’s blue just pass through. It would create a straight cut off, but this could be done much easier on the CPU.
Edit: I forgot what the pic was. That’s a point light, not a directional light. But point light or directional light, it would still be pretty much the exact same method I just explained. Of course I just thought of it off the top of my head, so there are probably some better ways.