mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-14 08:30:35 +00:00
Implementation using no additional frame buffers
This commit is contained in:
parent
578f7cfbcd
commit
06a99dbafb
8 changed files with 46 additions and 21 deletions
|
@ -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<void()> &afterBloomDrawEndScene2D)
|
||||
{
|
||||
#ifndef __MOBILE__
|
||||
if (!swscene) GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
|
||||
#endif
|
||||
GLRenderer->PostProcessScene(fixedcm, flash, afterBloomDrawEndScene2D);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,11 @@ void FGLRenderer::RenderScreenQuad()
|
|||
|
||||
void FGLRenderer::PostProcessScene(int fixedcm, float flash, const std::function<void()> &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)
|
||||
|
@ -118,6 +127,7 @@ void FGLRenderer::Flush()
|
|||
}
|
||||
else
|
||||
{
|
||||
screen->FirstEye();
|
||||
// Render 2D to eye textures
|
||||
int eyeCount = vrmode->mEyeCount;
|
||||
for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -255,7 +255,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
|
||||
|
@ -296,6 +296,12 @@ VSMatrix VREyeInfo::GetHUDProjection(int width, int height) const
|
|||
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 +320,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(
|
||||
|
|
|
@ -36,6 +36,8 @@ struct VREyeInfo
|
|||
private:
|
||||
float getShift() const;
|
||||
int getEye() const;
|
||||
|
||||
float getStereoSeparation(double stereoLevel) const;
|
||||
};
|
||||
|
||||
struct VRMode
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -136,7 +136,12 @@ 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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue