Merge branch 'multiview' into direct-eye-buffers

This commit is contained in:
Simon 2023-02-13 11:29:23 +00:00
commit 936f079db8
9 changed files with 34 additions and 14 deletions

View file

@ -86,7 +86,14 @@ void I_StartTic ()
}
void TBXR_FrameSetup();
void TBXR_prepareEyeBuffer(int);
bool TBXR_IsFrameSetup();
void I_StartFrame ()
{
if (TBXR_IsFrameSetup())
{
return;
}
TBXR_FrameSetup();
}

View file

@ -121,11 +121,12 @@ 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

View file

@ -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();

View file

@ -100,17 +100,20 @@ void HWViewpointBuffer::Set2D(F2DDrawer *drawer, FRenderState &di, int width, in
if (isDrawingFullscreen && isIn2D) //fullscreen 2D
{
matrices.mProjectionMatrix.ortho(0, (float) width, (float) height, 0, -1.0f, 1.0f);
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);
}
else if (isIn2D) // HUD
{
auto vrmode = VRMode::GetVRMode(true);
matrices.mProjectionMatrix = vrmode->mEyes[di.GetEye()].GetHUDProjection(width, height);
matrices.mProjectionMatrixLeft = vrmode->mEyes[0].GetHUDProjection(width, height);
matrices.mProjectionMatrixRight = vrmode->mEyes[1].GetHUDProjection(width, height);
}
else //Player Sprite
{
auto vrmode = VRMode::GetVRMode(true);
matrices.mProjectionMatrix = vrmode->mEyes[di.GetEye()].GetPlayerSpriteProjection(width, height);
matrices.mProjectionMatrixLeft = vrmode->mEyes[0].GetPlayerSpriteProjection(width, height);
matrices.mProjectionMatrixRight = vrmode->mEyes[1].GetPlayerSpriteProjection(width, height);
}
matrices.CalcDependencies();
SetViewpoint(di, &matrices);

View file

@ -15,7 +15,8 @@ enum class ELightBlendMode : uint8_t
struct HWViewpointUniforms
{
VSMatrix mProjectionMatrix;
VSMatrix mProjectionMatrixLeft;
VSMatrix mProjectionMatrixRight;
VSMatrix mViewMatrix;
VSMatrix mNormalViewMatrix;
FVector4 mCameraPos;

View file

@ -171,7 +171,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_stereo = { 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 } } };

View file

@ -169,7 +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.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio);
di->VPUniforms.mProjectionMatrixLeft = vrmode->mEyes[0].GetProjection(fov, ratio, fovratio);
di->VPUniforms.mProjectionMatrixRight = vrmode->mEyes[1].GetProjection(fov, ratio, fovratio);
// Stereo mode specific viewpoint adjustment

View file

@ -138,7 +138,8 @@ void HWDrawInfo::StartScene(FRenderViewpoint& parentvp, HWViewpointUniforms* uni
}
else
{
VPUniforms.mProjectionMatrix.loadIdentity();
VPUniforms.mProjectionMatrixLeft.loadIdentity();
VPUniforms.mProjectionMatrixRight.loadIdentity();
VPUniforms.mViewMatrix.loadIdentity();
VPUniforms.mNormalViewMatrix.loadIdentity();
//VPUniforms.mViewHeight = viewheight;
@ -732,10 +733,10 @@ void HWDrawInfo::DrawScene(int drawmode, bool portal)
RenderScene(RenderState);
if (applySSAO && RenderState.GetPassType() == GBUFFER_PASS)
if (false)//applySSAO && RenderState.GetPassType() == GBUFFER_PASS)
{
screen->AmbientOccludeScene(VPUniforms.mProjectionMatrix.get()[5]);
screen->mViewpoints->Bind(RenderState, vpIndex);
//screen->AmbientOccludeScene(VPUniforms.mProjectionMatrix[0].get()[5]);
//screen->mViewpoints->Bind(RenderState, vpIndex);
}
// Handle all portals after rendering the opaque objects but before

View file

@ -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;