sd805 / l4d2vr

Left 4 Dead 2 VR mod
369 stars 35 forks source link

Portal 2 compatibility? Need help with port #87

Open Gistix opened 1 year ago

Gistix commented 1 year ago

I'm trying to port this over to Portal 2, I'm working on getting the rendering working however I'm getting this:

image (It renders the game in a very small size inside the window, the entire window is sent to OpenVR)

I have aligned most of the classes based on Portal's VMT tables and disabled all hooks except "dRenderView" (so I can test and get stereo rendering working), I haven't forked yet but I'm planning to once it's in a playable state.

Sharkgamedev commented 1 year ago

Hey bro! The author as well as many talented people are present in the Flat2VRDiscord server where you might get better answers to your questions! I can shoot you an invite if you'd like!

Gistix commented 1 year ago

Hey bro! The author as well as many talented people are present in the Flat2VRDiscord server where you might get better answers to your questions! I can shoot you an invite if you'd like!

I'm already in the server, but I'll send an message there too just in case, thanks!

Gistix commented 1 year ago

I got it to render to the headset directly (instead of working like a virtual cinema). However its only rendering the UI and it seems to not be clearing the RT since the reticle colors bleed to white with time. I suppose the rendering order described in "dPushRenderTargetAndViewport" (PopRenderTargetAndViewport -> IsSplitScreen -> PrePushRenderTarget -> PushRenderTargetAndViewport) isn't the same for Portal 2 because of the portal rendering.

Here's how it looks like with the respective value of m_PushHUDStep:

dPopRenderTargetAndViewport: -999
dIsSplitScreen: 0
dIsSplitScreen: 1
dIsSplitScreen: -999
dIsSplitScreen: -999
dIsSplitScreen: -999
dIsSplitScreen: -999
dPushRenderTargetAndViewport: -999
dPopRenderTargetAndViewport: -999
dPushRenderTargetAndViewport: 0
dPopRenderTargetAndViewport: -999
dPopRenderTargetAndViewport: 0
dPopRenderTargetAndViewport: 0
dIsSplitScreen: 0
dPrePushRenderTarget: 1
dPopRenderTargetAndViewport: 2
dPrePushRenderTarget: 0
dPrePushRenderTarget: -999
dPopRenderTargetAndViewport: -999
dPushRenderTargetAndViewport: 0
dPushRenderTargetAndViewport: -999
sd805 commented 1 year ago

Yeah my method for finding the GUI texture is definitely jank, so I wouldn't expect it to work on other Source games. You'll have to find when PushRenderTargetAndViewport gets called with the GUI texture (inside of the RenderView function). A better solution I think would be to either do a mid-function hook at the point PushRenderTargetAndViewport gets called, or maybe you can just call pTexture->GetName() in the hook to find out when the GUI texture gets passed. Can't remember if I tried that.

Gistix commented 1 year ago

I have got it working, this video is a almost a month old and I have already fixed portaling angle (while breaking roomscale movement...)

So the UI is rendered to a texture as well? I have hooked DrawSelf to make the crosshair better indicate where portals are being aimed at and I'm having an issue where the UI is not being rendered in the entire screen (its being cut-off in a region the same size as the game's resolution)