Infinite ground plane using Background shader

I had an idea to create an infinite ground plane using the background and sky shader. It sort of works but there are still some issues. Im going to post the Blend file here so that maybe someone can see what Im doing wrong.

What it does.
I take the generated mapping for the background / world and I test if z=less than 0. Basically I use the results of this test to select either a straightforward Sky shader for anything above z=0 or , for z= less than 0 it outputs a ground shader.
So far so good. With a noise generating the ground texture and some noodling to change the size factor for distance (that bit is not right in the blend) it gives quite a reasonable result.

Ive included a cube and a plane so that the result can be visualised along with geometry. Obviously the infinite ground plane wont catch shadows which is why the textured ground plane ( which is alpha blended to the infinite plane) is there. So basically it gives a real horizon line using the infinite ground plane and I can control its texture and brightness independently from the sky shader. So far so good. BUT…

When replacing the noise shader with say a checker texture it is immediately apparent that the ground plane is still operating with a shperical projection. ie it doesnt map the checker texture flat across x,y,0 but is mapped to the bottom half of the infinite sphere. Ive tried restricting the z to 0 for the lower part of the mapping but I just cant find a way to get a checker to map flat across the ground plane. I can squeeze it by increasing the z size using mapping node but it seems very fudged solution. Does the background enforce a spherical mapping somehow and how can his be over ridden if we want to create a plane with the background shader? That is the bit I am stumped at.


Infinite_ground_background.blend (648 KB)