But then you have a division of each coordinate. And this was more expensive than a memory lookup. So you might end up with a table as well. You have to test and optimize both approaches to be really sure.
I’m not sure why a division is necessary. When you send a ray out in a given direction through the screen, you can calculate its height in world space at distance z just by multiplication; and you can construct that ray entirely by multiplication and addition of values that are constant for the frame. So you can march a point out in increasing z along a ray pointing towards the bottom of the screen, then when it hits the ground, move it up the screen until it stops hitting the ground, then draw that line and start increasing z again. The perspective correction division just disappears completely.
I don’t disagree that you need to benchmark approaches to see if they will work, but it’s got to be interesting to consider if it’s possible to avoid allocating a buffer to store the height reached per column, right?
But then you have a division of each coordinate. And this was more expensive than a memory lookup. So you might end up with a table as well. You have to test and optimize both approaches to be really sure.