- moved VR code and IntRect to 'common'

This commit is contained in:
Christoph Oelckers 2020-04-26 10:26:29 +02:00
parent 4b56714199
commit 686aa9779d
23 changed files with 108 additions and 85 deletions

View file

@ -973,7 +973,6 @@ set (PCH_SOURCES
rendering/hwrenderer/utility/hw_draw2d.cpp rendering/hwrenderer/utility/hw_draw2d.cpp
rendering/hwrenderer/utility/hw_lighting.cpp rendering/hwrenderer/utility/hw_lighting.cpp
rendering/hwrenderer/utility/hw_shaderpatcher.cpp rendering/hwrenderer/utility/hw_shaderpatcher.cpp
rendering/hwrenderer/utility/hw_vrmodes.cpp
maploader/edata.cpp maploader/edata.cpp
maploader/specials.cpp maploader/specials.cpp
maploader/maploader.cpp maploader/maploader.cpp
@ -1145,6 +1144,7 @@ set (PCH_SOURCES
common/objects/dobjgc.cpp common/objects/dobjgc.cpp
common/objects/dobjtype.cpp common/objects/dobjtype.cpp
common/rendering/r_videoscale.cpp common/rendering/r_videoscale.cpp
common/rendering/hwrenderer/data/hw_vrmodes.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp

View file

@ -26,10 +26,10 @@
*/ */
#include "vectors.h" // RAD2DEG #include "vectors.h" // RAD2DEG
#include "doomtype.h" // M_PI
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "hw_vrmodes.h" #include "hw_vrmodes.h"
#include "v_video.h" #include "v_video.h"
#include "version.h"
// Set up 3D-specific console variables: // Set up 3D-specific console variables:
CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG)
@ -59,6 +59,7 @@ static VRMode vrmi_checker = { 2, isqrt2, isqrt2, 1.f,{ { -.5f, 1.f },{ .5f, 1.f
const VRMode *VRMode::GetVRMode(bool toscreen) const VRMode *VRMode::GetVRMode(bool toscreen)
{ {
#ifdef VR3D_ENABLED
switch (toscreen && vid_rendermode == 4 ? vr_mode : 0) switch (toscreen && vid_rendermode == 4 ? vr_mode : 0)
{ {
default: default:
@ -91,6 +92,9 @@ const VRMode *VRMode::GetVRMode(bool toscreen)
case VR_CHECKERINTERLEAVED: case VR_CHECKERINTERLEAVED:
return &vrmi_checker; return &vrmi_checker;
} }
#else
return &vrmi_mono;
#endif
} }
void VRMode::AdjustViewport(DFrameBuffer *screen) const void VRMode::AdjustViewport(DFrameBuffer *screen) const

View file

@ -3,6 +3,7 @@
#include "hwrenderer/data/shaderuniforms.h" #include "hwrenderer/data/shaderuniforms.h"
#include <memory> #include <memory>
#include <map> #include <map>
#include "intrect.h"
struct PostProcessShader; struct PostProcessShader;
@ -777,15 +778,6 @@ struct ShadowMapUniforms
} }
}; };
class PPShadowMap
{
public:
void Update(PPRenderState *renderstate);
private:
PPShader ShadowMap = { "shaders/glsl/shadowmap.fp", "", ShadowMapUniforms::Desc() };
};
class PPCustomShaderInstance class PPCustomShaderInstance
{ {
public: public:
@ -819,6 +811,18 @@ private:
std::vector<std::unique_ptr<PPCustomShaderInstance>> mShaders; std::vector<std::unique_ptr<PPCustomShaderInstance>> mShaders;
}; };
class PPShadowMap
{
public:
void Update(PPRenderState* renderstate);
private:
PPShader ShadowMap = { "shaders/glsl/shadowmap.fp", "", ShadowMapUniforms::Desc() };
};
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
class Postprocess class Postprocess

View file

