mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- consolidated the 3 RenderViewpoint variants and took the function out of the framebuffer class.
This commit is contained in:
parent
c203df5edb
commit
6177ed153d
19 changed files with 85 additions and 229 deletions
|
@ -91,9 +91,6 @@ public:
|
||||||
void Draw2D(F2DDrawer *data);
|
void Draw2D(F2DDrawer *data);
|
||||||
void BeginFrame();
|
void BeginFrame();
|
||||||
|
|
||||||
sector_t *RenderViewpoint (FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
|
||||||
|
|
||||||
|
|
||||||
bool StartOffscreen();
|
bool StartOffscreen();
|
||||||
void EndOffscreen();
|
void EndOffscreen();
|
||||||
void UpdateShadowMap();
|
void UpdateShadowMap();
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace OpenGLRenderer
|
||||||
class FShader;
|
class FShader;
|
||||||
struct HWSectorPlane;
|
struct HWSectorPlane;
|
||||||
|
|
||||||
class FGLRenderState : public FRenderState
|
class FGLRenderState final : public FRenderState
|
||||||
{
|
{
|
||||||
uint8_t mLastDepthClamp : 1;
|
uint8_t mLastDepthClamp : 1;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public:
|
||||||
mSpecularLevel = specularLevel;
|
mSpecularLevel = specularLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnableDrawBuffers(int count) override
|
void EnableDrawBuffers(int count, bool apply = false) override
|
||||||
{
|
{
|
||||||
count = MIN(count, 3);
|
count = MIN(count, 3);
|
||||||
if (mNumDrawBuffers != count)
|
if (mNumDrawBuffers != count)
|
||||||
|
@ -117,6 +117,7 @@ public:
|
||||||
glDrawBuffers(count, buffers);
|
glDrawBuffers(count, buffers);
|
||||||
mNumDrawBuffers = count;
|
mNumDrawBuffers = count;
|
||||||
}
|
}
|
||||||
|
if (apply) Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToggleState(int state, bool on);
|
void ToggleState(int state, bool on);
|
||||||
|
|
|
@ -29,53 +29,20 @@
|
||||||
#include "gi.h"
|
#include "gi.h"
|
||||||
#include "m_png.h"
|
#include "m_png.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "g_level.h"
|
|
||||||
#include "r_data/r_interpolate.h"
|
#include "r_data/r_interpolate.h"
|
||||||
#include "r_utility.h"
|
#include "r_utility.h"
|
||||||
#include "d_player.h"
|
#include "d_player.h"
|
||||||
#include "p_effect.h"
|
|
||||||
#include "sbar.h"
|
|
||||||
#include "po_man.h"
|
|
||||||
#include "p_local.h"
|
|
||||||
#include "serializer.h"
|
|
||||||
#include "g_levellocals.h"
|
|
||||||
#include "actorinlines.h"
|
|
||||||
#include "r_data/models/models.h"
|
|
||||||
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||||
#include "hwrenderer/utility/hw_clock.h"
|
#include "hwrenderer/utility/hw_clock.h"
|
||||||
#include "hwrenderer/data/flatvertices.h"
|
#include "hwrenderer/data/flatvertices.h"
|
||||||
|
|
||||||
#include "hwrenderer/dynlights/hw_lightbuffer.h"
|
#include "hwrenderer/dynlights/hw_lightbuffer.h"
|
||||||
#include "gl_interface.h"
|
|
||||||
#include "gl/system/gl_framebuffer.h"
|
|
||||||
#include "gl/system/gl_debug.h"
|
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
|
||||||
#include "gl/renderer/gl_renderbuffers.h"
|
|
||||||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||||
#include "hwrenderer/scene/hw_clipper.h"
|
#include "hwrenderer/scene/hw_clipper.h"
|
||||||
#include "hwrenderer/scene/hw_portal.h"
|
#include "hwrenderer/scene/hw_portal.h"
|
||||||
#include "hwrenderer/utility/hw_vrmodes.h"
|
#include "hwrenderer/utility/hw_vrmodes.h"
|
||||||
#include "gl/renderer/gl_renderer.h"
|
|
||||||
#include "gl/system/gl_buffers.h"
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// CVARs
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
CVAR(Bool, gl_texture, true, 0)
|
|
||||||
CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
||||||
CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
||||||
|
|
||||||
EXTERN_CVAR (Bool, cl_capfps)
|
|
||||||
EXTERN_CVAR (Bool, r_deathcamera)
|
|
||||||
EXTERN_CVAR (Float, r_visibility)
|
|
||||||
EXTERN_CVAR (Bool, r_drawvoxels)
|
|
||||||
|
|
||||||
|
|
||||||
namespace OpenGLRenderer
|
|
||||||
{
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -83,75 +50,71 @@ namespace OpenGLRenderer
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
||||||
{
|
{
|
||||||
R_SetupFrame (mainvp, r_viewwindow, camera);
|
auto& RenderState = *screen->RenderState();
|
||||||
|
|
||||||
|
R_SetupFrame(mainvp, r_viewwindow, camera);
|
||||||
|
|
||||||
if (mainview && toscreen)
|
if (mainview && toscreen)
|
||||||
UpdateShadowMap();
|
screen->UpdateShadowMap();
|
||||||
|
|
||||||
// Update the attenuation flag of all light defaults for each viewpoint.
|
// Update the attenuation flag of all light defaults for each viewpoint.
|
||||||
// This function will only do something if the setting differs.
|
// This function will only do something if the setting differs.
|
||||||
FLightDefaults::SetAttenuationForLevel(!!(camera->Level->flags3 & LEVEL3_ATTENUATE));
|
FLightDefaults::SetAttenuationForLevel(!!(camera->Level->flags3 & LEVEL3_ATTENUATE));
|
||||||
|
|
||||||
// Render (potentially) multiple views for stereo 3d
|
// Render (potentially) multiple views for stereo 3d
|
||||||
// Fixme. The view offsetting should be done with a static table and not require setup of the entire render state for the mode.
|
// Fixme. The view offsetting should be done with a static table and not require setup of the entire render state for the mode.
|
||||||
auto vrmode = VRMode::GetVRMode(mainview && toscreen);
|
auto vrmode = VRMode::GetVRMode(mainview && toscreen);
|
||||||
const int eyeCount = vrmode->mEyeCount;
|
const int eyeCount = vrmode->mEyeCount;
|
||||||
mBuffers->CurrentEye() = 0; // always begin at zero, in case eye count changed
|
screen->FirstEye();
|
||||||
for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix)
|
for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix)
|
||||||
{
|
{
|
||||||
const auto &eye = vrmode->mEyes[mBuffers->CurrentEye()];
|
const auto& eye = vrmode->mEyes[eye_ix];
|
||||||
screen->SetViewportRects(bounds);
|
screen->SetViewportRects(bounds);
|
||||||
|
|
||||||
if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao
|
if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao
|
||||||
{
|
{
|
||||||
bool useSSAO = (gl_ssao != 0);
|
bool useSSAO = (gl_ssao != 0);
|
||||||
mBuffers->BindSceneFB(useSSAO);
|
screen->SetSceneRenderTarget(useSSAO);
|
||||||
gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
||||||
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
RenderState.EnableDrawBuffers(RenderState.GetPassDrawBufferCount(), true);
|
||||||
gl_RenderState.Apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto di = HWDrawInfo::StartDrawInfo(mainvp.ViewLevel, nullptr, mainvp, nullptr);
|
auto di = HWDrawInfo::StartDrawInfo(mainvp.ViewLevel, nullptr, mainvp, nullptr);
|
||||||
auto &vp = di->Viewpoint;
|
auto& vp = di->Viewpoint;
|
||||||
|
|
||||||
di->Set3DViewport(gl_RenderState);
|
di->Set3DViewport(RenderState);
|
||||||
di->SetViewArea();
|
di->SetViewArea();
|
||||||
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
|
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
|
||||||
di->Viewpoint.FieldOfView = fov; // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint)
|
di->Viewpoint.FieldOfView = 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
|
// Stereo mode specific perspective projection
|
||||||
di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio);
|
di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio);
|
||||||
// Stereo mode specific viewpoint adjustment
|
// Stereo mode specific viewpoint adjustment
|
||||||
vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees);
|
vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees);
|
||||||
di->SetupView(gl_RenderState, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
|
di->SetupView(RenderState, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
|
||||||
|
|
||||||
di->ProcessScene(toscreen);
|
di->ProcessScene(toscreen);
|
||||||
|
|
||||||
if (mainview)
|
if (mainview)
|
||||||
{
|
{
|
||||||
PostProcess.Clock();
|
PostProcess.Clock();
|
||||||
if (toscreen) di->EndDrawScene(mainvp.sector, gl_RenderState); // do not call this for camera textures.
|
if (toscreen) di->EndDrawScene(mainvp.sector, RenderState); // do not call this for camera textures.
|
||||||
|
|
||||||
if (gl_RenderState.GetPassType() == GBUFFER_PASS) // Turn off ssao draw buffers
|
if (RenderState.GetPassType() == GBUFFER_PASS) // Turn off ssao draw buffers
|
||||||
{
|
{
|
||||||
gl_RenderState.SetPassType(NORMAL_PASS);
|
RenderState.SetPassType(NORMAL_PASS);
|
||||||
gl_RenderState.EnableDrawBuffers(1);
|
RenderState.EnableDrawBuffers(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
|
screen->PostProcessScene(false, cm, [&]() { di->DrawEndScene2D(mainvp.sector, RenderState); });
|
||||||
|
|
||||||
PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector, gl_RenderState); });
|
|
||||||
PostProcess.Unclock();
|
PostProcess.Unclock();
|
||||||
}
|
}
|
||||||
di->EndDrawInfo();
|
di->EndDrawInfo();
|
||||||
if (eyeCount - eye_ix > 1)
|
if (eyeCount - eye_ix > 1)
|
||||||
mBuffers->NextEye(eyeCount);
|
screen->NextEye(eyeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mainvp.sector;
|
return mainvp.sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ void OpenGLFrameBuffer::WriteSavePic(player_t *player, FileWriter *file, int wid
|
||||||
|
|
||||||
// This shouldn't overwrite the global viewpoint even for a short time.
|
// This shouldn't overwrite the global viewpoint even for a short time.
|
||||||
FRenderViewpoint savevp;
|
FRenderViewpoint savevp;
|
||||||
sector_t* viewsector = GLRenderer->RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
sector_t* viewsector = RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
gl_RenderState.SetNoSoftLightLevel();
|
gl_RenderState.SetNoSoftLightLevel();
|
||||||
GLRenderer->CopyToBackbuffer(&bounds, false);
|
GLRenderer->CopyToBackbuffer(&bounds, false);
|
||||||
|
@ -268,7 +268,7 @@ void OpenGLFrameBuffer::RenderTextureView(FCanvasTexture* tex, AActor* Viewpoint
|
||||||
bounds.height = FHardwareTexture::GetTexDimension(tex->GetHeight());
|
bounds.height = FHardwareTexture::GetTexDimension(tex->GetHeight());
|
||||||
|
|
||||||
FRenderViewpoint texvp;
|
FRenderViewpoint texvp;
|
||||||
GLRenderer->RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
||||||
|
|
||||||
GLRenderer->EndOffscreen();
|
GLRenderer->EndOffscreen();
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ sector_t *OpenGLFrameBuffer::RenderView(player_t *player)
|
||||||
fovratio = ratio;
|
fovratio = ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
retsec = GLRenderer->RenderViewpoint(r_viewpoint, player->camera, NULL, r_viewpoint.FieldOfView.Degrees, ratio, fovratio, true, true);
|
retsec = RenderViewpoint(r_viewpoint, player->camera, NULL, r_viewpoint.FieldOfView.Degrees, ratio, fovratio, true, true);
|
||||||
}
|
}
|
||||||
All.Unclock();
|
All.Unclock();
|
||||||
return retsec;
|
return retsec;
|
||||||
|
@ -529,6 +529,25 @@ void OpenGLFrameBuffer::AmbientOccludeScene(float m5)
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLFrameBuffer::FirstEye()
|
||||||
|
{
|
||||||
|
GLRenderer->mBuffers->CurrentEye() = 0; // always begin at zero, in case eye count changed
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLFrameBuffer::NextEye(int eyecount)
|
||||||
|
{
|
||||||
|
GLRenderer->mBuffers->NextEye(eyecount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLFrameBuffer::SetSceneRenderTarget(bool useSSAO)
|
||||||
|
{
|
||||||
|
GLRenderer->mBuffers->BindSceneFB(useSSAO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLFrameBuffer::UpdateShadowMap()
|
||||||
|
{
|
||||||
|
GLRenderer->UpdateShadowMap();
|
||||||
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
|
@ -610,8 +629,9 @@ void OpenGLFrameBuffer::Draw2D()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLFrameBuffer::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
void OpenGLFrameBuffer::PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||||
{
|
{
|
||||||
|
if (!swscene) GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
|
||||||
GLRenderer->PostProcessScene(fixedcm, afterBloomDrawEndScene2D);
|
GLRenderer->PostProcessScene(fixedcm, afterBloomDrawEndScene2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,11 @@ public:
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
|
||||||
void AmbientOccludeScene(float m5) override;
|
void AmbientOccludeScene(float m5) override;
|
||||||
|
void FirstEye() override;
|
||||||
|
void NextEye(int eyecount) override;
|
||||||
|
void SetSceneRenderTarget(bool useSSAO) override;
|
||||||
|
void UpdateShadowMap() override;
|
||||||
|
|
||||||
FRenderState* RenderState() override;
|
FRenderState* RenderState() override;
|
||||||
void CleanForRestart() override;
|
void CleanForRestart() override;
|
||||||
void UpdatePalette() override;
|
void UpdatePalette() override;
|
||||||
|
@ -58,7 +63,7 @@ public:
|
||||||
void SetVSync(bool vsync);
|
void SetVSync(bool vsync);
|
||||||
|
|
||||||
void Draw2D() override;
|
void Draw2D() override;
|
||||||
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||||
|
|
||||||
bool HWGammaActive = false; // Are we using hardware or software gamma?
|
bool HWGammaActive = false; // Are we using hardware or software gamma?
|
||||||
std::shared_ptr<FGLDebug> mDebug; // Debug API
|
std::shared_ptr<FGLDebug> mDebug; // Debug API
|
||||||
|
|
|
@ -49,6 +49,10 @@ CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE)
|
||||||
CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
|
CVAR(Bool, gl_texture, true, 0)
|
||||||
|
CVAR(Float, gl_mask_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
CVAR(Float, gl_mask_sprite_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
|
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -329,3 +329,4 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
||||||
|
|
|
@ -672,7 +672,7 @@ public:
|
||||||
virtual void EnableDepthTest(bool on) = 0; // used by 2D, portals and render hacks.
|
virtual void EnableDepthTest(bool on) = 0; // used by 2D, portals and render hacks.
|
||||||
virtual void EnableMultisampling(bool on) = 0; // only active for 2D
|
virtual void EnableMultisampling(bool on) = 0; // only active for 2D
|
||||||
virtual void EnableLineSmooth(bool on) = 0; // constant setting for each 2D drawer operation
|
virtual void EnableLineSmooth(bool on) = 0; // constant setting for each 2D drawer operation
|
||||||
virtual void EnableDrawBuffers(int count) = 0; // Used by SSAO and EnableDrawBufferAttachments
|
virtual void EnableDrawBuffers(int count, bool apply = false) = 0; // Used by SSAO and EnableDrawBufferAttachments
|
||||||
|
|
||||||
void SetColorMask(bool on)
|
void SetColorMask(bool on)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
|
|
||||||
|
|
||||||
EXTERN_CVAR(Bool,gl_enhanced_nightvision)
|
EXTERN_CVAR(Bool,gl_enhanced_nightvision)
|
||||||
EXTERN_CVAR(Int, screenblocks);
|
EXTERN_CVAR(Int, screenblocks);
|
||||||
EXTERN_CVAR(Bool, gl_texture)
|
|
||||||
EXTERN_CVAR(Int, gl_texture_filter)
|
EXTERN_CVAR(Int, gl_texture_filter)
|
||||||
EXTERN_CVAR(Float, gl_texture_filter_anisotropic)
|
EXTERN_CVAR(Float, gl_texture_filter_anisotropic)
|
||||||
EXTERN_CVAR(Int, gl_texture_format)
|
EXTERN_CVAR(Int, gl_texture_format)
|
||||||
|
|
|
@ -296,78 +296,6 @@ sector_t *PolyFrameBuffer::RenderView(player_t *player)
|
||||||
return retsec;
|
return retsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
sector_t *PolyFrameBuffer::RenderViewpoint(FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
|
||||||
{
|
|
||||||
// To do: this is virtually identical to FGLRenderer::RenderViewpoint and should be merged.
|
|
||||||
|
|
||||||
R_SetupFrame(mainvp, r_viewwindow, camera);
|
|
||||||
|
|
||||||
if (mainview && toscreen)
|
|
||||||
UpdateShadowMap();
|
|
||||||
|
|
||||||
// Update the attenuation flag of all light defaults for each viewpoint.
|
|
||||||
// This function will only do something if the setting differs.
|
|
||||||
FLightDefaults::SetAttenuationForLevel(!!(camera->Level->flags3 & LEVEL3_ATTENUATE));
|
|
||||||
|
|
||||||
// Render (potentially) multiple views for stereo 3d
|
|
||||||
// Fixme. The view offsetting should be done with a static table and not require setup of the entire render state for the mode.
|
|
||||||
auto vrmode = VRMode::GetVRMode(mainview && toscreen);
|
|
||||||
for (int eye_ix = 0; eye_ix < vrmode->mEyeCount; ++eye_ix)
|
|
||||||
{
|
|
||||||
const auto &eye = vrmode->mEyes[eye_ix];
|
|
||||||
SetViewportRects(bounds);
|
|
||||||
|
|
||||||
if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao
|
|
||||||
{
|
|
||||||
//mRenderState->SetRenderTarget(GetBuffers()->SceneColor.View.get(), GetBuffers()->SceneDepthStencil.View.get(), GetBuffers()->GetWidth(), GetBuffers()->GetHeight(), Poly_FORMAT_R16G16B16A16_SFLOAT, GetBuffers()->GetSceneSamples());
|
|
||||||
bool useSSAO = (gl_ssao != 0);
|
|
||||||
GetRenderState()->SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
|
||||||
GetRenderState()->EnableDrawBuffers(GetRenderState()->GetPassDrawBufferCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto di = HWDrawInfo::StartDrawInfo(mainvp.ViewLevel, nullptr, mainvp, nullptr);
|
|
||||||
auto &vp = di->Viewpoint;
|
|
||||||
|
|
||||||
di->Set3DViewport(*GetRenderState());
|
|
||||||
di->SetViewArea();
|
|
||||||
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
|
|
||||||
di->Viewpoint.FieldOfView = 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);
|
|
||||||
// Stereo mode specific viewpoint adjustment
|
|
||||||
vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees);
|
|
||||||
di->SetupView(*GetRenderState(), vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
|
|
||||||
|
|
||||||
di->ProcessScene(toscreen);
|
|
||||||
|
|
||||||
if (mainview)
|
|
||||||
{
|
|
||||||
PostProcess.Clock();
|
|
||||||
if (toscreen) di->EndDrawScene(mainvp.sector, *GetRenderState()); // do not call this for camera textures.
|
|
||||||
|
|
||||||
if (GetRenderState()->GetPassType() == GBUFFER_PASS) // Turn off ssao draw buffers
|
|
||||||
{
|
|
||||||
GetRenderState()->SetPassType(NORMAL_PASS);
|
|
||||||
GetRenderState()->EnableDrawBuffers(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//mPostprocess->BlitSceneToPostprocess(); // Copy the resulting scene to the current post process texture
|
|
||||||
|
|
||||||
PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector, *GetRenderState()); });
|
|
||||||
|
|
||||||
PostProcess.Unclock();
|
|
||||||
}
|
|
||||||
di->EndDrawInfo();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (vrmode->mEyeCount > 1)
|
|
||||||
mBuffers->BlitToEyeTexture(eye_ix);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return mainvp.sector;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
|
void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
|
||||||
{
|
{
|
||||||
|
@ -399,7 +327,7 @@ static uint8_t ToIntColorComponent(float v)
|
||||||
return clamp((int)(v * 255.0f + 0.5f), 0, 255);
|
return clamp((int)(v * 255.0f + 0.5f), 0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyFrameBuffer::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
void PolyFrameBuffer::PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||||
{
|
{
|
||||||
afterBloomDrawEndScene2D();
|
afterBloomDrawEndScene2D();
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,9 @@ public:
|
||||||
void TextureFilterChanged() override;
|
void TextureFilterChanged() override;
|
||||||
void BeginFrame() override;
|
void BeginFrame() override;
|
||||||
void BlurScene(float amount) override;
|
void BlurScene(float amount) override;
|
||||||
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||||
void AmbientOccludeScene(float m5) override;
|
void AmbientOccludeScene(float m5) override;
|
||||||
|
//void SetSceneRenderTarget(bool useSSAO) override;
|
||||||
|
|
||||||
IHardwareTexture *CreateHardwareTexture() override;
|
IHardwareTexture *CreateHardwareTexture() override;
|
||||||
FModelRenderer *CreateModelRenderer(int mli) override;
|
FModelRenderer *CreateModelRenderer(int mli) override;
|
||||||
|
@ -70,7 +71,6 @@ public:
|
||||||
} FrameDeleteList;
|
} FrameDeleteList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sector_t *RenderViewpoint(FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
|
||||||
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
||||||
void UpdateShadowMap();
|
void UpdateShadowMap();
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ void PolyRenderState::EnableLineSmooth(bool on)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyRenderState::EnableDrawBuffers(int count)
|
void PolyRenderState::EnableDrawBuffers(int count, bool apply)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
void EnableDepthTest(bool on) override;
|
void EnableDepthTest(bool on) override;
|
||||||
void EnableMultisampling(bool on) override;
|
void EnableMultisampling(bool on) override;
|
||||||
void EnableLineSmooth(bool on) override;
|
void EnableLineSmooth(bool on) override;
|
||||||
void EnableDrawBuffers(int count) override;
|
void EnableDrawBuffers(int count, bool apply) override;
|
||||||
|
|
||||||
void SetRenderTarget(DCanvas *canvas, PolyDepthStencil *depthStencil, bool topdown);
|
void SetRenderTarget(DCanvas *canvas, PolyDepthStencil *depthStencil, bool topdown);
|
||||||
void Bind(PolyDataBuffer *buffer, uint32_t offset, uint32_t length);
|
void Bind(PolyDataBuffer *buffer, uint32_t offset, uint32_t length);
|
||||||
|
|
|
@ -122,7 +122,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
||||||
DrawTexture(twod, fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
|
DrawTexture(twod, fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
|
||||||
screen->Draw2D();
|
screen->Draw2D();
|
||||||
screen->Clear2D();
|
screen->Clear2D();
|
||||||
screen->PostProcessScene(CM_DEFAULT, [&]() {
|
screen->PostProcessScene(true, CM_DEFAULT, [&]() {
|
||||||
SWRenderer->DrawRemainingPlayerSprites();
|
SWRenderer->DrawRemainingPlayerSprites();
|
||||||
screen->Draw2D();
|
screen->Draw2D();
|
||||||
screen->Clear2D();
|
screen->Clear2D();
|
||||||
|
@ -138,7 +138,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
||||||
int cm = CM_DEFAULT;
|
int cm = CM_DEFAULT;
|
||||||
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
||||||
if (map) cm = (int)(ptrdiff_t)(map - SpecialColormaps.Data()) + CM_FIRSTSPECIALCOLORMAP;
|
if (map) cm = (int)(ptrdiff_t)(map - SpecialColormaps.Data()) + CM_FIRSTSPECIALCOLORMAP;
|
||||||
screen->PostProcessScene(cm, [&]() { });
|
screen->PostProcessScene(true, cm, [&]() { });
|
||||||
|
|
||||||
SWRenderer->DrawRemainingPlayerSprites();
|
SWRenderer->DrawRemainingPlayerSprites();
|
||||||
screen->Draw2D();
|
screen->Draw2D();
|
||||||
|
|
|
@ -312,12 +312,16 @@ public:
|
||||||
virtual void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
virtual void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
||||||
virtual sector_t *RenderView(player_t *player) { return nullptr; }
|
virtual sector_t *RenderView(player_t *player) { return nullptr; }
|
||||||
virtual void AmbientOccludeScene(float m5) {}
|
virtual void AmbientOccludeScene(float m5) {}
|
||||||
|
virtual void FirstEye() {}
|
||||||
|
virtual void NextEye(int eyecount) {}
|
||||||
|
virtual void SetSceneRenderTarget(bool useSSAO) {}
|
||||||
|
virtual void UpdateShadowMap() {}
|
||||||
|
|
||||||
// Screen wiping
|
// Screen wiping
|
||||||
virtual FTexture *WipeStartScreen();
|
virtual FTexture *WipeStartScreen();
|
||||||
virtual FTexture *WipeEndScreen();
|
virtual FTexture *WipeEndScreen();
|
||||||
|
|
||||||
virtual void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) { if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D(); }
|
virtual void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) { if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D(); }
|
||||||
|
|
||||||
void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
|
void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,7 @@ void VkRenderState::EndFrame()
|
||||||
mStreamBufferWriter.Reset();
|
mStreamBufferWriter.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkRenderState::EnableDrawBuffers(int count)
|
void VkRenderState::EnableDrawBuffers(int count, bool apply)
|
||||||
{
|
{
|
||||||
if (mRenderTarget.DrawBuffers != count)
|
if (mRenderTarget.DrawBuffers != count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
void EnableDepthTest(bool on) override;
|
void EnableDepthTest(bool on) override;
|
||||||
void EnableMultisampling(bool on) override;
|
void EnableMultisampling(bool on) override;
|
||||||
void EnableLineSmooth(bool on) override;
|
void EnableLineSmooth(bool on) override;
|
||||||
void EnableDrawBuffers(int count) override;
|
void EnableDrawBuffers(int count, bool apply) override;
|
||||||
|
|
||||||
void BeginFrame();
|
void BeginFrame();
|
||||||
void SetRenderTarget(VkTextureImage *image, VulkanImageView *depthStencilView, int width, int height, VkFormat Format, VkSampleCountFlagBits samples);
|
void SetRenderTarget(VkTextureImage *image, VulkanImageView *depthStencilView, int width, int height, VkFormat Format, VkSampleCountFlagBits samples);
|
||||||
|
|
|
@ -436,79 +436,6 @@ sector_t *VulkanFrameBuffer::RenderView(player_t *player)
|
||||||
return retsec;
|
return retsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
sector_t *VulkanFrameBuffer::RenderViewpoint(FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
|
||||||
{
|
|
||||||
// To do: this is virtually identical to FGLRenderer::RenderViewpoint and should be merged.
|
|
||||||
|
|
||||||
R_SetupFrame(mainvp, r_viewwindow, camera);
|
|
||||||
|
|
||||||
if (mainview && toscreen)
|
|
||||||
UpdateShadowMap();
|
|
||||||
|
|
||||||
// Update the attenuation flag of all light defaults for each viewpoint.
|
|
||||||
// This function will only do something if the setting differs.
|
|
||||||
FLightDefaults::SetAttenuationForLevel(!!(camera->Level->flags3 & LEVEL3_ATTENUATE));
|
|
||||||
|
|
||||||
// Render (potentially) multiple views for stereo 3d
|
|
||||||
// Fixme. The view offsetting should be done with a static table and not require setup of the entire render state for the mode.
|
|
||||||
auto vrmode = VRMode::GetVRMode(mainview && toscreen);
|
|
||||||
for (int eye_ix = 0; eye_ix < vrmode->mEyeCount; ++eye_ix)
|
|
||||||
{
|
|
||||||
const auto &eye = vrmode->mEyes[eye_ix];
|
|
||||||
screen->SetViewportRects(bounds);
|
|
||||||
|
|
||||||
if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao
|
|
||||||
{
|
|
||||||
mRenderState->SetRenderTarget(&GetBuffers()->SceneColor, GetBuffers()->SceneDepthStencil.View.get(), GetBuffers()->GetWidth(), GetBuffers()->GetHeight(), VK_FORMAT_R16G16B16A16_SFLOAT, GetBuffers()->GetSceneSamples());
|
|
||||||
bool useSSAO = (gl_ssao != 0);
|
|
||||||
GetRenderState()->SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
|
||||||
GetRenderState()->EnableDrawBuffers(GetRenderState()->GetPassDrawBufferCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto di = HWDrawInfo::StartDrawInfo(mainvp.ViewLevel, nullptr, mainvp, nullptr);
|
|
||||||
auto &vp = di->Viewpoint;
|
|
||||||
|
|
||||||
di->Set3DViewport(*GetRenderState());
|
|
||||||
di->SetViewArea();
|
|
||||||
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
|
|
||||||
di->Viewpoint.FieldOfView = 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);
|
|
||||||
// Stereo mode specific viewpoint adjustment
|
|
||||||
vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees);
|
|
||||||
di->SetupView(*GetRenderState(), vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
|
|
||||||
|
|
||||||
di->ProcessScene(toscreen);
|
|
||||||
|
|
||||||
if (mainview)
|
|
||||||
{
|
|
||||||
PostProcess.Clock();
|
|
||||||
if (toscreen) di->EndDrawScene(mainvp.sector, *GetRenderState()); // do not call this for camera textures.
|
|
||||||
|
|
||||||
if (GetRenderState()->GetPassType() == GBUFFER_PASS) // Turn off ssao draw buffers
|
|
||||||
{
|
|
||||||
GetRenderState()->SetPassType(NORMAL_PASS);
|
|
||||||
GetRenderState()->EnableDrawBuffers(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
mPostprocess->BlitSceneToPostprocess(); // Copy the resulting scene to the current post process texture
|
|
||||||
|
|
||||||
PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector, *GetRenderState()); });
|
|
||||||
|
|
||||||
PostProcess.Unclock();
|
|
||||||
}
|
|
||||||
di->EndDrawInfo();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (vrmode->mEyeCount > 1)
|
|
||||||
mBuffers->BlitToEyeTexture(eye_ix);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return mainvp.sector;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
|
void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
|
||||||
{
|
{
|
||||||
auto BaseLayer = static_cast<VkHardwareTexture*>(tex->GetHardwareTexture(0, 0));
|
auto BaseLayer = static_cast<VkHardwareTexture*>(tex->GetHardwareTexture(0, 0));
|
||||||
|
@ -544,8 +471,9 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint
|
||||||
tex->SetUpdated(true);
|
tex->SetUpdated(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
void VulkanFrameBuffer::PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||||
{
|
{
|
||||||
|
if (!swscene) mPostprocess->BlitSceneToPostprocess(); // Copy the resulting scene to the current post process texture
|
||||||
mPostprocess->PostProcessScene(fixedcm, afterBloomDrawEndScene2D);
|
mPostprocess->PostProcessScene(fixedcm, afterBloomDrawEndScene2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,3 +875,8 @@ void VulkanFrameBuffer::AmbientOccludeScene(float m5)
|
||||||
{
|
{
|
||||||
mPostprocess->AmbientOccludeScene(m5);
|
mPostprocess->AmbientOccludeScene(m5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VulkanFrameBuffer::SetSceneRenderTarget(bool useSSAO)
|
||||||
|
{
|
||||||
|
mRenderState->SetRenderTarget(&GetBuffers()->SceneColor, GetBuffers()->SceneDepthStencil.View.get(), GetBuffers()->GetWidth(), GetBuffers()->GetHeight(), VK_FORMAT_R16G16B16A16_SFLOAT, GetBuffers()->GetSceneSamples());
|
||||||
|
}
|
||||||
|
|
|
@ -87,8 +87,10 @@ public:
|
||||||
void StartPrecaching() override;
|
void StartPrecaching() override;
|
||||||
void BeginFrame() override;
|
void BeginFrame() override;
|
||||||
void BlurScene(float amount) override;
|
void BlurScene(float amount) override;
|
||||||
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||||
void AmbientOccludeScene(float m5) override;
|
void AmbientOccludeScene(float m5) override;
|
||||||
|
void SetSceneRenderTarget(bool useSSAO) override;
|
||||||
|
void UpdateShadowMap() override;
|
||||||
|
|
||||||
IHardwareTexture *CreateHardwareTexture() override;
|
IHardwareTexture *CreateHardwareTexture() override;
|
||||||
FMaterial* CreateMaterial(FGameTexture* tex, int scaleflags) override;
|
FMaterial* CreateMaterial(FGameTexture* tex, int scaleflags) override;
|
||||||
|
@ -113,12 +115,10 @@ public:
|
||||||
void UpdateGpuStats();
|
void UpdateGpuStats();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sector_t *RenderViewpoint(FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
|
||||||
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
||||||
void PrintStartupLog();
|
void PrintStartupLog();
|
||||||
void CreateFanToTrisIndexBuffer();
|
void CreateFanToTrisIndexBuffer();
|
||||||
void CopyScreenToBuffer(int w, int h, void *data);
|
void CopyScreenToBuffer(int w, int h, void *data);
|
||||||
void UpdateShadowMap();
|
|
||||||
void DeleteFrameObjects();
|
void DeleteFrameObjects();
|
||||||
void FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish, bool lastsubmit);
|
void FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish, bool lastsubmit);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue