From 7c37bad4ace2ffe34956024a1086f1db21073af0 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 16 Feb 2023 22:09:25 +0000 Subject: [PATCH] Squashed commit of the following: commit 57ebeb79e204527bb42256ba0499fae2655dde04 Author: Simon Date: Thu Feb 16 22:07:38 2023 +0000 Fixed issue with FrameSetup being called in the wrong place this seemed to limit the correctly submitted frames to 60 fps! commit 16299b3f8a4417978d988fce62db9572a879a3f6 Author: Simon Date: Tue Feb 14 20:51:03 2023 +0000 Get floor height offset correct for each game commit fa74cf0559b00b2b3fe495bd63f3d2591c5666e4 Author: Simon Date: Tue Feb 14 20:37:29 2023 +0000 Clean exit on Pico & Quest and gold tier patron credit screen commit deb2c35988322a6e05f76f01fb867856b495b7a2 Author: Simon Date: Mon Feb 13 22:22:29 2023 +0000 Number of small changed - Hide crosshair if it isn't needed - Don't draw black bar when drawing FPS counter - added roll in to the weapon sprite - If drawing full screen mode always use orthographic projection commit f1a165add78e97ffde804c86a00eda984c9b1d16 Author: Simon Date: Mon Feb 13 21:44:42 2023 +0000 FInal changes to get MV rendering correctly commit 936f079db8e90756fe09fceae7b67a9c46d214cb Merge: 06a99dbaf f8c1f49e6 Author: Simon Date: Mon Feb 13 11:29:23 2023 +0000 Merge branch 'multiview' into direct-eye-buffers commit 06a99dbafbde961d2cd5ec1fb459e51a283da098 Author: Simon Date: Mon Feb 13 11:26:44 2023 +0000 Implementation using no additional frame buffers commit f8c1f49e6f7599bff4e779bc933f35ec9aa3cbf4 Author: Simon Date: Sun Feb 12 11:19:27 2023 +0000 Failed attempt at multiview --- .../common/platform/posix/nosdl/i_input.cpp | 3 +- source/common/platform/posix/nosdl/i_main.cpp | 3 +- source/common/rendering/gl/gl_framebuffer.cpp | 5 ++ source/common/rendering/gl/gl_postprocess.cpp | 14 +++++- .../common/rendering/gl/gl_renderbuffers.cpp | 15 ++++++ source/common/rendering/gl/gl_shader.cpp | 10 +++- source/common/rendering/gl/gl_stereo3d.cpp | 17 ------- .../hwrenderer/data/hw_renderstate.h | 12 ----- .../hwrenderer/data/hw_viewpointbuffer.cpp | 11 +++-- .../hwrenderer/data/hw_viewpointuniforms.h | 2 +- .../rendering/hwrenderer/data/hw_vrmodes.cpp | 46 +++++++++++++------ .../rendering/hwrenderer/data/hw_vrmodes.h | 5 +- .../postprocessing/hw_postprocess_cvars.cpp | 2 +- source/common/rendering/v_framebuffer.cpp | 5 ++ source/common/startscreen/endoom.cpp | 20 -------- source/core/gamecvars.cpp | 2 +- source/core/gamehud.cpp | 2 +- source/core/mainloop.cpp | 3 ++ source/core/rendering/hw_entrypoint.cpp | 10 ++-- source/core/rendering/scene/hw_drawinfo.cpp | 15 +++++- source/core/version.h | 2 +- source/games/blood/src/blood.cpp | 4 ++ source/games/blood/src/player.cpp | 13 ++++++ source/games/duke/src/player_d.cpp | 17 ++++++- source/games/duke/src/player_r.cpp | 17 ++++++- source/games/exhumed/src/exhumed.cpp | 6 ++- source/games/exhumed/src/player.cpp | 11 +++++ source/games/sw/src/game.cpp | 4 +- source/games/sw/src/player.cpp | 12 +++++ wadsrc/static/menudef.txt | 43 ++++++++++++++--- wadsrc/static/shaders/glsl/main.vp | 2 +- 31 files changed, 232 insertions(+), 101 deletions(-) diff --git a/source/common/platform/posix/nosdl/i_input.cpp b/source/common/platform/posix/nosdl/i_input.cpp index 45502b598..04dddb887 100644 --- a/source/common/platform/posix/nosdl/i_input.cpp +++ b/source/common/platform/posix/nosdl/i_input.cpp @@ -85,8 +85,7 @@ void I_StartTic () I_GetEvent (); } -void TBXR_FrameSetup(); + void I_StartFrame () { - TBXR_FrameSetup(); } diff --git a/source/common/platform/posix/nosdl/i_main.cpp b/source/common/platform/posix/nosdl/i_main.cpp index 845dbc024..56956c0e8 100644 --- a/source/common/platform/posix/nosdl/i_main.cpp +++ b/source/common/platform/posix/nosdl/i_main.cpp @@ -184,8 +184,7 @@ int raze_main (int argc, char **argv) const int result = GameMain(); #ifdef __ANDROID__ - usleep(500* 1000); - exit(0); + usleep(1000* 1000); #endif return result; diff --git a/source/common/rendering/gl/gl_framebuffer.cpp b/source/common/rendering/gl/gl_framebuffer.cpp index 01d2fd84b..423c35deb 100644 --- a/source/common/rendering/gl/gl_framebuffer.cpp +++ b/source/common/rendering/gl/gl_framebuffer.cpp @@ -75,6 +75,8 @@ extern bool vid_hdr_active; void DrawVersionString (); +void TBXR_prepareEyeBuffer(int eye ); + namespace OpenGLRenderer { FGLRenderer *GLRenderer; @@ -450,6 +452,7 @@ void OpenGLFrameBuffer::AmbientOccludeScene(float m5) void OpenGLFrameBuffer::FirstEye() { GLRenderer->mBuffers->CurrentEye() = 0; // always begin at zero, in case eye count changed + TBXR_prepareEyeBuffer(0); } void OpenGLFrameBuffer::NextEye(int eyecount) @@ -590,7 +593,9 @@ void OpenGLFrameBuffer::Draw2D() void OpenGLFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, const std::function &afterBloomDrawEndScene2D) { +#ifndef __MOBILE__ if (!swscene) GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture +#endif GLRenderer->PostProcessScene(fixedcm, flash, afterBloomDrawEndScene2D); } diff --git a/source/common/rendering/gl/gl_postprocess.cpp b/source/common/rendering/gl/gl_postprocess.cpp index 64ca85fad..628649be8 100644 --- a/source/common/rendering/gl/gl_postprocess.cpp +++ b/source/common/rendering/gl/gl_postprocess.cpp @@ -56,6 +56,11 @@ void FGLRenderer::RenderScreenQuad() void FGLRenderer::PostProcessScene(int fixedcm, float flash, const std::function &afterBloomDrawEndScene2D) { +#ifdef __MOBILE__ + if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D(); + return; +#endif + int sceneWidth = mBuffers->GetSceneWidth(); int sceneHeight = mBuffers->GetSceneHeight(); @@ -84,11 +89,15 @@ void FGLRenderer::AmbientOccludeScene(float m5) void FGLRenderer::BlurScene(float gameinfobluramount) { + if (gameinfobluramount == 0) + return; + int sceneWidth = mBuffers->GetSceneWidth(); int sceneHeight = mBuffers->GetSceneHeight(); GLPPRenderState renderstate(mBuffers); + screen->FirstEye(); auto vrmode = VRMode::GetVRMode(true); int eyeCount = vrmode->mEyeCount; for (int i = 0; i < eyeCount; ++i) @@ -112,17 +121,18 @@ void FGLRenderer::ClearTonemapPalette() void FGLRenderer::Flush() { auto vrmode = VRMode::GetVRMode(true); - if (vrmode->mEyeCount == 1) +/* if (vrmode->mEyeCount == 1) { CopyToBackbuffer(nullptr, true); } else + */ { + screen->FirstEye(); // Render 2D to eye textures int eyeCount = vrmode->mEyeCount; for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix) { - screen->RenderState()->SetEye(eye_ix); // tell render state which eye's 2D we are drawing screen->Draw2D(); if (eyeCount - eye_ix > 1) mBuffers->NextEye(eyeCount); diff --git a/source/common/rendering/gl/gl_renderbuffers.cpp b/source/common/rendering/gl/gl_renderbuffers.cpp index a335411ce..92f8e1513 100644 --- a/source/common/rendering/gl/gl_renderbuffers.cpp +++ b/source/common/rendering/gl/gl_renderbuffers.cpp @@ -36,6 +36,8 @@ EXTERN_CVAR(Int, gl_debug_level) CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +void TBXR_prepareEyeBuffer(int eye ); + namespace OpenGLRenderer { @@ -672,7 +674,9 @@ void FGLRenderBuffers::CreateShadowMap() void FGLRenderBuffers::BindSceneFB(bool sceneData) { +#ifndef __MOBILE__ glBindFramebuffer(GL_FRAMEBUFFER, sceneData ? mSceneDataFB.handle : mSceneFB.handle); +#endif } //========================================================================== @@ -754,7 +758,9 @@ void FGLRenderBuffers::BindCurrentTexture(int index, int filter, int wrap) void FGLRenderBuffers::BindCurrentFB() { +#ifndef __MOBILE__ mPipelineFB[mCurrentPipelineTexture].Bind(); +#endif } //========================================================================== @@ -765,8 +771,10 @@ void FGLRenderBuffers::BindCurrentFB() void FGLRenderBuffers::BindNextFB() { +#ifndef __MOBILE__ int out = (mCurrentPipelineTexture + 1) % NumPipelineTextures; mPipelineFB[out].Bind(); +#endif } //========================================================================== @@ -788,7 +796,9 @@ void FGLRenderBuffers::NextTexture() void FGLRenderBuffers::BindOutputFB() { +#ifndef __MOBILE__ glBindFramebuffer(GL_FRAMEBUFFER, 0); +#endif } //========================================================================== @@ -999,12 +1009,17 @@ void GLPPRenderState::PopGroup() int FGLRenderBuffers::NextEye(int eyeCount) { +#ifndef __MOBILE__ int nextEye = (mCurrentEye + 1) % eyeCount; if (nextEye == mCurrentEye) return mCurrentEye; BlitToEyeTexture(mCurrentEye); mCurrentEye = nextEye; BlitFromEyeTexture(mCurrentEye); return mCurrentEye; +#else + TBXR_prepareEyeBuffer(1); + return 1; +#endif } } // namespace OpenGLRenderer diff --git a/source/common/rendering/gl/gl_shader.cpp b/source/common/rendering/gl/gl_shader.cpp index 02f1e308d..22e97800a 100644 --- a/source/common/rendering/gl/gl_shader.cpp +++ b/source/common/rendering/gl/gl_shader.cpp @@ -226,7 +226,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * // This must match the HWViewpointUniforms struct layout(std140) uniform ViewpointUBO { - mat4 ProjectionMatrix; + mat4 ProjectionMatrix[NUM_VIEWS]; mat4 ViewMatrix; mat4 NormalViewMatrix; @@ -400,7 +400,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * if (!lightbuffertype) { #ifdef __MOBILE__ - vp_comb.Format("#version 310 es\n#define NO_CLIPDISTANCE_SUPPORT\n#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n", lightbuffersize, screen->mBones->GetBlockSize()); + vp_comb.Format("#version 310 es\n#define NO_CLIPDISTANCE_SUPPORT\n#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n#define NUM_VIEWS 2\n", lightbuffersize, screen->mBones->GetBlockSize()); #else vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n", lightbuffersize, screen->mBones->GetBlockSize()); #endif @@ -421,6 +421,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } FString fp_comb = vp_comb; + +#ifdef __MOBILE__ + vp_comb << "#extension GL_OVR_multiview2 : enable\n" + "layout(num_views=NUM_VIEWS) in;\n"; +#endif + vp_comb << defines << i_data.GetChars(); fp_comb << "$placeholder$\n" << defines << i_data.GetChars(); diff --git a/source/common/rendering/gl/gl_stereo3d.cpp b/source/common/rendering/gl/gl_stereo3d.cpp index f921bd2fa..f74507932 100644 --- a/source/common/rendering/gl/gl_stereo3d.cpp +++ b/source/common/rendering/gl/gl_stereo3d.cpp @@ -48,7 +48,6 @@ bool TBXR_IsFrameSetup(); void TBXR_prepareEyeBuffer(int eye ); -void TBXR_finishEyeBuffer(int eye ); void TBXR_submitFrame(); EXTERN_CVAR(Int, vr_mode) @@ -381,22 +380,6 @@ bool FGLRenderer::QuadStereoCheckInitialRenderContextState() void FGLRenderer::PresentOpenXR() { - if (!TBXR_IsFrameSetup()) - { - return; - } - - for (int eye = 0; eye < 2; ++eye) - { - TBXR_prepareEyeBuffer(eye); - - ClearBorders(); - mBuffers->BindEyeTexture(eye, 0); - DrawPresentTexture(screen->mOutputLetterbox, true); - - TBXR_finishEyeBuffer(eye); - } - TBXR_submitFrame(); } diff --git a/source/common/rendering/hwrenderer/data/hw_renderstate.h b/source/common/rendering/hwrenderer/data/hw_renderstate.h index 3851a3610..1f5e08d4c 100644 --- a/source/common/rendering/hwrenderer/data/hw_renderstate.h +++ b/source/common/rendering/hwrenderer/data/hw_renderstate.h @@ -216,7 +216,6 @@ protected: uint8_t mSplitEnabled : 1; uint8_t mBrightmapEnabled : 1; - int mEye; int mLightIndex; int mBoneIndexBase; int mSpecialEffect; @@ -257,7 +256,6 @@ public: void Reset() { - mEye = 0; mTextureEnabled = true; mBrightmapEnabled = mGradientEnabled = mFogEnabled = mGlowEnabled = false; mFogColor = 0xffffffff; @@ -314,11 +312,6 @@ public: ClearClipSplit(); } - void SetEye(int eye) - { - mEye = eye; - } - void SetNormal(FVector3 norm) { mStreamData.uVertexNormal = { norm.X, norm.Y, norm.Z, 0.f }; @@ -616,11 +609,6 @@ public: mBias.mUnits = 0; } - int GetEye() - { - return mEye; - } - private: void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader) { diff --git a/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp b/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp index 84b369d31..f49431d3e 100644 --- a/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp +++ b/source/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp @@ -98,19 +98,22 @@ void HWViewpointBuffer::Set2D(F2DDrawer *drawer, FRenderState &di, int width, in matrices.mClipLine.X = -10000000.0f; matrices.mShadowmapFilter = gl_shadowmap_filter; - if (isDrawingFullscreen && isIn2D) //fullscreen 2D + if (isDrawingFullscreen) //fullscreen 2D { - matrices.mProjectionMatrix.ortho(0, (float) width, (float) height, 0, -1.0f, 1.0f); + matrices.mProjectionMatrix[0].ortho(0, (float) width, (float) height, 0, -1.0f, 1.0f); + matrices.mProjectionMatrix[1].ortho(0, (float) width, (float) height, 0, -1.0f, 1.0f); } else if (isIn2D) // HUD { auto vrmode = VRMode::GetVRMode(true); - matrices.mProjectionMatrix = vrmode->mEyes[di.GetEye()].GetHUDProjection(width, height); + matrices.mProjectionMatrix[0] = vrmode->mEyes[0].GetHUDProjection(width, height); + matrices.mProjectionMatrix[1] = vrmode->mEyes[1].GetHUDProjection(width, height); } else //Player Sprite { auto vrmode = VRMode::GetVRMode(true); - matrices.mProjectionMatrix = vrmode->mEyes[di.GetEye()].GetPlayerSpriteProjection(width, height); + matrices.mProjectionMatrix[0] = vrmode->mEyes[0].GetPlayerSpriteProjection(width, height); + matrices.mProjectionMatrix[1] = vrmode->mEyes[1].GetPlayerSpriteProjection(width, height); } matrices.CalcDependencies(); SetViewpoint(di, &matrices); diff --git a/source/common/rendering/hwrenderer/data/hw_viewpointuniforms.h b/source/common/rendering/hwrenderer/data/hw_viewpointuniforms.h index def3b4808..22e7d3c14 100644 --- a/source/common/rendering/hwrenderer/data/hw_viewpointuniforms.h +++ b/source/common/rendering/hwrenderer/data/hw_viewpointuniforms.h @@ -15,7 +15,7 @@ enum class ELightBlendMode : uint8_t struct HWViewpointUniforms { - VSMatrix mProjectionMatrix; + VSMatrix mProjectionMatrix[2]; VSMatrix mViewMatrix; VSMatrix mNormalViewMatrix; FVector4 mCameraPos; diff --git a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp index 80d824442..b1c5a0ed0 100644 --- a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp +++ b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp @@ -172,6 +172,7 @@ float getHmdAdjustedHeightInMapUnit() #define isqrt2 0.7071067812f static VRMode vrmi_mono = { 1, 1.f, 1.f, 1.f,{ { 0.f, 1.f },{ 0.f, 0.f } } }; static VRMode vrmi_stereo = { 2, 1.f, 1.f, 1.f,{ { -.5f, 1.f },{ .5f, 1.f } } }; +static VRMode vrmi_openxr = { 1, 1.f, 1.f, 1.f,{ { -.5f, 1.f },{ .5f, 1.f } } }; static VRMode vrmi_sbsfull = { 2, .5f, 1.f, 2.f,{ { -.5f, .5f },{ .5f, .5f } } }; static VRMode vrmi_sbssquished = { 2, .5f, 1.f, 1.f,{ { -.5f, 1.f },{ .5f, 1.f } } }; static VRMode vrmi_lefteye = { 1, 1.f, 1.f, 1.f, { { -.5f, 1.f },{ 0.f, 0.f } } }; @@ -194,8 +195,10 @@ const VRMode *VRMode::GetVRMode(bool toscreen) case VR_QUADSTEREO: case VR_AMBERBLUE: case VR_SIDEBYSIDELETTERBOX: + return &vrmi_stereo; + case VR_OPENXR: - return &vrmi_stereo; + return &vrmi_openxr; case VR_SIDEBYSIDESQUISHED: case VR_COLUMNINTERLEAVED: @@ -255,7 +258,7 @@ VSMatrix VREyeInfo::GetHUDProjection(int width, int height) const VSMatrix new_projection; new_projection.loadIdentity(); - float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter() * vr_hud_stereo * (getEye() == 1 ? 1.0 : -1.0); + float stereo_separation = getStereoSeparation(vr_hud_stereo); new_projection.translate(stereo_separation, 0, 0); // doom_units from meters @@ -289,13 +292,19 @@ VSMatrix VREyeInfo::GetHUDProjection(int width, int height) const new_projection.translate(-1.0, 1.0, 0); new_projection.scale(2.0 / width, -2.0 / height, -1.0); - VSMatrix proj = GetProjection(RazeXR_GetFOV(), ratio, fovratio); + VSMatrix proj = GetCenterProjection(RazeXR_GetFOV(), ratio, fovratio); proj.multMatrix(new_projection); new_projection = proj; return new_projection; } +float VREyeInfo::getStereoSeparation(double stereoLevel) const +{ + float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter() * stereoLevel * (getEye() == 1 ? -1.0 : 1.0); + return stereo_separation; +} + VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const { // now render the main view @@ -314,8 +323,7 @@ VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const new_projection.loadIdentity(); float weapon_stereo_effect = 2.8f; - float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter() * weapon_stereo_effect * (getEye() == 1 ? -1.0 : 1.0); - new_projection.translate(stereo_separation, 0, 0); + new_projection.translate(getStereoSeparation(weapon_stereo_effect), 0, 0); // doom_units from meters new_projection.scale( @@ -334,6 +342,7 @@ VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const new_projection.rotate(weaponangles[YAW] - hmdorientation[YAW], 0, 1, 0); new_projection.rotate(weaponangles[PITCH], 1, 0, 0); + new_projection.rotate(weaponangles[ROLL], 0, 0, 1); float weapon_scale = 0.6f; @@ -356,7 +365,7 @@ VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const } new_projection.scale(2.0 / width, -2.0 / height, -1.0); - VSMatrix proj = GetProjection(RazeXR_GetFOV(), ratio, fovratio); + VSMatrix proj = GetCenterProjection(RazeXR_GetFOV(), ratio, fovratio); proj.multMatrix(new_projection); new_projection = proj; @@ -375,7 +384,14 @@ int VREyeInfo::getEye() const bool VR_GetVRProjection(int eye, float zNear, float zFar, float* projection); -VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio) const +VSMatrix VREyeInfo::GetStereoProjection(float fov, float aspectRatio, float fovRatio) const +{ + VSMatrix projection = GetCenterProjection(fov, aspectRatio, fovRatio); + projection.translate(getStereoSeparation(1.0f), 0, 0); + return projection; +} + +VSMatrix VREyeInfo::GetCenterProjection(float fov, float aspectRatio, float fovRatio) const { VSMatrix result; @@ -417,6 +433,7 @@ VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio) /* virtual */ DVector3 VREyeInfo::GetViewShift(FRotator viewAngles) const { + if (mShiftFactor == 0) { // pass-through for Mono view @@ -425,19 +442,18 @@ DVector3 VREyeInfo::GetViewShift(FRotator viewAngles) const else { vec3_t angles; - VectorSet(angles, viewAngles.Pitch.Degrees(), viewAngles.Yaw.Degrees(), viewAngles.Roll.Degrees()); + VectorSet(angles, viewAngles.Pitch.Degrees(), viewAngles.Yaw.Degrees(), + viewAngles.Roll.Degrees()); vec3_t v_forward, v_right, v_up; AngleVectors(angles, v_forward, v_right, v_up); - vec3_t tmp; - VectorScale(v_right, getShift(), tmp); - - float posforward=0; - float posside=0; - float dummy=0; + float posforward = 0; + float posside = 0; + float dummy = 0; VR_GetMove(&dummy, &dummy, &posforward, &posside, &dummy, &dummy, &dummy, &dummy); - DVector3 eyeOffset(tmp[0], tmp[1], tmp[2]); + DVector3 eyeOffset; + eyeOffset.Zero(); if (vr_positional_tracking) { diff --git a/source/common/rendering/hwrenderer/data/hw_vrmodes.h b/source/common/rendering/hwrenderer/data/hw_vrmodes.h index a39fe5b4d..17329f9e9 100644 --- a/source/common/rendering/hwrenderer/data/hw_vrmodes.h +++ b/source/common/rendering/hwrenderer/data/hw_vrmodes.h @@ -28,7 +28,8 @@ struct VREyeInfo float mShiftFactor; float mScaleFactor; - VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const; + VSMatrix GetCenterProjection(float fov, float aspectRatio, float fovRatio) const; + VSMatrix GetStereoProjection(float fov, float aspectRatio, float fovRatio) const; DVector3 GetViewShift(FRotator angles) const; VSMatrix GetHUDProjection(int width, int height) const; VSMatrix GetPlayerSpriteProjection(int width, int height) const; @@ -36,6 +37,8 @@ struct VREyeInfo private: float getShift() const; int getEye() const; + + float getStereoSeparation(double stereoLevel) const; }; struct VRMode diff --git a/source/common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp b/source/common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp index 1c0b375a8..01a9683b6 100644 --- a/source/common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp +++ b/source/common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp @@ -68,7 +68,7 @@ CUSTOM_CVAR(Int, gl_ssao, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) self = 0; } -CUSTOM_CVAR(Int, gl_ssao_portals, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, gl_ssao_portals, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { if (self < 0) self = 0; diff --git a/source/common/rendering/v_framebuffer.cpp b/source/common/rendering/v_framebuffer.cpp index 271348bc1..f445c6f7c 100644 --- a/source/common/rendering/v_framebuffer.cpp +++ b/source/common/rendering/v_framebuffer.cpp @@ -252,6 +252,11 @@ void DFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y) void DFrameBuffer::FPSLimit() { + //We don't need to limit FPS +#ifdef __MOBILE__ + return; +#endif + using namespace std::chrono; using namespace std::this_thread; diff --git a/source/common/startscreen/endoom.cpp b/source/common/startscreen/endoom.cpp index cc1e31a44..073d2b295 100644 --- a/source/common/startscreen/endoom.cpp +++ b/source/common/startscreen/endoom.cpp @@ -169,26 +169,6 @@ int RunEndoom() S_StopMusic(true); auto endoom = new FEndoomScreen(endoom_lump); endoom->Render(true); - -/* while(true) - { - I_GetEvent(); - endoom->Update(); - while (eventtail != eventhead) - { - event_t *ev = &events[eventtail]; - eventtail = (eventtail + 1) & (MAXEVENTS - 1); - - if (ev->type == EV_KeyDown || ev->type == EV_KeyUp) - { - return 0; - } - if (ev->type == EV_GUI_Event && (ev->subtype == EV_GUI_KeyDown || ev->subtype == EV_GUI_LButtonDown || ev->subtype == EV_GUI_RButtonDown || ev->subtype == EV_GUI_MButtonDown)) - { - return 0; - } - } - }*/ return 0; } diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index eb096e595..c5768e9f4 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -92,7 +92,7 @@ CVARD(Bool, cl_loadingscreens, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/dis CVARD(Bool, cl_clampedpitch, true, CVAR_ARCHIVE, "clamp the view pitch to original ranges") -CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE|CVAR_USERINFO, "enable/disable weapon autoaim") +CUSTOM_CVARD(Int, cl_autoaim, 0, CVAR_ARCHIVE|CVAR_USERINFO, "enable/disable weapon autoaim") { int automodes = (g_gameType & (GAMEFLAG_DUKECOMPAT | GAMEFLAG_BLOOD | GAMEFLAG_SW)) ? 2 : 1; if (self < 0 || self > automodes) self = 1; diff --git a/source/core/gamehud.cpp b/source/core/gamehud.cpp index f1c2b92a4..62f0041be 100644 --- a/source/core/gamehud.cpp +++ b/source/core/gamehud.cpp @@ -133,7 +133,7 @@ void DrawRateStuff() int textScale = active_con_scale(twod_blend); int rate_x = (screen->GetWidth() / 2) / textScale - (NewConsoleFont->StringWidth(&fpsbuff[0]) / 2); - twod->AddColorOnlyQuad(rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, MAKEARGB(255, 0, 0, 0)); + //twod->AddColorOnlyQuad(rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, MAKEARGB(255, 0, 0, 0)); DrawText(twod_blend, NewConsoleFont, CR_WHITE, rate_x, screen->GetHeight() / 2, (char*)&fpsbuff[0], DTA_VirtualWidth, screen->GetWidth() / textScale, DTA_VirtualHeight, screen->GetHeight() / textScale, diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 3ea65556e..3842ad64e 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -408,12 +408,15 @@ void DrawOverlays() //========================================================================== CVAR(String, drawtile, "", 0) // debug stuff. Draws the tile with the given number on top of thze HUD +void TBXR_FrameSetup(); void Display() { if (screen == nullptr || (!AppActive && (screen->IsFullscreen() || !vid_activeinbackground))) { return; } + + TBXR_FrameSetup(); FTexture* wipestart = nullptr; if (nextwipe != wipe_None) diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index 65f0e9ca8..3dfa64861 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -136,15 +136,18 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float auto vrmode = VRMode::GetVRMode(mainview && toscreen); const int eyeCount = vrmode->mEyeCount; screen->FirstEye(); + +#ifndef __MOBILE__ hw_int_useindexedcolortextures = eyeCount > 1? false : *hw_useindexedcolortextures; +#else + hw_int_useindexedcolortextures = false; +#endif for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix) { const auto& eye = vrmode->mEyes[eye_ix]; screen->SetViewportRects(bounds); - screen->RenderState()->SetEye(eye_ix); - if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao { bool useSSAO = (gl_ssao != 0); @@ -164,7 +167,8 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float di->Viewpoint.FieldOfView = FAngle::fromDeg(fov); // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint) // Stereo mode specific perspective projection - di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio); + di->VPUniforms.mProjectionMatrix[0] = vrmode->mEyes[0].GetStereoProjection(fov, ratio, fovratio); + di->VPUniforms.mProjectionMatrix[1] = vrmode->mEyes[1].GetStereoProjection(fov, ratio, fovratio); // Stereo mode specific viewpoint adjustment diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index 5a310441b..88d66264a 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -138,7 +138,8 @@ void HWDrawInfo::StartScene(FRenderViewpoint& parentvp, HWViewpointUniforms* uni } else { - VPUniforms.mProjectionMatrix.loadIdentity(); + VPUniforms.mProjectionMatrix[0].loadIdentity(); + VPUniforms.mProjectionMatrix[1].loadIdentity(); VPUniforms.mViewMatrix.loadIdentity(); VPUniforms.mNormalViewMatrix.loadIdentity(); //VPUniforms.mViewHeight = viewheight; @@ -730,19 +731,29 @@ void HWDrawInfo::DrawScene(int drawmode, bool portal) if (!gl_no_skyclear) portalState.RenderFirstSkyPortal(recursion, this, RenderState); +#ifndef __MOBILE__ + //The original location of this call RenderScene(RenderState); if (applySSAO && RenderState.GetPassType() == GBUFFER_PASS) { - screen->AmbientOccludeScene(VPUniforms.mProjectionMatrix.get()[5]); + screen->AmbientOccludeScene(VPUniforms.mProjectionMatrix[0].get()[5]); screen->mViewpoints->Bind(RenderState, vpIndex); } +#endif // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; portalState.EndFrame(this, RenderState); recursion--; + +#ifdef __MOBILE__ + //For some reason, doing this here this fixes the issue with portals being drawn out of order sometimes when using + // Direct to eye buffer rendering for multiview + RenderScene(RenderState); +#endif + RenderTranslucent(RenderState); } diff --git a/source/core/version.h b/source/core/version.h index 393c50afd..dc8904465 100644 --- a/source/core/version.h +++ b/source/core/version.h @@ -44,7 +44,7 @@ const char *GetVersionString(); #define VERSIONSTR "1.7pre" -#define RAZEXR_VERSIONSTR "RazeXR 0.1.5" +#define RAZEXR_VERSIONSTR "RazeXR 0.2.1" // The version as seen in the Windows resource #define RC_FILEVERSION 1,6,9999,0 diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 18e2b5ae3..8ca99bbf3 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -51,6 +51,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "tilesetbuilder.h" #include "nnexts.h" +extern int playerHeight; //Used to define player height for VR + BEGIN_BLD_NS @@ -604,6 +606,8 @@ void GameInterface::app_init() { mirrortile = tileGetTextureID(504); + playerHeight = 60; + GC::AddMarkerFunc(markgcroots); InitCheats(); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index be9929e64..f7e753268 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1547,6 +1547,7 @@ void ProcessInput(PLAYER* pPlayer) DVector2 posXY; sectortype* sect; + bool crosshairActive = false; if (vr_6dof_weapons) { get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw); @@ -1577,6 +1578,8 @@ void ProcessInput(PLAYER* pPlayer) if (hit.hitSector != nullptr) { + crosshairActive = true; + double length = (hit.hitpos.XY() - actor->spr.pos.XY()).Length(); //Update the existing aiming sprites if there is one @@ -1603,6 +1606,16 @@ void ProcessInput(PLAYER* pPlayer) } } + if (!crosshairActive) + { + BloodStatIterator it(kStatCrosshair); + DBloodActor *crosshair = it.Next(); + if (crosshair) + { + crosshair->spr.scale = DVector2(0, 0); + } + } + WeaponProcess(pPlayer); if (vr_6dof_weapons) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 61fbef940..fa332daa2 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2560,11 +2560,12 @@ static void processweapon(int snum, ESyncBits actions) int shrunk = (pact->spr.scale.Y < 0.5); //Aiming decal?! - if (pact) + if (pact && pact->isPlayer()) { + bool crosshairActive = false; if (p->curr_weapon != KNEE_WEAPON) { - if (pact->isPlayer() && vr_6dof_weapons && vr_6dof_crosshair) + if (vr_6dof_weapons && vr_6dof_crosshair) { float x, y, z1, z2, pitch, yaw; get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw); @@ -2591,6 +2592,7 @@ static void processweapon(int snum, ESyncBits actions) if (hit.hitSector != nullptr) { + crosshairActive = true; double length = (hit.hitpos.XY() - pact->spr.pos.XY()).Length(); //Update the existing aiming sprites if there is one @@ -2609,6 +2611,17 @@ static void processweapon(int snum, ESyncBits actions) } } } + + if (!crosshairActive) + { + //Update the existing aiming sprites if there is one + DukeStatIterator it(STAT_AIM_SPRITE); + DDukeActor* crosshair = it.Next(); + if (crosshair) + { + crosshair->spr.scale = DVector2(0, 0); + } + } } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 932e1b11d..aa9af80b5 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3174,11 +3174,12 @@ static void processweapon(int snum, ESyncBits actions, sectortype* psectp) int shrunk = (pact->spr.scale.Y < 0.125); //Aiming decal?! - if (pact) + if (pact && pact->isPlayer()) { + bool crosshairActive = false; if (p->curr_weapon != KNEE_WEAPON) { - if (pact->isPlayer() && vr_6dof_weapons && vr_6dof_crosshair) + if (vr_6dof_weapons && vr_6dof_crosshair) { float x, y, z1, z2, pitch, yaw; get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw); @@ -3204,6 +3205,7 @@ static void processweapon(int snum, ESyncBits actions, sectortype* psectp) if (hit.hitSector != nullptr) { + crosshairActive = true; double length = (hit.hitpos.XY() - pact->spr.pos.XY()).Length(); //Update the existing aiming sprites if there is one @@ -3222,6 +3224,17 @@ static void processweapon(int snum, ESyncBits actions, sectortype* psectp) } } } + + if (!crosshairActive) + { + //Update the existing aiming sprites if there is one + DukeStatIterator it(STAT_AIM_SPRITE); + DDukeActor* crosshair = it.Next(); + if (crosshair) + { + crosshair->spr.scale = DVector2(0, 0); + } + } } if (p->detonate_count > 0) diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 29ab58fcc..55998cb84 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -52,6 +52,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "tilesetbuilder.h" #include "psky.h" +extern int playerHeight; //Used to define player height for VR + + BEGIN_PS_NS TObjPtr bestTarget; @@ -568,12 +571,11 @@ void GameInterface::SetupSpecialTextures(TilesetBuildInfo& info) // // //--------------------------------------------------------------------------- - void GameInterface::app_init() { GC::AddMarkerFunc(markgcroots); - + playerHeight = 58; #if 0 help_disabled = true; #endif diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 02ba2472c..04d53e2a4 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -2664,6 +2664,7 @@ sectdone: DVector2 posXY; sectortype* sect; + bool crosshairActive = false; if (vr_6dof_weapons && nPlayer == 0) { get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw); @@ -2694,6 +2695,7 @@ sectdone: if (hit.hitSector != nullptr) { + crosshairActive = true; double length = (hit.hitpos.XY() - pPlayerActor->spr.pos.XY()).Length(); //Update the existing aiming sprites if there is one @@ -2721,7 +2723,16 @@ sectdone: } pPlayerActor->spr.pos.Z += -pPlayerActor->viewzoffset; + } + if (!crosshairActive) + { + ExhumedStatIterator it(kStatCrosshair); + DExhumedActor *crosshair = it.Next(); + if (crosshair) + { + crosshair->spr.scale = DVector2(0, 0); + } } MoveWeapons(nPlayer); diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 138270295..3261e8974 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -86,6 +86,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "interpolate.h" //#include "crc32.h" +extern int playerHeight; //Used to define player height for VR CVAR(Bool, sw_ninjahack, false, CVAR_ARCHIVE /*| CVAR_SERVERINFO*/); CVAR(Bool, sw_darts, false, CVAR_ARCHIVE); @@ -249,7 +250,6 @@ void GameInterface::SetupSpecialTextures(TilesetBuildInfo& info) // // //--------------------------------------------------------------------------- - void GameInterface::app_init() { // these are frequently checked markers. @@ -306,6 +306,8 @@ void GameInterface::app_init() userConfig.AddDefs.reset(); InitFX(); + + playerHeight = 58; } //--------------------------------------------------------------------------- diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 26f792bac..c6499194b 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -7036,6 +7036,7 @@ void domovethings(void) DVector2 posXY; sectortype* sect; + bool crosshairActive = false; if (vr_6dof_weapons) { get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw); @@ -7065,6 +7066,7 @@ void domovethings(void) if (hit.hitSector != nullptr) { + crosshairActive = true; double length = (hit.hitpos.XY() - pp->actor->spr.pos.XY()).Length(); //Update the existing aiming sprites if there is one @@ -7093,6 +7095,16 @@ void domovethings(void) } } + if (!crosshairActive) + { + SWStatIterator it(STAT_CROSSHAIR); + DSWActor* crosshair = it.Next(); + if (crosshair) + { + crosshair->spr.scale = DVector2(0, 0); + } + } + pSpriteControl(pp); if (vr_6dof_weapons) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 0f130e166..b1154e982 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -506,6 +506,9 @@ OptionMenu "OptionsMenu" protected Submenu "$OS_TITLE", "os_Menu" StaticText " " Submenu "$MNU_ENGINECREDITS", "EngineCredits" + StaticText " " + Submenu "Team Beef Gold-Tier Patrons", "GoldTierCredits" + StaticText " " SafeCommand "$OPTMNU_DEFAULTS", "reset2defaults" SafeCommand "$OPTMNU_RESETTOSAVED", "reset2saved" //Command "$OPTMNU_CONSOLE", "menuconsole" @@ -545,8 +548,8 @@ OptionMenu "VROptionsMenu" protected { Title "VR Options" StaticText "" - //Option "Control Scheme", "vr_control_scheme", "ControlScheme" - //Option "Switch Sticks", "vr_switch_sticks", "YesNo" + Option "Control Scheme", "vr_control_scheme", "ControlScheme" + Option "Switch Sticks", "vr_switch_sticks", "YesNo" StaticText "" Option "Turning Mode", "vr_snapTurn", "TurningMode" Option "Direction Mode", "vr_move_use_offhand", "DirectionMode" @@ -555,7 +558,7 @@ OptionMenu "VROptionsMenu" protected StaticText "" Option "Positional Tracking", "vr_positional_tracking", "YesNo" Option "6DoF Weapons", "vr_6dof_weapons", "YesNo" - Option "VR Aim-Assist", "vr_6dof_crosshair", "YesNo" + Option "VR Crosshair", "vr_6dof_crosshair", "YesNo" StaticText "" StaticText "HUD" @@ -1741,9 +1744,9 @@ OptionMenu VideoModeMenu protected Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes" Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2 - StaticText " " - Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" - Option "$VIDMNU_MAXFPS", "vid_maxfps", "MaxFps" +// StaticText " " +// Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" +// Option "$VIDMNU_MAXFPS", "vid_maxfps", "MaxFps" StaticText "" StaticText "$VIDMNU_CUSTOMRES" @@ -2108,6 +2111,34 @@ OptionMenu "MultiOptionsMenu" } */ +OptionMenu "GoldTierCredits" +{ + title "$MNU_CREDITS" + StaticText "" + StaticText "" + StaticText "" + StaticText "Team Beef Gold Tier Patrons", 1 + StaticText "" + StaticText "David Gohman Adam Luc Lowndes " + StaticText "Sign of the Beefcarver Naughtynate350 Mike Gummelt " + StaticText "CrashOrganism Russel Jones Joshua Vizanko " + StaticText "GD Dragon Saeed Al-Ali Gabe Miller " + StaticText "Jojo Mojo Andrew Remsen valedurandal " + StaticText "Brian Sifrar Dominik Studer Tommy Green " + StaticText "Cuttlersan Kalli Raya Lunar Stain " + StaticText "iS ken fountain Ben Otter " + StaticText "Emanuele Disco CharlieSayNo cranky_bum " + StaticText "Jamie S EDavey BMF " + StaticText "Jack Henaghan Loot Tester Charlie Bagwell " + StaticText "Braxus Ryan Milke Emile Tixeuil " + StaticText "Rex Keith Griffin Cole Edwards " + StaticText "Max Spellbound1998 mrpapa " + StaticText "Albert Valiev Duncan Mummery Stephen Sayles " + StaticText "Markus Dickmann HUSSEIN MOSTAFA Adam Davidek " + StaticText "Jack Henaghan Axis BayesianBroccoli " + StaticText "Montain Gral Markus Gunther " +} + OptionMenu "EngineCredits" { title "$MNU_CREDITS" diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 7c137fff3..e70ff8e80 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -109,7 +109,7 @@ void main() vTexCoord = TextureMatrix * vec4(parmTexCoord, 0.0, 1.0); #endif - gl_Position = ProjectionMatrix * eyeCoordPos; + gl_Position = ProjectionMatrix[gl_ViewID_OVR] * eyeCoordPos; #ifdef VULKAN_COORDINATE_SYSTEM gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;