diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1f9c4e7b49..426cb505ff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -973,7 +973,6 @@ set (PCH_SOURCES rendering/hwrenderer/utility/hw_draw2d.cpp rendering/hwrenderer/utility/hw_lighting.cpp rendering/hwrenderer/utility/hw_shaderpatcher.cpp - rendering/hwrenderer/utility/hw_vrmodes.cpp maploader/edata.cpp maploader/specials.cpp maploader/maploader.cpp @@ -1145,6 +1144,7 @@ set (PCH_SOURCES common/objects/dobjgc.cpp common/objects/dobjtype.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_cvars.cpp diff --git a/src/rendering/hwrenderer/utility/hw_vrmodes.cpp b/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp similarity index 98% rename from src/rendering/hwrenderer/utility/hw_vrmodes.cpp rename to src/common/rendering/hwrenderer/data/hw_vrmodes.cpp index ebb2aad9fd..c57a6297e7 100644 --- a/src/rendering/hwrenderer/utility/hw_vrmodes.cpp +++ b/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp @@ -26,10 +26,10 @@ */ #include "vectors.h" // RAD2DEG -#include "doomtype.h" // M_PI #include "hwrenderer/utility/hw_cvars.h" #include "hw_vrmodes.h" #include "v_video.h" +#include "version.h" // Set up 3D-specific console variables: 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) { +#ifdef VR3D_ENABLED switch (toscreen && vid_rendermode == 4 ? vr_mode : 0) { default: @@ -91,6 +92,9 @@ const VRMode *VRMode::GetVRMode(bool toscreen) case VR_CHECKERINTERLEAVED: return &vrmi_checker; } +#else + return &vrmi_mono; +#endif } void VRMode::AdjustViewport(DFrameBuffer *screen) const diff --git a/src/rendering/hwrenderer/utility/hw_vrmodes.h b/src/common/rendering/hwrenderer/data/hw_vrmodes.h similarity index 100% rename from src/rendering/hwrenderer/utility/hw_vrmodes.h rename to src/common/rendering/hwrenderer/data/hw_vrmodes.h diff --git a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h index 8c74af83e5..7b715c5b2e 100644 --- a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h +++ b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.h @@ -3,6 +3,7 @@ #include "hwrenderer/data/shaderuniforms.h" #include #include +#include "intrect.h" 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 { public: @@ -819,6 +811,18 @@ private: std::vector> mShaders; }; +class PPShadowMap +{ +public: + void Update(PPRenderState* renderstate); + +private: + PPShader ShadowMap = { "shaders/glsl/shadowmap.fp", "", ShadowMapUniforms::Desc() }; +}; + + + + ///////////////////////////////////////////////////////////////////////////// class Postprocess diff --git a/src/common/utility/intrect.h b/src/common/utility/intrect.h new file mode 100644 index 0000000000..3cda7613e6 --- /dev/null +++ b/src/common/utility/intrect.h @@ -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; + } + + +}; + diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index a04264dbef..7ea9734ae4 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -47,6 +47,7 @@ #include "doomstat.h" #include "gi.h" #include "d_main.h" +#include "v_video.h" #if !defined _MSC_VER && !defined __APPLE__ #include "i_system.h" // for SHARE_DIR #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; + } + + } } } } diff --git a/src/r_data/v_palette.cpp b/src/r_data/v_palette.cpp index 2c78131e36..1b007099b5 100644 --- a/src/r_data/v_palette.cpp +++ b/src/r_data/v_palette.cpp @@ -59,7 +59,7 @@ int BlendR, BlendG, BlendB, BlendA; /**************************/ 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) { // 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 // Q: What are reasonable limits to use here? - float newgamma = Gamma + 0.1f; + float newgamma = vid_gamma + 0.1f; if (newgamma > 3.0) newgamma = 1.0; - Gamma = newgamma; - Printf ("Gamma correction level %g\n", *Gamma); + vid_gamma = newgamma; + Printf ("Gamma correction level %g\n", *vid_gamma); } diff --git a/src/rendering/gl/renderer/gl_postprocess.cpp b/src/rendering/gl/renderer/gl_postprocess.cpp index 274667c321..4c4025df5a 100644 --- a/src/rendering/gl/renderer/gl_postprocess.cpp +++ b/src/rendering/gl/renderer/gl_postprocess.cpp @@ -33,7 +33,7 @@ #include "gl/shaders/gl_shaderprogram.h" #include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h" -#include "hwrenderer/utility/hw_vrmodes.h" +#include "hw_vrmodes.h" #include "hwrenderer/data/flatvertices.h" #include "gl/textures/gl_hwtexture.h" #include "r_videoscale.h" @@ -62,7 +62,7 @@ void FGLRenderer::PostProcessScene(int fixedcm, const std::function &aft hw_postprocess.Pass1(&renderstate, fixedcm, sceneWidth, sceneHeight); mBuffers->BindCurrentFB(); - afterBloomDrawEndScene2D(); + if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D(); hw_postprocess.Pass2(&renderstate, fixedcm, sceneWidth, sceneHeight); } @@ -199,7 +199,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma) } else { - mPresentShader->Uniforms->InvGamma = 1.0f / clamp(Gamma, 0.1f, 4.f); + mPresentShader->Uniforms->InvGamma = 1.0f / clamp(vid_gamma, 0.1f, 4.f); mPresentShader->Uniforms->Contrast = clamp(vid_contrast, 0.1f, 3.f); mPresentShader->Uniforms->Brightness = clamp(vid_brightness, -0.8f, 0.8f); mPresentShader->Uniforms->Saturation = clamp(vid_saturation, -15.0f, 15.f); diff --git a/src/rendering/gl/renderer/gl_renderer.cpp b/src/rendering/gl/renderer/gl_renderer.cpp index acaed25007..a101f7ec7e 100644 --- a/src/rendering/gl/renderer/gl_renderer.cpp +++ b/src/rendering/gl/renderer/gl_renderer.cpp @@ -48,7 +48,7 @@ #include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderbuffers.h" #include "gl/shaders/gl_shaderprogram.h" -#include "hwrenderer/utility/hw_vrmodes.h" +#include "hw_vrmodes.h" #include "hwrenderer/data/flatvertices.h" #include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_fakeflat.h" diff --git a/src/rendering/gl/renderer/gl_stereo3d.cpp b/src/rendering/gl/renderer/gl_stereo3d.cpp index 00f830b8f3..6df5ee69e0 100644 --- a/src/rendering/gl/renderer/gl_stereo3d.cpp +++ b/src/rendering/gl/renderer/gl_stereo3d.cpp @@ -28,7 +28,7 @@ #include "gl_system.h" #include "gl/renderer/gl_renderer.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/renderer/gl_postprocessstate.h" #include "gl/system/gl_framebuffer.h" @@ -162,7 +162,7 @@ void FGLRenderer::prepareInterleavedPresent(FPresentShaderBase& shader) } else { - shader.Uniforms->InvGamma = 1.0f / clamp(Gamma, 0.1f, 4.f); + shader.Uniforms->InvGamma = 1.0f / clamp(vid_gamma, 0.1f, 4.f); shader.Uniforms->Contrast = clamp(vid_contrast, 0.1f, 3.f); shader.Uniforms->Brightness = clamp(vid_brightness, -0.8f, 0.8f); shader.Uniforms->Saturation = clamp(vid_saturation, -15.0f, 15.0f); diff --git a/src/rendering/gl/system/gl_framebuffer.cpp b/src/rendering/gl/system/gl_framebuffer.cpp index 0ec8d4eafd..20b6319381 100644 --- a/src/rendering/gl/system/gl_framebuffer.cpp +++ b/src/rendering/gl/system/gl_framebuffer.cpp @@ -38,7 +38,7 @@ #include "gl/renderer/gl_renderbuffers.h" #include "gl/textures/gl_samplers.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/scene/hw_skydome.h" #include "hwrenderer/scene/hw_fakeflat.h" diff --git a/src/rendering/gl/textures/gl_hwtexture.h b/src/rendering/gl/textures/gl_hwtexture.h index 727774672c..d25131d777 100644 --- a/src/rendering/gl/textures/gl_hwtexture.h +++ b/src/rendering/gl/textures/gl_hwtexture.h @@ -14,7 +14,6 @@ #include "hw_ihwtexture.h" class FCanvasTexture; -class AActor; namespace OpenGLRenderer { diff --git a/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp b/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp index e9fb4686f5..99bdaed530 100644 --- a/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp +++ b/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp @@ -29,6 +29,7 @@ #include "g_levellocals.h" #include "v_video.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). @@ -224,3 +225,23 @@ IShadowMap::~IShadowMap() 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(); +} + diff --git a/src/rendering/hwrenderer/hw_entrypoint.cpp b/src/rendering/hwrenderer/hw_entrypoint.cpp index e5b0411b5d..c2e06a8302 100644 --- a/src/rendering/hwrenderer/hw_entrypoint.cpp +++ b/src/rendering/hwrenderer/hw_entrypoint.cpp @@ -46,7 +46,7 @@ #include "hwrenderer/scene/hw_fakeflat.h" #include "hwrenderer/scene/hw_clipper.h" #include "hwrenderer/scene/hw_portal.h" -#include "hwrenderer/utility/hw_vrmodes.h" +#include "hw_vrmodes.h" EXTERN_CVAR(Bool, cl_capfps) extern bool NoInterpolateView; @@ -181,7 +181,7 @@ void DoWriteSavePic(FileWriter* file, ESSType ssformat, uint8_t* scr, int width, 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); } //=========================================================================== diff --git a/src/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp b/src/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp index 9b90fbd622..f8e6e3e8bd 100644 --- a/src/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp +++ b/src/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp @@ -23,27 +23,7 @@ #include "d_player.h" #include "hwrenderer/postprocessing/hw_postprocessshader.h" #include "g_levellocals.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(); -} - +#include "hwrenderer/postprocessing/hw_postprocess.h" static bool IsConsolePlayer(player_t *player) { diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index e1697adec3..2df708ca91 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -41,7 +41,7 @@ #include "hwrenderer/data/hw_viewpointbuffer.h" #include "hwrenderer/data/flatvertices.h" #include "hwrenderer/dynlights/hw_lightbuffer.h" -#include "hwrenderer/utility/hw_vrmodes.h" +#include "hw_vrmodes.h" #include "hw_clipper.h" EXTERN_CVAR(Float, r_visibility) diff --git a/src/rendering/hwrenderer/scene/hw_skydome.cpp b/src/rendering/hwrenderer/scene/hw_skydome.cpp index 58f25f5329..e0e1103294 100644 --- a/src/rendering/hwrenderer/scene/hw_skydome.cpp +++ b/src/rendering/hwrenderer/scene/hw_skydome.cpp @@ -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) { - int texw = tex->GetDisplayWidth(); - int texh = tex->GetDisplayHeight(); + float texw = tex->GetDisplayWidth(); + float texh = tex->GetDisplayHeight(); modelMatrix.loadIdentity(); modelMatrix.rotate(-180.0f + x_offset, 0.f, 1.f, 0.f); diff --git a/src/rendering/polyrenderer/backend/poly_framebuffer.cpp b/src/rendering/polyrenderer/backend/poly_framebuffer.cpp index 24aea91793..6091b4ed97 100644 --- a/src/rendering/polyrenderer/backend/poly_framebuffer.cpp +++ b/src/rendering/polyrenderer/backend/poly_framebuffer.cpp @@ -30,7 +30,7 @@ #include "i_video.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/models/hw_models.h" #include "hwrenderer/scene/hw_skydome.h" diff --git a/src/rendering/v_video.h b/src/rendering/v_video.h index dc98b80e54..0fa592ff38 100644 --- a/src/rendering/v_video.h +++ b/src/rendering/v_video.h @@ -41,6 +41,7 @@ #include "renderstyle.h" #include "c_cvars.h" #include "v_2ddrawer.h" +#include "intrect.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; void V_UpdateModeSize (int width, int height); @@ -366,7 +338,7 @@ extern DFrameBuffer *screen; #define SCREENHEIGHT (screen->GetHeight ()) #define SCREENPITCH (screen->GetPitch ()) -EXTERN_CVAR (Float, Gamma) +EXTERN_CVAR (Float, vid_gamma) // Allocates buffer screens, call before R_Init. diff --git a/src/rendering/vulkan/renderer/vk_postprocess.cpp b/src/rendering/vulkan/renderer/vk_postprocess.cpp index 51105c811f..403a9dfcd1 100644 --- a/src/rendering/vulkan/renderer/vk_postprocess.cpp +++ b/src/rendering/vulkan/renderer/vk_postprocess.cpp @@ -32,7 +32,7 @@ #include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h" -#include "hwrenderer/utility/hw_vrmodes.h" +#include "hw_vrmodes.h" #include "hwrenderer/data/flatvertices.h" #include "r_videoscale.h" #include "filesystem.h" @@ -201,7 +201,7 @@ void VkPostprocess::DrawPresentTexture(const IntRect &box, bool applyGamma, bool } else { - uniforms.InvGamma = 1.0f / clamp(Gamma, 0.1f, 4.f); + uniforms.InvGamma = 1.0f / clamp(vid_gamma, 0.1f, 4.f); uniforms.Contrast = clamp(vid_contrast, 0.1f, 3.f); uniforms.Brightness = clamp(vid_brightness, -0.8f, 0.8f); uniforms.Saturation = clamp(vid_saturation, -15.0f, 15.f); diff --git a/src/rendering/vulkan/system/vk_framebuffer.cpp b/src/rendering/vulkan/system/vk_framebuffer.cpp index 7cf64196b4..a783f8c10f 100644 --- a/src/rendering/vulkan/system/vk_framebuffer.cpp +++ b/src/rendering/vulkan/system/vk_framebuffer.cpp @@ -32,7 +32,7 @@ #include "v_text.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/models/hw_models.h" #include "hwrenderer/scene/hw_skydome.h" diff --git a/src/version.h b/src/version.h index 92b4e70518..1be840a5f5 100644 --- a/src/version.h +++ b/src/version.h @@ -65,7 +65,7 @@ const char *GetVersionString(); // Version stored in the ini's [LastRun] section. // Bump it if you made some configuration change that you want to // be able to migrate in FGameConfigFile::DoGlobalSetup(). -#define LASTRUNVERSION "219" +#define LASTRUNVERSION "220" // Protocol version used in demos. // Bump it if you change existing DEM_ commands or add new ones. @@ -95,6 +95,7 @@ const char *GetVersionString(); #define BASEWAD "gzdoom.pk3" #define OPTIONALWAD "game_support.pk3" #define GZDOOM 1 +#define VR3D_ENABLED // More stuff that needs to be different for derivatives. #define GAMENAME "GZDoom" diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b59af595f4..1b390c469e 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -926,7 +926,7 @@ OptionMenu "VideoOptions" protected StaticText " " 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_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25, 2