@ -0,0 +1,31 @@
#pragma once
struct IntRect
{
int left, top;
int width, height;
void Offset(int xofs, int yofs)
{
left += xofs;
top += yofs;
}
void AddToRect(int x, int y)
{
if (x < left)
left = x;
if (x > left + width)
width = x - left;
if (y < top)
top = y;
if (y > top + height)
height = y - top;
}
};

View file

@ -47,6 +47,7 @@
#include "doomstat.h" #include "doomstat.h"
#include "gi.h" #include "gi.h"
#include "d_main.h" #include "d_main.h"
#include "v_video.h"
#if !defined _MSC_VER && !defined __APPLE__ #if !defined _MSC_VER && !defined __APPLE__
#include "i_system.h" // for SHARE_DIR #include "i_system.h" // for SHARE_DIR
#endif // !_MSC_VER && !__APPLE__ #endif // !_MSC_VER && !__APPLE__
@ -560,6 +561,16 @@ void FGameConfigFile::DoGlobalSetup ()
} }
} }
} }
if (last < 220)
{
auto var = FindCVar("Gamma", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Float);
vid_gamma = v.Float;
}
}
} }
} }
} }

View file

@ -59,7 +59,7 @@ int BlendR, BlendG, BlendB, BlendA;
/**************************/ /**************************/
uint8_t newgamma[256]; uint8_t newgamma[256];
CUSTOM_CVAR (Float, Gamma, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CUSTOM_CVAR (Float, vid_gamma, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{ {
if (self == 0.f) if (self == 0.f)
{ // Gamma values of 0 are illegal. { // Gamma values of 0 are illegal.
@ -78,13 +78,13 @@ CCMD (bumpgamma)
// [RH] Gamma correction tables are now generated on the fly for *any* gamma level // [RH] Gamma correction tables are now generated on the fly for *any* gamma level
// Q: What are reasonable limits to use here? // Q: What are reasonable limits to use here?
float newgamma = Gamma + 0.1f; float newgamma = vid_gamma + 0.1f;
if (newgamma > 3.0) if (newgamma > 3.0)
newgamma = 1.0; newgamma = 1.0;
Gamma = newgamma; vid_gamma = newgamma;
Printf ("Gamma correction level %g\n", *Gamma); Printf ("Gamma correction level %g\n", *vid_gamma);
} }

View file

@ -33,7 +33,7 @@
#include "gl/shaders/gl_shaderprogram.h" #include "gl/shaders/gl_shaderprogram.h"
#include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess.h"
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "gl/textures/gl_hwtexture.h" #include "gl/textures/gl_hwtexture.h"
#include "r_videoscale.h" #include "r_videoscale.h"
@ -62,7 +62,7 @@ void FGLRenderer::PostProcessScene(int fixedcm, const std::function<void()> &aft
hw_postprocess.Pass1(&renderstate, fixedcm, sceneWidth, sceneHeight); hw_postprocess.Pass1(&renderstate, fixedcm, sceneWidth, sceneHeight);
mBuffers->BindCurrentFB(); mBuffers->BindCurrentFB();
afterBloomDrawEndScene2D(); if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D();
hw_postprocess.Pass2(&renderstate, fixedcm, sceneWidth, sceneHeight); hw_postprocess.Pass2(&renderstate, fixedcm, sceneWidth, sceneHeight);
} }
@ -199,7 +199,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
} }
else else
{ {
mPresentShader->Uniforms->InvGamma = 1.0f / clamp<float>(Gamma, 0.1f, 4.f); mPresentShader->Uniforms->InvGamma = 1.0f / clamp<float>(vid_gamma, 0.1f, 4.f);
mPresentShader->Uniforms->Contrast = clamp<float>(vid_contrast, 0.1f, 3.f); mPresentShader->Uniforms->Contrast = clamp<float>(vid_contrast, 0.1f, 3.f);
mPresentShader->Uniforms->Brightness = clamp<float>(vid_brightness, -0.8f, 0.8f); mPresentShader->Uniforms->Brightness = clamp<float>(vid_brightness, -0.8f, 0.8f);
mPresentShader->Uniforms->Saturation = clamp<float>(vid_saturation, -15.0f, 15.f); mPresentShader->Uniforms->Saturation = clamp<float>(vid_saturation, -15.0f, 15.f);

View file

@ -48,7 +48,7 @@
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "gl/shaders/gl_shaderprogram.h" #include "gl/shaders/gl_shaderprogram.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_skydome.h"
#include "hwrenderer/scene/hw_fakeflat.h" #include "hwrenderer/scene/hw_fakeflat.h"

View file

@ -28,7 +28,7 @@
#include "gl_system.h" #include "gl_system.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/renderer/gl_postprocessstate.h" #include "gl/renderer/gl_postprocessstate.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
@ -162,7 +162,7 @@ void FGLRenderer::prepareInterleavedPresent(FPresentShaderBase& shader)
} }
else else
{ {
shader.Uniforms->InvGamma = 1.0f / clamp<float>(Gamma, 0.1f, 4.f); shader.Uniforms->InvGamma = 1.0f / clamp<float>(vid_gamma, 0.1f, 4.f);
shader.Uniforms->Contrast = clamp<float>(vid_contrast, 0.1f, 3.f); shader.Uniforms->Contrast = clamp<float>(vid_contrast, 0.1f, 3.f);
shader.Uniforms->Brightness = clamp<float>(vid_brightness, -0.8f, 0.8f); shader.Uniforms->Brightness = clamp<float>(vid_brightness, -0.8f, 0.8f);
shader.Uniforms->Saturation = clamp<float>(vid_saturation, -15.0f, 15.0f); shader.Uniforms->Saturation = clamp<float>(vid_saturation, -15.0f, 15.0f);

View file

@ -38,7 +38,7 @@
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "gl/textures/gl_samplers.h" #include "gl/textures/gl_samplers.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "hwrenderer/models/hw_models.h" #include "hwrenderer/models/hw_models.h"
#include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_skydome.h"
#include "hwrenderer/scene/hw_fakeflat.h" #include "hwrenderer/scene/hw_fakeflat.h"

View file

@ -14,7 +14,6 @@
#include "hw_ihwtexture.h" #include "hw_ihwtexture.h"
class FCanvasTexture; class FCanvasTexture;
class AActor;
namespace OpenGLRenderer namespace OpenGLRenderer
{ {

View file

@ -29,6 +29,7 @@
#include "g_levellocals.h" #include "g_levellocals.h"
#include "v_video.h" #include "v_video.h"
#include "a_dynlight.h" #include "a_dynlight.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
/* /*
The 1D shadow maps are stored in a 1024x1024 texture as float depth values (R32F). The 1D shadow maps are stored in a 1024x1024 texture as float depth values (R32F).
@ -224,3 +225,23 @@ IShadowMap::~IShadowMap()
Reset(); Reset();
} }
void PPShadowMap::Update(PPRenderState* renderstate)
{
ShadowMapUniforms uniforms;
uniforms.ShadowmapQuality = (float)gl_shadowmap_quality;
uniforms.NodesCount = screen->mShadowMap.NodesCount();
renderstate->PushGroup("shadowmap");
renderstate->Clear();
renderstate->Shader = &ShadowMap;
renderstate->Uniforms.Set(uniforms);
renderstate->Viewport = { 0, 0, gl_shadowmap_quality, 1024 };
renderstate->SetShadowMapBuffers(true);
renderstate->SetOutputShadowMap();
renderstate->SetNoBlend();
renderstate->Draw();
renderstate->PopGroup();
}

View file

@ -46,7 +46,7 @@
#include "hwrenderer/scene/hw_fakeflat.h" #include "hwrenderer/scene/hw_fakeflat.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 "hw_vrmodes.h"
EXTERN_CVAR(Bool, cl_capfps) EXTERN_CVAR(Bool, cl_capfps)
extern bool NoInterpolateView; extern bool NoInterpolateView;
@ -181,7 +181,7 @@ void DoWriteSavePic(FileWriter* file, ESSType ssformat, uint8_t* scr, int width,
pitch *= -1; pitch *= -1;
} }
M_CreatePNG(file, scr, ssformat == SS_PAL ? palette : nullptr, ssformat, width, height, pitch, Gamma); M_CreatePNG(file, scr, ssformat == SS_PAL ? palette : nullptr, ssformat, width, height, pitch, vid_gamma);
} }
//=========================================================================== //===========================================================================

View file

@ -23,27 +23,7 @@
#include "d_player.h" #include "d_player.h"
#include "hwrenderer/postprocessing/hw_postprocessshader.h" #include "hwrenderer/postprocessing/hw_postprocessshader.h"
#include "g_levellocals.h" #include "g_levellocals.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
void PPShadowMap::Update(PPRenderState *renderstate)
{
ShadowMapUniforms uniforms;
uniforms.ShadowmapQuality = (float)gl_shadowmap_quality;
uniforms.NodesCount = screen->mShadowMap.NodesCount();
renderstate->PushGroup("shadowmap");
renderstate->Clear();
renderstate->Shader = &ShadowMap;
renderstate->Uniforms.Set(uniforms);
renderstate->Viewport = { 0, 0, gl_shadowmap_quality, 1024 };
renderstate->SetShadowMapBuffers(true);
renderstate->SetOutputShadowMap();
renderstate->SetNoBlend();
renderstate->Draw();
renderstate->PopGroup();
}
static bool IsConsolePlayer(player_t *player) static bool IsConsolePlayer(player_t *player)
{ {

View file

@ -41,7 +41,7 @@
#include "hwrenderer/data/hw_viewpointbuffer.h" #include "hwrenderer/data/hw_viewpointbuffer.h"
#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/dynlights/hw_lightbuffer.h" #include "hwrenderer/dynlights/hw_lightbuffer.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "hw_clipper.h" #include "hw_clipper.h"
EXTERN_CVAR(Float, r_visibility) EXTERN_CVAR(Float, r_visibility)

View file

@ -284,8 +284,8 @@ void FSkyVertexBuffer::CreateDome()
void FSkyVertexBuffer::SetupMatrices(HWDrawInfo *di, FGameTexture *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelMatrix, VSMatrix &textureMatrix) void FSkyVertexBuffer::SetupMatrices(HWDrawInfo *di, FGameTexture *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelMatrix, VSMatrix &textureMatrix)
{ {
int texw = tex->GetDisplayWidth(); float texw = tex->GetDisplayWidth();
int texh = tex->GetDisplayHeight(); float texh = tex->GetDisplayHeight();
modelMatrix.loadIdentity(); modelMatrix.loadIdentity();
modelMatrix.rotate(-180.0f + x_offset, 0.f, 1.f, 0.f); modelMatrix.rotate(-180.0f + x_offset, 0.f, 1.f, 0.f);

View file

@ -30,7 +30,7 @@
#include "i_video.h" #include "i_video.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "hwrenderer/models/hw_models.h" #include "hwrenderer/models/hw_models.h"
#include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_skydome.h"

View file

@ -41,6 +41,7 @@
#include "renderstyle.h" #include "renderstyle.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
#include "intrect.h"
#include "hwrenderer/dynlights/hw_shadowmap.h" #include "hwrenderer/dynlights/hw_shadowmap.h"
@ -78,35 +79,6 @@ enum EHWCaps
}; };
struct IntRect
{
int left, top;
int width, height;
void Offset(int xofs, int yofs)
{
left += xofs;
top += yofs;
}
void AddToRect(int x, int y)
{
if (x < left)
left = x;
if (x > left + width)
width = x - left;
if (y < top)
top = y;
if (y > top + height)
height = y - top;
}
};
extern int DisplayWidth, DisplayHeight; extern int DisplayWidth, DisplayHeight;
void V_UpdateModeSize (int width, int height); void V_UpdateModeSize (int width, int height);
@ -366,7 +338,7 @@ extern DFrameBuffer *screen;
#define SCREENHEIGHT (screen->GetHeight ()) #define SCREENHEIGHT (screen->GetHeight ())
#define SCREENPITCH (screen->GetPitch ()) #define SCREENPITCH (screen->GetPitch ())
EXTERN_CVAR (Float, Gamma) EXTERN_CVAR (Float, vid_gamma)
// Allocates buffer screens, call before R_Init. // Allocates buffer screens, call before R_Init.

View file

@ -32,7 +32,7 @@
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess.h"
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "r_videoscale.h" #include "r_videoscale.h"
#include "filesystem.h" #include "filesystem.h"
@ -201,7 +201,7 @@ void VkPostprocess::DrawPresentTexture(const IntRect &box, bool applyGamma, bool
} }
else else
{ {
uniforms.InvGamma = 1.0f / clamp<float>(Gamma, 0.1f, 4.f); uniforms.InvGamma = 1.0f / clamp<float>(vid_gamma, 0.1f, 4.f);
uniforms.Contrast = clamp<float>(vid_contrast, 0.1f, 3.f); uniforms.Contrast = clamp<float>(vid_contrast, 0.1f, 3.f);
uniforms.Brightness = clamp<float>(vid_brightness, -0.8f, 0.8f); uniforms.Brightness = clamp<float>(vid_brightness, -0.8f, 0.8f);
uniforms.Saturation = clamp<float>(vid_saturation, -15.0f, 15.f); uniforms.Saturation = clamp<float>(vid_saturation, -15.0f, 15.f);

View file

@ -32,7 +32,7 @@
#include "v_text.h" #include "v_text.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_vrmodes.h"
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "hwrenderer/models/hw_models.h" #include "hwrenderer/models/hw_models.h"
#include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_skydome.h"

View file

@ -65,7 +65,7 @@ const char *GetVersionString();
// Version stored in the ini's [LastRun] section. // Version stored in the ini's [LastRun] section.
// Bump it if you made some configuration change that you want to // Bump it if you made some configuration change that you want to
// be able to migrate in FGameConfigFile::DoGlobalSetup(). // be able to migrate in FGameConfigFile::DoGlobalSetup().
#define LASTRUNVERSION "219" #define LASTRUNVERSION "220"
// Protocol version used in demos. // Protocol version used in demos.
// Bump it if you change existing DEM_ commands or add new ones. // Bump it if you change existing DEM_ commands or add new ones.
@ -95,6 +95,7 @@ const char *GetVersionString();
#define BASEWAD "gzdoom.pk3" #define BASEWAD "gzdoom.pk3"
#define OPTIONALWAD "game_support.pk3" #define OPTIONALWAD "game_support.pk3"
#define GZDOOM 1 #define GZDOOM 1
#define VR3D_ENABLED
// More stuff that needs to be different for derivatives. // More stuff that needs to be different for derivatives.
#define GAMENAME "GZDoom" #define GAMENAME "GZDoom"

View file

@ -926,7 +926,7 @@ OptionMenu "VideoOptions" protected
StaticText " " StaticText " "
Slider "$DSPLYMNU_SCREENSIZE", "screenblocks", 3.0, 12.0, 1.0, 0 Slider "$DSPLYMNU_SCREENSIZE", "screenblocks", 3.0, 12.0, 1.0, 0
Slider "$DSPLYMNU_GAMMA", "Gamma", 0.75, 3.0, 0.05, 2 Slider "$DSPLYMNU_GAMMA", "vid_gamma", 0.75, 3.0, 0.05, 2
Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05,2 Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05,2
Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1
Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25, 2 Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25, 2