mirror of
https://github.com/DrBeef/Raze.git
synced 2025-03-13 05:02:04 +00:00
FInal changes to get MV rendering correctly
This commit is contained in:
parent
936f079db8
commit
f1a165add7
7 changed files with 50 additions and 30 deletions
|
@ -100,20 +100,20 @@ void HWViewpointBuffer::Set2D(F2DDrawer *drawer, FRenderState &di, int width, in
|
|||
|
||||
if (isDrawingFullscreen && isIn2D) //fullscreen 2D
|
||||
{
|
||||
matrices.mProjectionMatrixLeft.ortho(0, (float) width, (float) height, 0, -1.0f, 1.0f);
|
||||
matrices.mProjectionMatrixRight.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.mProjectionMatrixLeft = vrmode->mEyes[0].GetHUDProjection(width, height);
|
||||
matrices.mProjectionMatrixRight = vrmode->mEyes[1].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.mProjectionMatrixLeft = vrmode->mEyes[0].GetPlayerSpriteProjection(width, height);
|
||||
matrices.mProjectionMatrixRight = vrmode->mEyes[1].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);
|
||||
|
|
|
@ -15,8 +15,7 @@ enum class ELightBlendMode : uint8_t
|
|||
|
||||
struct HWViewpointUniforms
|
||||
{
|
||||
VSMatrix mProjectionMatrixLeft;
|
||||
VSMatrix mProjectionMatrixRight;
|
||||
VSMatrix mProjectionMatrix[2];
|
||||
VSMatrix mViewMatrix;
|
||||
VSMatrix mNormalViewMatrix;
|
||||
FVector4 mCameraPos;
|
||||
|
|
|
@ -171,7 +171,8 @@ 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 = { 1, 1.f, 1.f, 1.f,{ { -.5f, 1.f },{ .5f, 1.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:
|
||||
|
@ -289,7 +292,7 @@ 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;
|
||||
|
||||
|
@ -361,7 +364,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;
|
||||
|
||||
|
@ -380,7 +383,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;
|
||||
|
||||
|
@ -422,6 +432,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
|
||||
|
@ -430,19 +441,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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -169,8 +169,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.mProjectionMatrixLeft = vrmode->mEyes[0].GetProjection(fov, ratio, fovratio);
|
||||
di->VPUniforms.mProjectionMatrixRight = vrmode->mEyes[1].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
|
||||
|
|
|
@ -138,8 +138,8 @@ void HWDrawInfo::StartScene(FRenderViewpoint& parentvp, HWViewpointUniforms* uni
|
|||
}
|
||||
else
|
||||
{
|
||||
VPUniforms.mProjectionMatrixLeft.loadIdentity();
|
||||
VPUniforms.mProjectionMatrixRight.loadIdentity();
|
||||
VPUniforms.mProjectionMatrix[0].loadIdentity();
|
||||
VPUniforms.mProjectionMatrix[1].loadIdentity();
|
||||
VPUniforms.mViewMatrix.loadIdentity();
|
||||
VPUniforms.mNormalViewMatrix.loadIdentity();
|
||||
//VPUniforms.mViewHeight = viewheight;
|
||||
|
@ -731,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 (false)//applySSAO && RenderState.GetPassType() == GBUFFER_PASS)
|
||||
if (applySSAO && RenderState.GetPassType() == GBUFFER_PASS)
|
||||
{
|
||||
//screen->AmbientOccludeScene(VPUniforms.mProjectionMatrix[0].get()[5]);
|
||||
//screen->mViewpoints->Bind(RenderState, vpIndex);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ const char *GetVersionString();
|
|||
|
||||
#define VERSIONSTR "1.7pre"
|
||||
|
||||
#define RAZEXR_VERSIONSTR "RazeXR 0.1.5"
|
||||
#define RAZEXR_VERSIONSTR "RazeXR 0.2.0"
|
||||
|
||||
// The version as seen in the Windows resource
|
||||
#define RC_FILEVERSION 1,6,9999,0
|
||||
|
|
Loading…
Reference in a new issue