Using scn_frame.inverseViewProjectionTransform * position makes the grid less erratic and it looks like it aligns to the floor plane but it is still in the wrong place.
I am trying to render an infinite world floor grid, similar to this question.
My project is using SceneKit with Metal Shading Language but the concepts are no doubt similar between GLSL/HLSL.
Here is an example project where I attempt to render a plane as a full screen quad with the grid lines...