alienbreed3d2
alienbreed3d2 copied to clipboard
Floor seems to swim in fullscreen mode
When moving forward and backwards in fullscreen mode it looks like as if floor and walls are moving 'disconnected', especially at the distance.
This is likely due to a slight FOV mismatch between the floor and wall rendering, introduced by 94dddbd As an experiment one could set FS_WIDTH back to 288 and see if the walls and floor now match.
The floor lines are being drawn by projecting the left screen edge to the floor texture, then stepping "right" in screenspace to teh start of the clipped line. If the left start is already off, all the rest of the line will be. And I think there's a 0.75 involved which may be the tangent (cosine?) of half the field of view (FoV). This code can be found here: https://github.com/mheyer32/alienbreed3d2/blob/main/ab3d2_source/hires.s#L8671
The water floor rendering code has a similar constant baked into it.
The walls use the rotated/projected map points computed here: (https://github.com/mheyer32/alienbreed3d2/blob/main/ab3d2_source/hires.s#L5346) and https://github.com/mheyer32/alienbreed3d2/blob/main/ab3d2_source/hires.s#L5346 (there's two functions, one that rotates all level points when onscreen-map rendering is on, the other rotates only visible points for regular rendering)
There's a multiplication of the projected X with 2/3 (which widens the FoV by 1.5; which I believe encodes the aspect ratio increase from going from 192 to 288 when switching from small screen to fullscreen.).
We could try what happens if we change that from 1/1.5 to 1/1.666.
Shall we keep this issue open for the "bobble wobble" ?
There is some other element to this. A similar thing happens in the vertical direction, as if perspective foreshorting in Y direction is different for wall and floor rendering.
I have verified this finding, somewhat by accident. I created a new texture (which has other issues) that happens to have a very clearly delineated bottom edge. Using it in a large zone reveals that at 2/3 screen size, the perspective for the floor and walls are a reasonable match. However, switching to fullscreen, it's as if the vanishing point for the floor is on a slightly higher horizon:
Note the bottom edge of the wall here:
And again here:
There's another location in the code where a 4/3 crops up in floor rendering when switching to FS mode. I think this may be another place we need to change the multiplier.
I did experiment but it seems that wasn't the multiplier I was looking for.
It’s unclear to me if the wall doesn’t match the floor or if the floor doesn’t match the walls. It could be a bug in either rendering routines.
It might actually be a problem with the wall renderings. Does the same issue apply to ceilings meeting the walls?
That's a fair suggestion. I think I'll fork my mod repo and start building levels to solely test such things.
I can see the need for checkerboard wall and floor textures imminently.
Actually the original swimming problem, or something very much like it seems to still be happening when you use sidestepping and is not present at 2/3 size.
I have made a test level to help debug these types of issues. See: https://youtu.be/ZbpF36GXtfM
Other things noticed from this are the generally sloppy sampling, which we already knew about, and the fact that the floor textures appear backwards, which I did not know about. I wonder if that's a bug.
An update on the "bobble wobble" aspect. Careful frame by frame investigation of the walking behaviour in the new test levels reveals that the issue is caused by the fact that the flats (floors and ceilings) have no reaction to the left/right walking offset and only the vertical component. This is particularly apparent if you switch to keyboard mode, centre the view vertically and then backpedal into the wall. The floor perspective changes only as a function of your vertical bobble, whereas the walls react to both the vertical and the horizontal component.
Try changing the lines that add xwoboff here: https://github.com/mheyer32/alienbreed3d2/blob/main/ab3d2_source/hires.s#L7496
I will. I've been a bit snowed under lately, hence the lack of useful output!
https://github.com/mheyer32/alienbreed3d2/blob/main/ab3d2_source/hires.s#L3858
takes the current "xwobble" value and translates that into a delta vector (xwobxoff, xwobzoff) in the X/Z floor plane, using the player's viewing vector (PLR1_cosval, PLR1_sinval). The effect we see on screen almost looks like x and z are swapped and/or their sign is not correct. Its also possible the floor drawing routine is broken (as evidenced by the mirrored texture) and thus the wobble-delta may be correct, but has the wrong effect in the broken floor space.