diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 1819b8c17..fd49afa68 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -12,6 +12,7 @@ #ifdef HWRENDER #include "hw_glob.h" #include "hw_batching.h" +#include "hw_main.h" #include "../i_system.h" #include "../qs22j.h" @@ -387,14 +388,14 @@ static unsigned int HWR_MarkStateChanges(DrawCallInfo *current, DrawCallInfo *ne // check if a state change is required and flag it to stateChanges - if (current->shader != next->shader && cv_glshaders.value && gl_shadersavailable) + if (current->shader != next->shader && HWR_UseShader()) stateChanges |= SHADER_CHANGED; if (HWR_GetDrawCallTexture(current) != HWR_GetDrawCallTexture(next) || HWR_GetDrawCallBrightmap(current) != HWR_GetDrawCallBrightmap(next)) stateChanges |= TEXTURE_CHANGED; if (current->polyFlags != next->polyFlags) stateChanges |= POLYFLAGS_CHANGED; - if (cv_glshaders.value && gl_shadersavailable) + if (HWR_UseShader()) { if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba || currentSI->TintColor.rgba != nextSI->TintColor.rgba || @@ -418,7 +419,7 @@ static unsigned int HWR_MarkStateChanges(DrawCallInfo *current, DrawCallInfo *ne static void HWR_ExecuteStateChanges(unsigned int stateChanges, DrawCallInfo *dc) { - if ((stateChanges & SHADER_CHANGED) && cv_glshaders.value && gl_shadersavailable) + if ((stateChanges & SHADER_CHANGED) && HWR_UseShader()) { GL_SetShader(dc->shader); ps_hw_numshaders++; @@ -477,7 +478,7 @@ void HWR_RenderBatches(void) // sort the draw calls ps_hw_batchsorttime = I_GetPreciseTime(); - if (cv_glshaders.value && gl_shadersavailable) + if (HWR_UseShader()) qs22j(drawCallOrder, cst->drawCallsSize, sizeof(UINT32), compareDrawCalls); else qs22j(drawCallOrder, cst->drawCallsSize, sizeof(UINT32), compareDrawCallsNoShaders); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5583029e4..b49df1e2c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -122,6 +122,10 @@ static angle_t gl_aimingangle; // Returns true if shaders can be used. boolean HWR_UseShader(void) { +#ifdef HAVE_VR + if (vr_started) + return gl_shadersavailable; +#endif return (cv_glshaders.value && gl_shadersavailable); } @@ -775,7 +779,7 @@ void HWR_RenderPlayerView(void) ClearColor.blue = 0.0f; ClearColor.alpha = 1.0f; - if (cv_glshaders.value) + if (HWR_UseShader()) { GL_SetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime. diff --git a/src/p_user.c b/src/p_user.c index d7ef85571..818cfe8eb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3129,6 +3129,21 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam_rotate[num].value; camdist = FixedMul(cv_cam_dist[num].value, mapobjectscale); camheight = FixedMul(cv_cam_height[num].value, mapobjectscale); +#ifdef HAVE_VR + if (vr_started) + { + const fixed_t vr_camdist = FixedMul(160*FRACUNIT, mapobjectscale); + const fixed_t vr_camheight = FixedMul(50*FRACUNIT, mapobjectscale); + + // Match kart-public-vr's chase camera defaults in VR. Blankart's + // normal camera is higher and farther back, which makes the headset + // view start too high and pitched down. + if (camdist > vr_camdist) + camdist = vr_camdist; + if (camheight > vr_camheight) + camheight = vr_camheight; + } +#endif if (leveltime > introtime) { diff --git a/src/vr/vr_main.c b/src/vr/vr_main.c index d3e8b87ca..9e9ae3d77 100644 --- a/src/vr/vr_main.c +++ b/src/vr/vr_main.c @@ -10,6 +10,10 @@ #include "../i_video.h" #include "../r_fps.h" #include "../v_video.h" +#ifdef HWRENDER +#include "../hardware/hw_glob.h" +#include "../hardware/hw_main.h" +#endif #include #include #include "../sdl/sdlmain.h" @@ -519,6 +523,12 @@ boolean VR_Init(void) vr_started = true; vr_enabled = true; +#ifdef HWRENDER + if (gl_shadersavailable) { + CONS_Printf("VR: Recompiling hardware shaders with OpenXR view uniforms.\n"); + HWR_CompileShaders(); + } +#endif CV_StealthSet(&cv_vidwait, "Off"); CV_StealthSetValue(&cv_fpscap, -1); CV_StealthSet(&cv_ticrate, "Compact"); @@ -550,6 +560,10 @@ void VR_Shutdown(void) vr_started = false; vr_enabled = false; vr_drawing_ui = false; +#ifdef HWRENDER + if (gl_shadersavailable) + HWR_CompileShaders(); +#endif displayRefreshRateExtensionEnabled = false; pfnEnumerateDisplayRefreshRatesFB = NULL; pfnGetDisplayRefreshRateFB = NULL;