Fixed Skyboxes render from player's position rather than camera's

Status
Not open for further replies.

Kaysakado

Member
At least, that's what I think is going on here. Theoretically the cactus sector in the skybox should be lining up perfectly with the cactus in the in-game sector. And the top of the blue bricks should be flush with the bottom of the wood. With chasecam off it renders perfectly, but there are strange perspective issues in third person.
 

Attachments

  • srb20406.gif
    srb20406.gif
    3.6 MB · Views: 486
  • skyboxtest.zip
    1.8 KB · Views: 314
Last edited by a moderator:
I dunno Kays... Glancing at the source code, it looks like the skyboxes are correctly rendering from the camera's position rather than the player's in third person mode. Does the same issue occur in OpenGL by any chance? I wonder if it's just software renderer's awkward perspective quirks ruining things.

Relevant bit of code for offsetting viewx/viewy relative to skybox viewpoints for chase cam starts here in R_SkyboxFrame: https://github.com/STJr/SRB2/blob/SRB2_release_2.1.15/src/r_main.c#L926
 
Sorry for the double post; I raised the bricks to be flush with the top of the wood as in the attached PNGs. This shows that the X and Y are aligned correctly, it's just the Z that's off. I haven't been able to compile SRB2, but is it possible that instead of this:
Code:
viewz += thiscam->z / mh->skybox_scalez;
We need this:
Code:
viewz += (thiscam->z + thiscam->height>>1) / mh->skybox_scalez;
Some relevant code in R_SetupFrame: https://github.com/STJr/SRB2/blob/6d2d48f15205a5ea6aaabac0b09bfd7f7842e82a/src/r_main.c#L1080-L1096

And maybe even something like this, as I've noticed that if I shift the whole map down or up by 360 (and adjust the skybox thing angle to compensate) the z perspective gets even more fucked:
Code:
viewz += (thiscam->z + thiscam->height>>1 - skyboxmo[1]->z) / mh->skybox_scalez;

(Also, two things I'm curious about: Why does the skybox view point rely on angle for both viewz AND viewangle? Is there any reason skyboxmo[0]->z couldn't be used for viewz?
And is there a reason in R_SetupFrame that alt view uses 20*FRACUNIT when thiscam->height>>1 works out to 8*FRACUNIT for an unscaled chasecam?)

EDIT: I'm almost definitely sure the problem is not accounting for the camera height. In the attached GIF I raised the in-level sectors by 8 fracunits and the chasecam renders "correctly" (even though it shouldn't in this case). When I change scale, the new camera height isn't accounted for so the skybox viewz is too low! Not pictured: in first person, as you'd expect, the skybox viewz is "too high" and the skybox renders lower than the map (which is what should happen in this case).
 

Attachments

  • srb20006.png
    srb20006.png
    16.1 KB · Views: 381
  • srb20007.png
    srb20007.png
    20.7 KB · Views: 362
  • srb20408.gif
    srb20408.gif
    379.6 KB · Views: 408
Last edited:
Well now, that's interesting, I'll look into testing what happens if I add those missing height offsets for chasecam/awayviewmobj viewz to R_SkyboxFrame...

As for why thing z apparently affects the z position AND angle... I'm not sure, I think there was some sort of reasoning for using angle for z along the lines of being able to be positioned below the ground? I honestly have no idea though, it didn't make a lot of sense to me either at the time I found that fact out myself.

The differences in height offset for chasecam and alt view I can't answer at all, I know nothing as to why they do that. =V
 
Last edited:
Whoops, forgot to mention 2 months ago that I made a fix for this, which was later merged and should now be included with 2.1.16. Does the issue still occur now?
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top