"the distance from a pixel in the center of the screen to the floor is infinite" What?
This makes sense when you assume the ceiling or floor is not at the same height as your camera. The exact center of the screen would be the point where the ceiling or wall touch the depth axis (e.g. 'Z'), but they don't, so the distance where the screen center meets the floor is... infinitely far away.
But there is no vertical center of the screen if you have an even number of pixels in the vertical dimension... not sure why the guy brings that up at all.
If his explanation for some of the things are confusing, try to figure it out yourself.
"You can also precalculate a lookup table for this instead, since there are only h / 2 possible values (one half of the screen in vertical direction)."
This is true, if he means the difference of distance (e.g. Z coordinates if Z is your depth axis) from one horizontal row of the screen to the next, or easier for later use, the difference to the bottom row, i.e. if you assume you would draw your floor completely from bottom row of your screen to the "center" row, each next row will be a bit further away. And since this sort of rendering has the restriction that you cannot look up/down and thus all floor / ceiling planes are parallel to your viewing direction, you have constant-height all over e.g. a floor plane. So you can make a table for each row from bottom to center, holding the difference in depth from bottom row. When rendering, you have to add those to e.g. the actual depth value of your bottom row which you calculate based on current camera height. So, you quickly have the real current depth values for each row.
You also need to rotate your floor plane based on camera angle. Then, if you go row by row, e.g. from bottom to center for the floor, imagine each row is layed on the rotated floor plane, at a start and end positions (first and last pixel of current row) which you determine with the camera position on the floor plane, and the rotation. So to say, actually you rotate those points about the inverse camera angle, not the floor itself.
Then when you move along the pixel row, from first to last pixel, you can compute where on the floor plane the current pixel would "hit", and thus compute the current texture index (assuming you have some grid specifying what texture some "cell" of floor has) and texture coordinates.
If you draw sketches of that on paper, you'll see how this works I hope, I can't draw anything here right now.
Hope this makes sense ^^
UnshavenBastardMember Since 08 Nov 2001
Offline Last Active Jul 03 2016 07:32 AM