From 93a6e4bc9499975063eacb0cd7c4bc571982361b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 17 Feb 2017 08:08:22 +0100 Subject: [PATCH 01/82] Add an aggressive blur pass for the scene --- src/gl/renderer/gl_postprocess.cpp | 71 ++++++++++++++++++++++++++++++ src/gl/renderer/gl_renderbuffers.h | 2 + src/gl/renderer/gl_renderer.h | 1 + 3 files changed, 74 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 2f9b31bbb..92ef89362 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -166,6 +166,7 @@ void FGLRenderer::PostProcessScene(int fixedcm) ColormapScene(fixedcm); LensDistortScene(); ApplyFXAA(); + BlurScene(); } //----------------------------------------------------------------------------- @@ -467,6 +468,76 @@ void FGLRenderer::BloomScene(int fixedcm) FGLDebug::PopGroup(); } +//----------------------------------------------------------------------------- +// +// Blur the scene +// +//----------------------------------------------------------------------------- + +void FGLRenderer::BlurScene() +{ + FGLDebug::PushGroup("BlurScene"); + + FGLPostProcessState savedState; + savedState.SaveTextureBindings(2); + + const float blurAmount = 5.0f; + int sampleCount = 9; + int numLevels = 3; // Must be 4 or less (since FGLRenderBuffers::NumBloomLevels is 4 and we are using its buffers). + assert(numLevels <= FGLRenderBuffers::NumBloomLevels); + + const auto &viewport = mScreenViewport; // The area we want to blur. Could also be mSceneViewport if only the scene area is to be blured + + const auto &level0 = mBuffers->BloomLevels[0]; + + // Grab the area we want to bloom: + glBindFramebuffer(GL_READ_FRAMEBUFFER, mBuffers->GetCurrentFB()); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, level0.VFramebuffer); + glBlitFramebuffer(viewport.left, viewport.top, viewport.width, viewport.height, 0, 0, level0.Width, level0.Height, GL_COLOR_BUFFER_BIT, GL_LINEAR); + + // Blur and downscale: + for (int i = 0; i < numLevels - 1; i++) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i + 1]; + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); + } + + // Blur and upscale: + for (int i = numLevels - 1; i > 0; i--) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i - 1]; + + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); + + // Linear upscale: + glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); + glViewport(0, 0, next.Width, next.Height); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, level.VTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + RenderScreenQuad(); + } + + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); + + // Copy blur back to scene texture: + glBindFramebuffer(GL_READ_FRAMEBUFFER, level0.VFramebuffer); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mBuffers->GetCurrentFB()); + glBlitFramebuffer(0, 0, level0.Width, level0.Height, viewport.left, viewport.top, viewport.width, viewport.height, GL_COLOR_BUFFER_BIT, GL_LINEAR); + + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + FGLDebug::PopGroup(); +} + //----------------------------------------------------------------------------- // // Tonemap scene texture and place the result in the HUD/2D texture diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 5df3bcca0..41202b499 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -43,6 +43,8 @@ public: void BindNextFB(); void NextTexture(); + int GetCurrentFB() const { return mPipelineFB[mCurrentPipelineTexture]; } + void BindOutputFB(); void BlitToEyeTexture(int eye); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 63168ff24..1bfad8841 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -180,6 +180,7 @@ public: void ClearTonemapPalette(); void LensDistortScene(); void ApplyFXAA(); + void BlurScene(); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void DrawPresentTexture(const GL_IRECT &box, bool applyGamma); void Flush(); From 786c4f01c8e4debcd5779c0da27849b10a774f1d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 10 Mar 2017 12:47:52 -0500 Subject: [PATCH 02/82] - Monsters no longer search for players who are unfriendly. --- src/p_enemy.cpp | 8 +++++++- src/p_mobj.cpp | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 8aed0370e..cd986b5f2 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -250,6 +250,9 @@ void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist) if (emitter == NULL) return; + /*if (target != NULL && target->player && !(target->flags & MF_FRIENDLY)) + return;*/ + if (target != NULL && target->player && (target->player->cheats & CF_NOTARGET)) return; @@ -1883,6 +1886,9 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) if (!(player->mo->flags & MF_SHOOTABLE)) continue; // not shootable (observer or dead) + if (!((actor->flags ^ player->mo->flags) & MF_FRIENDLY)) + continue; // same +MF_FRIENDLY, ignore + if (player->cheats & CF_NOTARGET) continue; // no target @@ -1982,7 +1988,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) targ = NULL; } - if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) + if (targ && targ->player && ((targ->player->cheats & CF_NOTARGET) || !(targ->flags & MF_FRIENDLY))) { return 0; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c175858de..5c7b0ce7b 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -7354,6 +7354,9 @@ bool AActor::IsFriend (AActor *other) other->FriendPlayer == 0 || players[FriendPlayer-1].mo->IsTeammate(players[other->FriendPlayer-1].mo); } + // [SP] If friendly flags match, then they are on the same team. + /*if (!((flags ^ other->flags) & MF_FRIENDLY)) + return true;*/ return false; } From ff3d3f13c8ada898d5dd344474c9006c47dfa157 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 10 Mar 2017 14:00:58 -0500 Subject: [PATCH 03/82] - Implement hostile coop for -FRIENDLY players. --- src/p_enemy.cpp | 3 --- src/p_mobj.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index cd986b5f2..aca2d8bb0 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -250,9 +250,6 @@ void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist) if (emitter == NULL) return; - /*if (target != NULL && target->player && !(target->flags & MF_FRIENDLY)) - return;*/ - if (target != NULL && target->player && (target->player->cheats & CF_NOTARGET)) return; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 5c7b0ce7b..870b0a8df 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -7273,7 +7273,7 @@ bool AActor::IsTeammate (AActor *other) } else if (!deathmatch && player && other->player) { - return true; + return (!((flags ^ other->flags) & MF_FRIENDLY)); } else if (teamplay) { From 23141dc38a1dfad1fb2455c283a5659ffe8bcab4 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 01:19:37 -0400 Subject: [PATCH 04/82] - QZDoom-ify --- CMakeLists.txt | 4 ++-- src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- src/version.h | 20 ++++++++++---------- src/win32/hardware.cpp | 2 +- src/win32/zdoom.rc | 20 ++++++++++---------- wadsrc/CMakeLists.txt | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e96249ff3..1a10e9997 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8.7 ) -project(GZDoom) +project(QZDoom) if( COMMAND cmake_policy ) if( POLICY CMP0011 ) @@ -122,7 +122,7 @@ IF( NOT CMAKE_BUILD_TYPE ) ENDIF() set( ZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where zdoom.pk3 and the executable will be created." ) -set( ZDOOM_EXE_NAME "gzdoom" CACHE FILEPATH "Name of the executable to create" ) +set( ZDOOM_EXE_NAME "qzdoom" CACHE FILEPATH "Name of the executable to create" ) if( MSVC ) # Allow the user to use ZDOOM_OUTPUT_DIR as a single release point. # Use zdoom, zdoomd, zdoom64, and zdoomd64 for the binary names diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 906fc413d..b0c6ed5b8 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -148,7 +148,7 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ static int s_currentRenderer; -CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index e512adb73..88870cb52 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -65,7 +65,7 @@ void I_RestartRenderer(); int currentrenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/version.h b/src/version.h index 0bcbbb83e..b3382b474 100644 --- a/src/version.h +++ b/src/version.h @@ -46,16 +46,16 @@ const char *GetVersionString(); #ifdef GIT_DESCRIPTION #define VERSIONSTR GIT_DESCRIPTION #else -#define VERSIONSTR "2.5pre" +#define VERSIONSTR "1.4pre" #endif // The version as seen in the Windows resource -#define RC_FILEVERSION 2,4,9999,0 -#define RC_PRODUCTVERSION 2,4,9999,0 +#define RC_FILEVERSION 1,3,9999,0 +#define RC_PRODUCTVERSION 1,3,9999,0 #define RC_PRODUCTVERSION2 VERSIONSTR // These are for content versioning. The current state is '2.4'. #define VER_MAJOR 2 -#define VER_MINOR 5 +#define VER_MINOR 4 #define VER_REVISION 0 // Version identifier for network games. @@ -92,14 +92,14 @@ const char *GetVersionString(); #define SAVEVER 4551 // This is so that derivates can use the same savegame versions without worrying about engine compatibility -#define GAMESIG "GZDOOM" -#define BASEWAD "gzdoom.pk3" +#define GAMESIG "QZDOOM" +#define BASEWAD "qzdoom.pk3" // More stuff that needs to be different for derivatives. -#define GAMENAME "GZDoom" -#define GAMENAMELOWERCASE "gzdoom" -#define FORUM_URL "http://forum.drdteam.org" -#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24" +#define GAMENAME "QZDoom" +#define GAMENAMELOWERCASE "qzdoom" +#define FORUM_URL "http://forum.drdteam.org/viewforum.php?f=196" +#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=197" #if defined(__APPLE__) || defined(_WIN32) #define GAME_DIR GAMENAME diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index b083f4fe9..70e622b39 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -106,7 +106,7 @@ CUSTOM_CVAR(Bool, vid_used3d, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN } // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 0d21faae5..cede1e894 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -72,13 +72,13 @@ BEGIN " BEGIN\r\n" " VALUE ""Comments"", ""Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg.""\r\n" " VALUE ""CompanyName"", "" ""\r\n" - " VALUE ""FileDescription"", ""GZDoom""\r\n" + " VALUE ""FileDescription"", ""QZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" - " VALUE ""InternalName"", ""GZDoom""\r\n" + " VALUE ""InternalName"", ""QZDoom""\r\n" " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" - " VALUE ""OriginalFilename"", ""gzdoom.exe""\r\n" - " VALUE ""ProductName"", ""GZDoom""\r\n" + " VALUE ""OriginalFilename"", ""qzdoom.exe""\r\n" + " VALUE ""ProductName"", ""QZDoom""\r\n" " VALUE ""ProductVersion"", RC_PRODUCTVERSION2\r\n" " END\r\n" " END\r\n" @@ -228,7 +228,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US FONT 8, "MS Shell Dlg" { CONTROL 101, IDC_STATIC, STATIC, SS_ICON | WS_CHILD | WS_VISIBLE, 7, 7, 21, 20 - CONTROL "Welcome to GZDoom!", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 8, 180, 8 + CONTROL "Welcome to QZDoom!", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 8, 180, 8 CONTROL "", IDC_WELCOME_VERSION, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 18, 180, 8 CONTROL "IWAD selection", IDC_STATIC, BUTTON, BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 8, 32, 208, 117 CONTROL "Select which game file (IWAD) to run.", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 12, 44, 190, 8 @@ -242,7 +242,7 @@ FONT 8, "MS Shell Dlg" CONTROL "Load lights", IDC_WELCOME_LIGHTS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 180, 51, 10 CONTROL "Load brightmaps", IDC_WELCOME_BRIGHTMAPS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 190, 65, 10 CONTROL "Don't ask me this again", IDC_DONTASKIWAD, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 73, 211, 87, 10 - CONTROL "Play GZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 + CONTROL "Play QZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 CONTROL "Exit", IDCANCEL, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 228, 50, 14 } @@ -504,13 +504,13 @@ BEGIN BEGIN VALUE "Comments", "Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg." VALUE "CompanyName", " " - VALUE "FileDescription", "GZDoom" + VALUE "FileDescription", "QZDoom" VALUE "FileVersion", RC_FILEVERSION2 - VALUE "InternalName", "GZDoom" + VALUE "InternalName", "QZDoom" VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc." - VALUE "OriginalFilename", "gzdoom.exe" - VALUE "ProductName", "GZDoom" + VALUE "OriginalFilename", "qzdoom.exe" + VALUE "ProductName", "QZDoom" VALUE "ProductVersion", RC_PRODUCTVERSION2 END END diff --git a/wadsrc/CMakeLists.txt b/wadsrc/CMakeLists.txt index 80189a328..5a85840e0 100644 --- a/wadsrc/CMakeLists.txt +++ b/wadsrc/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required( VERSION 2.8.7 ) -add_pk3(gzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) +add_pk3(qzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) From 48e98c66de08f7de61910ca7fb5eb3029d1cf7c0 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 01:23:10 -0400 Subject: [PATCH 05/82] - fixed: this should probably be bumped to match GZDoom --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index b3382b474..8b081c14a 100644 --- a/src/version.h +++ b/src/version.h @@ -55,7 +55,7 @@ const char *GetVersionString(); #define RC_PRODUCTVERSION2 VERSIONSTR // These are for content versioning. The current state is '2.4'. #define VER_MAJOR 2 -#define VER_MINOR 4 +#define VER_MINOR 5 #define VER_REVISION 0 // Version identifier for network games. From 959fb2577bdd8187c26bae8213ccf4d80f5f07e1 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 04:02:40 -0400 Subject: [PATCH 06/82] - Unfriendly players now spawn at deathmatch starts. --- src/g_game.cpp | 4 +++- src/p_setup.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 92ccc6555..447fb82db 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1766,6 +1766,8 @@ void G_DoReborn (int playernum, bool freshbot) } else { + bool isUnfriendly = players[playernum].mo && !(players[playernum].mo->flags & MF_FRIENDLY); + // respawn at the start // first disassociate the corpse if (players[playernum].mo) @@ -1775,7 +1777,7 @@ void G_DoReborn (int playernum, bool freshbot) } // spawn at random spot if in deathmatch - if (deathmatch) + if (deathmatch || isUnfriendly) { G_DeathMatchSpawnPlayer (playernum); return; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index eccad199e..064a92a1f 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -4080,6 +4080,22 @@ void P_SetupLevel (const char *lumpname, int position) } } + // [SP] move unfriendly players around + // horribly hacky - yes, this needs rewritten. + for (i = 0; i < MAXPLAYERS; ++i) + { + if (playeringame[i] && players[i].mo != NULL) + { + if (!(players[i].mo->flags & MF_FRIENDLY)) + { + AActor * oldSpawn = players[i].mo; + G_DeathMatchSpawnPlayer (i); + oldSpawn->Destroy(); + } + } + } + + // Don't count monsters in end-of-level sectors if option is on if (dmflags2 & DF2_NOCOUNTENDMONST) { From e49b5493642886764acfc5e2134c3599a3a6453d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 17:50:47 -0400 Subject: [PATCH 07/82] - added CVARs to control menu blur - made blur effect menu only --- src/gl/renderer/gl_postprocess.cpp | 9 +++++++-- src/menu/menu.cpp | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 92ef89362..77edfe0c9 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -166,7 +166,7 @@ void FGLRenderer::PostProcessScene(int fixedcm) ColormapScene(fixedcm); LensDistortScene(); ApplyFXAA(); - BlurScene(); + //BlurScene(); } //----------------------------------------------------------------------------- @@ -474,14 +474,19 @@ void FGLRenderer::BloomScene(int fixedcm) // //----------------------------------------------------------------------------- +CVAR(Float, gl_menu_blur, 5.0f, CVAR_ARCHIVE) +CVAR(Bool, gl_menu_blur_enabled, false, CVAR_ARCHIVE) + void FGLRenderer::BlurScene() { + if ((!gl_menu_blur_enabled) || (gl_menu_blur <= 0.0)) + return; FGLDebug::PushGroup("BlurScene"); FGLPostProcessState savedState; savedState.SaveTextureBindings(2); - const float blurAmount = 5.0f; + const float blurAmount = gl_menu_blur; int sampleCount = 9; int numLevels = 3; // Must be 4 or less (since FGLRenderBuffers::NumBloomLevels is 4 and we are using its buffers). assert(numLevels <= FGLRenderBuffers::NumBloomLevels); diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 2050c4834..5f0910759 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -57,6 +57,7 @@ #include "textures/textures.h" #include "virtual.h" #include "events.h" +#include "gl/renderer/gl_renderer.h" // for menu blur // // Todo: Move these elsewhere @@ -780,6 +781,8 @@ void M_Drawer (void) if (!CurrentMenu->DontDim) { screen->Dim(fade); + if (GLRenderer) + GLRenderer->BlurScene(); V_SetBorderNeedRefresh(); } CurrentMenu->CallDrawer(); From 954f21f71d4426c6680dfb82b9b1ba7512b025c4 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 18:46:51 -0400 Subject: [PATCH 08/82] - changed defaults - moved CVARs to head of file as forward declaration - FGLRenderer::BlurScene now checks if postprocessing is enabled before executing --- src/gl/renderer/gl_postprocess.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 77edfe0c9..cc1092ccc 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -145,6 +145,8 @@ CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITC GLRenderer->ClearTonemapPalette(); } +CVAR(Float, gl_menu_blur, 1.0f, CVAR_ARCHIVE) +CVAR(Bool, gl_menu_blur_enabled, true, CVAR_ARCHIVE) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -166,7 +168,6 @@ void FGLRenderer::PostProcessScene(int fixedcm) ColormapScene(fixedcm); LensDistortScene(); ApplyFXAA(); - //BlurScene(); } //----------------------------------------------------------------------------- @@ -474,19 +475,17 @@ void FGLRenderer::BloomScene(int fixedcm) // //----------------------------------------------------------------------------- -CVAR(Float, gl_menu_blur, 5.0f, CVAR_ARCHIVE) -CVAR(Bool, gl_menu_blur_enabled, false, CVAR_ARCHIVE) - void FGLRenderer::BlurScene() { - if ((!gl_menu_blur_enabled) || (gl_menu_blur <= 0.0)) + float blurAmount = gl_menu_blur; + if ((!gl_menu_blur_enabled) || (gl_menu_blur <= 0.0) || !FGLRenderBuffers::IsEnabled()) return; + FGLDebug::PushGroup("BlurScene"); FGLPostProcessState savedState; savedState.SaveTextureBindings(2); - const float blurAmount = gl_menu_blur; int sampleCount = 9; int numLevels = 3; // Must be 4 or less (since FGLRenderBuffers::NumBloomLevels is 4 and we are using its buffers). assert(numLevels <= FGLRenderBuffers::NumBloomLevels); From b747b0c3c6e1840c99954b00749c73a83300c68a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 19:11:13 -0400 Subject: [PATCH 09/82] - made gl_menu_blur into a menu option - made bluramount also into a gameinfo option - negative gl_menu_blur cvar now uses gameinfo option, 0 disables it - removed gl_menu_blur_enabled since gl_menu_blur==0 does that anyway - made gl_menu_blur default to -1 to use gameinfo option - add default gameinfo bluramount options --- src/gi.cpp | 1 + src/gi.h | 1 + src/gl/renderer/gl_postprocess.cpp | 14 ++++++++++---- src/gl/renderer/gl_renderer.h | 2 +- src/menu/menu.cpp | 2 +- wadsrc/static/language.enu | 1 + wadsrc/static/mapinfo/chex.txt | 1 + wadsrc/static/mapinfo/doomcommon.txt | 1 + wadsrc/static/mapinfo/heretic.txt | 1 + wadsrc/static/mapinfo/hexen.txt | 1 + wadsrc/static/mapinfo/mindefaults.txt | 1 + wadsrc/static/mapinfo/strife.txt | 1 + wadsrc/static/menudef.txt | 2 ++ 13 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/gi.cpp b/src/gi.cpp index 3c53b5b5c..0ac9c82b6 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -369,6 +369,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_BOOL(nightmarefast, "nightmarefast") GAMEINFOKEY_COLOR(dimcolor, "dimcolor") GAMEINFOKEY_FLOAT(dimamount, "dimamount") + GAMEINFOKEY_FLOAT(bluramount, "bluramount") GAMEINFOKEY_INT(definventorymaxamount, "definventorymaxamount") GAMEINFOKEY_INT(defaultrespawntime, "defaultrespawntime") GAMEINFOKEY_INT(defaultrespawntime, "defaultrespawntime") diff --git a/src/gi.h b/src/gi.h index bf9ccd450..3f51055fe 100644 --- a/src/gi.h +++ b/src/gi.h @@ -155,6 +155,7 @@ struct gameinfo_t FString CursorPic; uint32_t dimcolor; float dimamount; + float bluramount; int definventorymaxamount; int defaultrespawntime; int defaultdropstyle; diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index cc1092ccc..827dd7da2 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -145,8 +145,7 @@ CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITC GLRenderer->ClearTonemapPalette(); } -CVAR(Float, gl_menu_blur, 1.0f, CVAR_ARCHIVE) -CVAR(Bool, gl_menu_blur_enabled, true, CVAR_ARCHIVE) +CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -475,10 +474,17 @@ void FGLRenderer::BloomScene(int fixedcm) // //----------------------------------------------------------------------------- -void FGLRenderer::BlurScene() +void FGLRenderer::BlurScene(float gameinfobluramount) { + // first, respect the CVar float blurAmount = gl_menu_blur; - if ((!gl_menu_blur_enabled) || (gl_menu_blur <= 0.0) || !FGLRenderBuffers::IsEnabled()) + + // if CVar is negative, use the gameinfo entry + if (gl_menu_blur < 0) + blurAmount = gameinfobluramount; + + // if blurAmount == 0 or somehow still returns negative, exit to prevent a crash, clearly we don't want this + if ((blurAmount <= 0.0) || !FGLRenderBuffers::IsEnabled()) return; FGLDebug::PushGroup("BlurScene"); diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 1bfad8841..ce59a032c 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -180,7 +180,7 @@ public: void ClearTonemapPalette(); void LensDistortScene(); void ApplyFXAA(); - void BlurScene(); + void BlurScene(float gameinfobluramount); void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); void DrawPresentTexture(const GL_IRECT &box, bool applyGamma); void Flush(); diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 5f0910759..795ee99e5 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -782,7 +782,7 @@ void M_Drawer (void) { screen->Dim(fade); if (GLRenderer) - GLRenderer->BlurScene(); + GLRenderer->BlurScene(gameinfo.bluramount); V_SetBorderNeedRefresh(); } CurrentMenu->CallDrawer(); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 1a4a97148..ecf47f78a 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2696,6 +2696,7 @@ GLPREFMNU_SPRBILLFACECAMERA = "Sprites face camera"; GLPREFMNU_PARTICLESTYLE = "Particle style"; GLPREFMNU_AMBLIGHT = "Ambient light level"; GLPREFMNU_RENDERQUALITY = "Rendering quality"; +GLPREFMNU_MENUBLUR = "Menu Blur"; GLPREFMNU_VRMODE = "Stereo 3D VR"; GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; GLPREFMNU_MULTISAMPLE = "Multisample"; diff --git a/wadsrc/static/mapinfo/chex.txt b/wadsrc/static/mapinfo/chex.txt index 4bff1283e..f35a5f2cd 100644 --- a/wadsrc/static/mapinfo/chex.txt +++ b/wadsrc/static/mapinfo/chex.txt @@ -38,6 +38,7 @@ gameinfo weaponslot = 7, "LAZDevice" dimcolor = "ff d7 00" dimamount = 0.2 + bluramount = 0.5 definventorymaxamount = 25 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/doomcommon.txt b/wadsrc/static/mapinfo/doomcommon.txt index f24095941..b96164a20 100644 --- a/wadsrc/static/mapinfo/doomcommon.txt +++ b/wadsrc/static/mapinfo/doomcommon.txt @@ -38,6 +38,7 @@ gameinfo weaponslot = 7, "BFG9000" dimcolor = "ff d7 00" dimamount = 0.2 + bluramount = 0.5 definventorymaxamount = 25 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/heretic.txt b/wadsrc/static/mapinfo/heretic.txt index 361bf5cde..f87bd0f02 100644 --- a/wadsrc/static/mapinfo/heretic.txt +++ b/wadsrc/static/mapinfo/heretic.txt @@ -37,6 +37,7 @@ gameinfo weaponslot = 7, "Mace" dimcolor = "00 00 ff" dimamount = 0.2 + bluramount = 0.5 definventorymaxamount = 16 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/hexen.txt b/wadsrc/static/mapinfo/hexen.txt index 6b17df101..a52105a07 100644 --- a/wadsrc/static/mapinfo/hexen.txt +++ b/wadsrc/static/mapinfo/hexen.txt @@ -36,6 +36,7 @@ gameinfo weaponslot = 4, "FWeapQuietus", "CWeapWraithverge", "MWeapBloodscourge" dimcolor = "00 00 ff" dimamount = 0.2 + bluramount = 0.5 definventorymaxamount = 25 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/mindefaults.txt b/wadsrc/static/mapinfo/mindefaults.txt index 885587281..f02ff78d0 100644 --- a/wadsrc/static/mapinfo/mindefaults.txt +++ b/wadsrc/static/mapinfo/mindefaults.txt @@ -27,6 +27,7 @@ gameinfo intermissioncounter = true dimcolor = "6f 00 6b" dimamount = 0.8 + bluramount = 0.0 definventorymaxamount = 25 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index 17b8a1924..fbdf3d9e3 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -38,6 +38,7 @@ gameinfo weaponslot = 8, "Sigil" dimcolor = "ff d7 00" dimamount = 0.2 + bluramount = 0.5 definventorymaxamount = 25 defaultrespawntime = 16 defaultdropstyle = 2 diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index f6f699088..143057396 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2169,6 +2169,8 @@ OptionMenu "OpenGLOptions" Option "$GLPREFMNU_PARTICLESTYLE", gl_particles_style, "Particles" Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" StaticText " " + Slider "$GLPREFMNU_MENUBLUR", gl_menu_blur, 0, 5.0, 0.5, 2 + StaticText " " Option "$GLPREFMNU_VRMODE", vr_mode, "VRMode" Option "$GLPREFMNU_VRQUADSTEREO", vr_enable_quadbuffered, "OnOff" StaticText " " From f6d9d153b12573efb06cdd9c09a2885abc63d711 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 21 Mar 2017 08:46:42 -0400 Subject: [PATCH 10/82] - fixed: moved blur before and outside of menu dimming code. --- src/menu/menu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 795ee99e5..cf82b27f5 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -778,11 +778,11 @@ void M_Drawer (void) if (CurrentMenu != nullptr && menuactive != MENU_Off) { + if (GLRenderer) + GLRenderer->BlurScene(gameinfo.bluramount); if (!CurrentMenu->DontDim) { screen->Dim(fade); - if (GLRenderer) - GLRenderer->BlurScene(gameinfo.bluramount); V_SetBorderNeedRefresh(); } CurrentMenu->CallDrawer(); From 0376d4e8fc4bb30b4897136abfc5a16bf9b09163 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Apr 2017 02:17:34 +0200 Subject: [PATCH 11/82] - Use SDL_GL_GetProcAddress on platforms where the SDL is being used. Since SDL initialized OpenGL for us, it is the only reliable way of retrieving proc addresses. - Check if ogl_LoadFunctions failed and make OpenGLSWFrameBuffer gracefully recover from that --- src/gl/system/gl_load.c | 4 +++- src/gl/system/gl_swframebuffer.cpp | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c index 7075d6969..b0608ecb5 100644 --- a/src/gl/system/gl_load.c +++ b/src/gl/system/gl_load.c @@ -85,7 +85,9 @@ static PROC WinGetProcAddress(const char *name) #define IntGetProcAddress(name) AppleGLGetProcAddress(name) #else #if defined(__sgi) || defined(__sun) || defined(__unix__) - #define IntGetProcAddress(name) PosixGetProcAddress((const GLubyte*)name) + void* SDL_GL_GetProcAddress(const char* proc); + #define IntGetProcAddress(name) SDL_GL_GetProcAddress((const char*)name) + //#define IntGetProcAddress(name) PosixGetProcAddress((const GLubyte*)name) /* END OF MANUAL CHANGES, DO NOT REMOVE! */ #else /* GLX */ #include diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index ee5c0d58d..16138585d 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -194,7 +194,11 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, static bool first = true; if (first) { - ogl_LoadFunctions(); + if (ogl_LoadFunctions() == ogl_LOAD_FAILED) + { + Printf("OpenGL load failed. No OpenGL acceleration will be used.\n"); + return; + } } gl_LoadExtensions(); InitializeState(); From a9591f57a64f45bad73d514018e373812631118d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Apr 2017 03:03:21 +0200 Subject: [PATCH 12/82] - Detect dinosaur OpenGL and refuse to use it --- src/gl/system/gl_swframebuffer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 16138585d..b3de63eee 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -200,6 +200,19 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, return; } } + + const char *glversion = (const char*)glGetString(GL_VERSION); + bool isGLES = (glversion && strlen(glversion) > 10 && memcmp(glversion, "OpenGL ES ", 10) == 0); + if (isGLES && ogl_IsVersionGEQ(2, 0) == 0) + { + Printf("OpenGL acceleration requires at least OpenGL ES 2.0. No Acceleration will be used.\n"); + return; + } + else if (!isGLES && ogl_IsVersionGEQ(3, 0) == 0) + { + Printf("OpenGL acceleration requires at least OpenGL 3.0. No Acceleration will be used.\n"); + return; + } gl_LoadExtensions(); InitializeState(); if (first) From 994740b3ae24309e2455c6f16b0a54123b9d1a7a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Apr 2017 04:09:04 +0200 Subject: [PATCH 13/82] - Add OpenGL ES 3 support to GL renderer --- src/gl/shaders/gl_shader.cpp | 18 ++++++++++++++---- src/gl/system/gl_interface.cpp | 1 + wadsrc/static/shaders/glsl/fuzz_noise.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_standard.fp | 2 +- wadsrc/static/shaders/glsl/main.fp | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 44be65ebe..2fdf9fbf3 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -85,8 +85,11 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); if (lightbuffertype == GL_UNIFORM_BUFFER) { - // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary - if (gl.glslversion < 1.4f) + if (gl.es) + { + vp_comb.Format("#version 300 es\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } + else if (gl.glslversion < 1.4f) // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary { vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); } @@ -411,8 +414,15 @@ FShaderManager::FShaderManager() { if (!gl.legacyMode) { - for (int passType = 0; passType < MAX_PASS_TYPES; passType++) - mPassShaders.Push(new FShaderCollection((EPassType)passType)); + if (gl.es) // OpenGL ES does not support multiple fragment shader outputs. As a result, no GBUFFER passes are possible. + { + mPassShaders.Push(new FShaderCollection(NORMAL_PASS)); + } + else + { + for (int passType = 0; passType < MAX_PASS_TYPES; passType++) + mPassShaders.Push(new FShaderCollection((EPassType)passType)); + } } } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index a0d16597f..1a3f4b1ae 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -176,6 +176,7 @@ void gl_LoadExtensions() gl.legacyMode = false; gl.lightmethod = LM_DEFERRED; gl.buffermethod = BM_DEFERRED; + gl.flags |= RFL_NO_CLIP_PLANES; } else { diff --git a/wadsrc/static/shaders/glsl/fuzz_noise.fp b/wadsrc/static/shaders/glsl/fuzz_noise.fp index 17f15d03b..75afc251f 100644 --- a/wadsrc/static/shaders/glsl/fuzz_noise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_noise.fp @@ -5,7 +5,7 @@ vec4 ProcessTexel() { vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); - ivec2 texSize = textureSize(tex, 0); + vec2 texSize = vec2(textureSize(tex, 0)); texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; diff --git a/wadsrc/static/shaders/glsl/fuzz_standard.fp b/wadsrc/static/shaders/glsl/fuzz_standard.fp index 95ba52431..b467f64b2 100644 --- a/wadsrc/static/shaders/glsl/fuzz_standard.fp +++ b/wadsrc/static/shaders/glsl/fuzz_standard.fp @@ -5,7 +5,7 @@ vec4 ProcessTexel() { vec2 texCoord = vTexCoord.st; vec4 basicColor = getTexel(texCoord); - ivec2 texSize = textureSize(tex, 0); + vec2 texSize = vec2(textureSize(tex, 0)); texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 9a682f386..5b4d1438f 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -90,7 +90,7 @@ vec4 getTexel(vec2 st) } break; } - if (uObjectColor2.a == 0) texel *= uObjectColor; + if (uObjectColor2.a == 0.0) texel *= uObjectColor; else texel *= mix(uObjectColor, uObjectColor2, glowdist.z); return desaturate(texel); From dc1695918eb4eff5eb7949e602b20d7b0779f2ea Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 6 Apr 2017 23:29:15 -0400 Subject: [PATCH 14/82] - detect gl es shaders and request them --- src/gl/shaders/gl_shaderprogram.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 5327eeac0..dfb46c544 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -216,7 +216,10 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const FString patchedCode; int shaderVersion = MIN((int)round(gl.glslversion * 10) * 10, maxGlslVersion); - patchedCode.AppendFormat("#version %d\n", shaderVersion); + if (gl.es) + patchedCode.AppendFormat("#version %d es\n", shaderVersion); + else + patchedCode.AppendFormat("#version %d\n", shaderVersion); // TODO: Find some way to add extension requirements to the patching // From 771b32120368f4e5c923ab5443cb68ba2517891e Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 01:19:37 -0400 Subject: [PATCH 15/82] - QZDoom-ify --- CMakeLists.txt | 4 ++-- src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- src/version.h | 20 ++++++++++---------- src/win32/hardware.cpp | 2 +- src/win32/zdoom.rc | 20 ++++++++++---------- wadsrc/CMakeLists.txt | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e96249ff3..1a10e9997 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8.7 ) -project(GZDoom) +project(QZDoom) if( COMMAND cmake_policy ) if( POLICY CMP0011 ) @@ -122,7 +122,7 @@ IF( NOT CMAKE_BUILD_TYPE ) ENDIF() set( ZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where zdoom.pk3 and the executable will be created." ) -set( ZDOOM_EXE_NAME "gzdoom" CACHE FILEPATH "Name of the executable to create" ) +set( ZDOOM_EXE_NAME "qzdoom" CACHE FILEPATH "Name of the executable to create" ) if( MSVC ) # Allow the user to use ZDOOM_OUTPUT_DIR as a single release point. # Use zdoom, zdoomd, zdoom64, and zdoomd64 for the binary names diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 00b39639f..fd09c88f8 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -148,7 +148,7 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ static int s_currentRenderer; -CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index e512adb73..88870cb52 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -65,7 +65,7 @@ void I_RestartRenderer(); int currentrenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/version.h b/src/version.h index b2e554633..a74b150b8 100644 --- a/src/version.h +++ b/src/version.h @@ -46,16 +46,16 @@ const char *GetVersionString(); #ifdef GIT_DESCRIPTION #define VERSIONSTR GIT_DESCRIPTION #else -#define VERSIONSTR "2.5pre" +#define VERSIONSTR "1.4pre" #endif // The version as seen in the Windows resource -#define RC_FILEVERSION 2,4,9999,0 -#define RC_PRODUCTVERSION 2,4,9999,0 +#define RC_FILEVERSION 1,3,9999,0 +#define RC_PRODUCTVERSION 1,3,9999,0 #define RC_PRODUCTVERSION2 VERSIONSTR // These are for content versioning. The current state is '2.4'. #define VER_MAJOR 2 -#define VER_MINOR 5 +#define VER_MINOR 4 #define VER_REVISION 0 // Version identifier for network games. @@ -92,14 +92,14 @@ const char *GetVersionString(); #define SAVEVER 4551 // This is so that derivates can use the same savegame versions without worrying about engine compatibility -#define GAMESIG "GZDOOM" -#define BASEWAD "gzdoom.pk3" +#define GAMESIG "QZDOOM" +#define BASEWAD "qzdoom.pk3" // More stuff that needs to be different for derivatives. -#define GAMENAME "GZDoom" -#define GAMENAMELOWERCASE "gzdoom" -#define FORUM_URL "http://forum.drdteam.org" -#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24" +#define GAMENAME "QZDoom" +#define GAMENAMELOWERCASE "qzdoom" +#define FORUM_URL "http://forum.drdteam.org/viewforum.php?f=196" +#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=197" #if defined(__APPLE__) || defined(_WIN32) #define GAME_DIR GAMENAME diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index b083f4fe9..70e622b39 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -106,7 +106,7 @@ CUSTOM_CVAR(Bool, vid_used3d, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN } // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 0d21faae5..cede1e894 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -72,13 +72,13 @@ BEGIN " BEGIN\r\n" " VALUE ""Comments"", ""Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg.""\r\n" " VALUE ""CompanyName"", "" ""\r\n" - " VALUE ""FileDescription"", ""GZDoom""\r\n" + " VALUE ""FileDescription"", ""QZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" - " VALUE ""InternalName"", ""GZDoom""\r\n" + " VALUE ""InternalName"", ""QZDoom""\r\n" " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" - " VALUE ""OriginalFilename"", ""gzdoom.exe""\r\n" - " VALUE ""ProductName"", ""GZDoom""\r\n" + " VALUE ""OriginalFilename"", ""qzdoom.exe""\r\n" + " VALUE ""ProductName"", ""QZDoom""\r\n" " VALUE ""ProductVersion"", RC_PRODUCTVERSION2\r\n" " END\r\n" " END\r\n" @@ -228,7 +228,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US FONT 8, "MS Shell Dlg" { CONTROL 101, IDC_STATIC, STATIC, SS_ICON | WS_CHILD | WS_VISIBLE, 7, 7, 21, 20 - CONTROL "Welcome to GZDoom!", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 8, 180, 8 + CONTROL "Welcome to QZDoom!", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 8, 180, 8 CONTROL "", IDC_WELCOME_VERSION, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 18, 180, 8 CONTROL "IWAD selection", IDC_STATIC, BUTTON, BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 8, 32, 208, 117 CONTROL "Select which game file (IWAD) to run.", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 12, 44, 190, 8 @@ -242,7 +242,7 @@ FONT 8, "MS Shell Dlg" CONTROL "Load lights", IDC_WELCOME_LIGHTS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 180, 51, 10 CONTROL "Load brightmaps", IDC_WELCOME_BRIGHTMAPS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 190, 65, 10 CONTROL "Don't ask me this again", IDC_DONTASKIWAD, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 73, 211, 87, 10 - CONTROL "Play GZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 + CONTROL "Play QZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 CONTROL "Exit", IDCANCEL, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 228, 50, 14 } @@ -504,13 +504,13 @@ BEGIN BEGIN VALUE "Comments", "Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg." VALUE "CompanyName", " " - VALUE "FileDescription", "GZDoom" + VALUE "FileDescription", "QZDoom" VALUE "FileVersion", RC_FILEVERSION2 - VALUE "InternalName", "GZDoom" + VALUE "InternalName", "QZDoom" VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc." - VALUE "OriginalFilename", "gzdoom.exe" - VALUE "ProductName", "GZDoom" + VALUE "OriginalFilename", "qzdoom.exe" + VALUE "ProductName", "QZDoom" VALUE "ProductVersion", RC_PRODUCTVERSION2 END END diff --git a/wadsrc/CMakeLists.txt b/wadsrc/CMakeLists.txt index 80189a328..5a85840e0 100644 --- a/wadsrc/CMakeLists.txt +++ b/wadsrc/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required( VERSION 2.8.7 ) -add_pk3(gzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) +add_pk3(qzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) From a4a6b098805f471009b542033b37cbb33ac3f3da Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 14 Mar 2017 01:23:10 -0400 Subject: [PATCH 16/82] - fixed: this should probably be bumped to match GZDoom --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index a74b150b8..ef25c91e6 100644 --- a/src/version.h +++ b/src/version.h @@ -55,7 +55,7 @@ const char *GetVersionString(); #define RC_PRODUCTVERSION2 VERSIONSTR // These are for content versioning. The current state is '2.4'. #define VER_MAJOR 2 -#define VER_MINOR 4 +#define VER_MINOR 5 #define VER_REVISION 0 // Version identifier for network games. From b2c2efbf5016fba62288cd827e0555fd1db82f05 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 12 Apr 2017 02:51:04 -0400 Subject: [PATCH 17/82] - use OpenGL defaults like GZDoom --- src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- src/win32/hardware.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index fd09c88f8..00b39639f 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -148,7 +148,7 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ static int s_currentRenderer; -CUSTOM_CVAR(Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 88870cb52..e512adb73 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -65,7 +65,7 @@ void I_RestartRenderer(); int currentrenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 70e622b39..b083f4fe9 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -106,7 +106,7 @@ CUSTOM_CVAR(Bool, vid_used3d, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN } // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer From a111c5928638a606c6f1776823194ebc6208dac1 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Thu, 25 May 2017 19:46:36 -0500 Subject: [PATCH 18/82] Added PSPF_MIRROR. - Flips the sprite's drawing and position over entirely. Automatically implies PSPF_FLIP. --- src/gl/scene/gl_weapon.cpp | 12 ++++++++++-- src/p_pspr.cpp | 1 + src/p_pspr.h | 1 + wadsrc/static/zscript/constants.txt | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 23610fb01..61c5c2a4e 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -98,7 +98,7 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa // calculate edges of the shape scalex = (320.0f / (240.0f * r_viewwindow.WidescreenRatio)) * vw / 320; - tx = sx - (160 - r.left); + tx = (psp->Flags & PSPF_MIRROR) ? ((160 - r.width) - (sx + r.left)) : (sx - (160 - r.left)); x1 = tx * scalex + vw/2; if (x1 > vw) return; // off the right side x1 += viewwindowx; @@ -107,6 +107,13 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa x2 = tx * scalex + vw / 2; if (x2 < 0) return; // off the left side x2 += viewwindowx; + /* + if (psp->Flags & PSPF_MIRROR) + { + float dist = 320.f - sx; + x1 += dist * scalex; + x2 += dist * scalex; + }*/ // killough 12/98: fix psprite positioning problem @@ -130,7 +137,8 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa y1 = viewwindowy + vh / 2 - (ftexturemid * scale); y2 = y1 + (r.height * scale) + 1; - if (!(mirror) != !(psp->Flags & PSPF_FLIP)) + + if (!(mirror) != !(psp->Flags & (PSPF_FLIP|PSPF_MIRROR))) { fU2 = tex->GetSpriteUL(); fV1 = tex->GetSpriteVT(); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 2404b8b9c..45e92a8d0 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -141,6 +141,7 @@ DEFINE_FIELD_BIT(DPSprite, Flags, bAddBob, PSPF_ADDBOB) DEFINE_FIELD_BIT(DPSprite, Flags, bPowDouble, PSPF_POWDOUBLE) DEFINE_FIELD_BIT(DPSprite, Flags, bCVarFast, PSPF_CVARFAST) DEFINE_FIELD_BIT(DPSprite, Flags, bFlip, PSPF_FLIP) +DEFINE_FIELD_BIT(DPSprite, Flags, bMirror, PSPF_MIRROR) //------------------------------------------------------------------------ // diff --git a/src/p_pspr.h b/src/p_pspr.h index 5964ace20..c98918ded 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -68,6 +68,7 @@ enum PSPFlags PSPF_FLIP = 1 << 6, PSPF_FORCEALPHA = 1 << 7, PSPF_FORCESTYLE = 1 << 8, + PSPF_MIRROR = 1 << 9, }; class DPSprite : public DObject diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index b698f966f..b0bf1b65d 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -726,6 +726,7 @@ enum EPSpriteFlags PSPF_FLIP = 1 << 6, PSPF_FORCEALPHA = 1 << 7, PSPF_FORCESTYLE = 1 << 8, + PSPF_MIRROR = 1 << 9, }; // Default psprite layers From a25a536c9f33447dbc095b368f4436f1d6d4c719 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Thu, 25 May 2017 20:40:54 -0500 Subject: [PATCH 19/82] Removed the auto PSPF_FLIP implimentation. --- src/gl/scene/gl_weapon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 61c5c2a4e..90d0ff31b 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -138,7 +138,7 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa y2 = y1 + (r.height * scale) + 1; - if (!(mirror) != !(psp->Flags & (PSPF_FLIP|PSPF_MIRROR))) + if (!(mirror) != !(psp->Flags & (PSPF_FLIP))) { fU2 = tex->GetSpriteUL(); fV1 = tex->GetSpriteVT(); From 636e36b90d9f2b9a5792d9bfdaec23ed53bc647b Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Fri, 26 May 2017 11:34:26 -0500 Subject: [PATCH 20/82] Clean-up. --- src/gl/scene/gl_weapon.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 90d0ff31b..8edc12474 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -107,14 +107,6 @@ void GLSceneDrawer::DrawPSprite (player_t * player,DPSprite *psp, float sx, floa x2 = tx * scalex + vw / 2; if (x2 < 0) return; // off the left side x2 += viewwindowx; - /* - if (psp->Flags & PSPF_MIRROR) - { - float dist = 320.f - sx; - x1 += dist * scalex; - x2 += dist * scalex; - }*/ - // killough 12/98: fix psprite positioning problem ftexturemid = 100.f - sy - r.top; From 35583621cf9573c9d79e4398f65f204f168ae31b Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Fri, 26 May 2017 18:28:09 -0500 Subject: [PATCH 21/82] PSPF_MIRROR now corrects the bobx direction. --- src/gl/scene/gl_weapon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 8edc12474..78c32cc07 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -437,7 +437,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) if (psp->Flags & PSPF_ADDBOB) { - sx += bobx; + sx += (psp->Flags & PSPF_MIRROR) ? -bobx : bobx; sy += boby; } From c1bacdbf92cbdc55c966aceed91cef767315631c Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 27 May 2017 19:42:49 -0400 Subject: [PATCH 22/82] Create initial rotation-tracking-only implementation of OpenVR mode for VR headsets. --- .gitignore | 1 + CMakeLists.txt | 2 + src/CMakeLists.txt | 25 ++ src/gl/data/gl_matrix.h | 2 +- src/gl/renderer/gl_renderbuffers.cpp | 8 +- src/gl/renderer/gl_renderbuffers.h | 1 + src/gl/stereo3d/LSMatrix.h | 162 ++++++++ src/gl/stereo3d/gl_openvr.cpp | 477 ++++++++++++++++++++++++ src/gl/stereo3d/gl_openvr.h | 111 ++++++ src/gl/stereo3d/gl_stereo_cvars.cpp | 18 +- src/gl/stereo3d/scoped_view_shifter.cpp | 2 +- src/gl/stereo3d/scoped_view_shifter.h | 2 +- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 14 files changed, 803 insertions(+), 10 deletions(-) create mode 100644 src/gl/stereo3d/LSMatrix.h create mode 100644 src/gl/stereo3d/gl_openvr.cpp create mode 100644 src/gl/stereo3d/gl_openvr.h diff --git a/.gitignore b/.gitignore index a001e38de..9f2fd2cb0 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ /llvm /src/r_drawersasm.obj /src/r_drawersasm.o +/build_cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d4b402326..da865aaac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,6 +300,8 @@ endif() set( LZMA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lzma/C" ) +option( GZDOOM_USE_OPENVR "Support OpenVR API for virtual reality head mounted displays" OFF ) + if( NOT CMAKE_CROSSCOMPILING ) if( NOT CROSS_EXPORTS ) set( CROSS_EXPORTS "" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 387d6855f..17cd911e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -473,6 +473,29 @@ if( NOT DYN_FLUIDSYNTH ) endif() endif() +if (GZDOOM_USE_OPENVR) + find_path(OPENVR_SDK_PATH + NAMES + headers/openvr.h + PATHS + C:/Users/cmbruns/git/openvr + ) + find_path(OPENVR_INCLUDE_DIRECTORY + NAMES + openvr.h + PATHS + ${OPENVR_SDK_PATH}/headers + ) + include_directories("${OPENVR_INCLUDE_DIRECTORY}") + find_library(OPENVR_LIBRARY + NAMES openvr_api + # TODO: Generalize for Mac and Linux and 64-bit Windows + PATHS "${OPENVR_SDK_PATH}/lib/win32/" + ) + list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) + add_definitions("-DUSE_OPENVR") +endif() + # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES sound/mididevices/music_win_mididevice.cpp @@ -805,6 +828,7 @@ set( FASTMATH_SOURCES gl/scene/gl_vertex.cpp gl/scene/gl_spritelight.cpp gl/dynlights/gl_dynlight1.cpp + gl/dynlights/gl_dynlight1.cpp gl/system/gl_load.c gl/models/gl_models.cpp ) @@ -1006,6 +1030,7 @@ set (PCH_SOURCES gl/stereo3d/gl_stereo_leftright.cpp gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp + gl/stereo3d/gl_openvr.cpp gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_sidebyside3d.cpp gl/stereo3d/gl_interleaved3d.cpp diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h index 3ec1f5ff4..12ef2f12b 100644 --- a/src/gl/data/gl_matrix.h +++ b/src/gl/data/gl_matrix.h @@ -62,7 +62,7 @@ class VSMatrix { void perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp); void ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp=-1.0f, FLOATTYPE farp=1.0f); void frustum(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp, FLOATTYPE farp); - void copy(FLOATTYPE * pDest) + void copy(FLOATTYPE * pDest) const { memcpy(pDest, mMatrix, 16 * sizeof(FLOATTYPE)); } diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 74dc36e72..e298b313b 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -458,7 +458,8 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye) while (mEyeFBs.Size() <= unsigned(eye)) { - GLuint texture = Create2DTexture("EyeTexture", GL_RGBA16F, mWidth, mHeight); + // GL_RGBA16F, GL_RGBA16, GL_RGBA32F all do not work with OpenVR and HTC Vive + GLuint texture = Create2DTexture("EyeTexture", GL_RGBA12, mWidth, mHeight); mEyeTextures.Push(texture); mEyeFBs.Push(CreateFrameBuffer("EyeFB", texture)); } @@ -485,6 +486,7 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int switch (format) { case GL_RGBA8: dataformat = GL_RGBA; datatype = GL_UNSIGNED_BYTE; break; + case GL_RGBA12: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; @@ -740,6 +742,10 @@ void FGLRenderBuffers::BindEyeFB(int eye, bool readBuffer) glBindFramebuffer(readBuffer ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER, mEyeFBs[eye]); } +GLuint FGLRenderBuffers::GetEyeTextureGLHandle(int eye) const { // Needed for OpenVR API + return mEyeTextures[eye]; +} + //========================================================================== // // Shadow map texture and frame buffers diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 5df3bcca0..870ac2218 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -48,6 +48,7 @@ public: void BlitToEyeTexture(int eye); void BindEyeTexture(int eye, int texunit); void BindEyeFB(int eye, bool readBuffer = false); + GLuint GetEyeTextureGLHandle(int eye) const; // Needed for OpenVR API void BindShadowMapFB(); void BindShadowMapTexture(int index); diff --git a/src/gl/stereo3d/LSMatrix.h b/src/gl/stereo3d/LSMatrix.h new file mode 100644 index 000000000..a0e401838 --- /dev/null +++ b/src/gl/stereo3d/LSMatrix.h @@ -0,0 +1,162 @@ +/* +** LSMatrix.h +** less-simple matrix class +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + + +#ifndef VR_LS_MATRIX_H_ +#define VR_LS_MATRIX_H_ + +#include "gl/data/gl_matrix.h" +#include "openvr.h" + +namespace vr { + HmdMatrix34_t; +} + +class LSVec3 +{ +public: + LSVec3(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w=1.0f) + : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) + { + mVec[0] = x; + mVec[1] = y; + mVec[2] = z; + mVec[3] = w; + } + + LSVec3(const LSVec3& rhs) + : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) + { + *this = rhs; + } + + LSVec3& operator=(const LSVec3& rhs) { + LSVec3& lhs = *this; + for (int i = 0; i < 4; ++i) + lhs[i] = rhs[i]; + return *this; + } + + const FLOATTYPE& operator[](int i) const {return mVec[i];} + FLOATTYPE& operator[](int i) { return mVec[i]; } + + LSVec3 operator-(const LSVec3& rhs) const { + const LSVec3& lhs = *this; + LSVec3 result = *this; + for (int i = 0; i < 4; ++i) + result[i] -= rhs[i]; + return result; + } + + FLOATTYPE mVec[4]; + FLOATTYPE& x; + FLOATTYPE& y; + FLOATTYPE& z; + FLOATTYPE& w; +}; + +LSVec3 operator*(FLOATTYPE s, const LSVec3& rhs) { + LSVec3 result = rhs; + for (int i = 0; i < 4; ++i) + result[i] *= s; + return result; +} + +class LSMatrix44 : public VSMatrix +{ +public: + LSMatrix44() + { + loadIdentity(); + } + + LSMatrix44(const vr::HmdMatrix34_t& m) { + loadIdentity(); + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + (*this)[i][j] = m.m[i][j]; + } + } + } + + LSMatrix44(const VSMatrix& m) { + m.copy(mMatrix); + } + + // overload bracket operator to return one row of the matrix, so you can invoke, say, m[2][3] + FLOATTYPE* operator[](int i) {return &mMatrix[i*4];} + const FLOATTYPE* operator[](int i) const { return &mMatrix[i * 4]; } + + LSMatrix44 operator*(const VSMatrix& rhs) const { + LSMatrix44 result(*this); + result.multMatrix(rhs); + return result; + } + + LSVec3 operator*(const LSVec3& rhs) const { + const LSMatrix44& lhs = *this; + LSVec3 result(0, 0, 0, 0); + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + result[i] += lhs[i][j] * rhs[j]; + } + } + return result; + } + + LSMatrix44 getWithoutTranslation() const { + LSMatrix44 m = *this; + // Remove translation component + m[3][3] = 1.0f; + m[3][2] = m[3][1] = m[3][0] = 0.0f; + m[2][3] = m[1][3] = m[0][3] = 0.0f; + return m; + } + + LSMatrix44 transpose() const { + LSMatrix44 result; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + result[i][j] = (*this)[j][i]; + } + } + return result; + } + +}; + +#endif // VR_LS_MATRIX_H_ + + diff --git a/src/gl/stereo3d/gl_openvr.cpp b/src/gl/stereo3d/gl_openvr.cpp new file mode 100644 index 000000000..7193de0ce --- /dev/null +++ b/src/gl/stereo3d/gl_openvr.cpp @@ -0,0 +1,477 @@ +/* +** gl_openvr.cpp +** Stereoscopic virtual reality mode for the HTC Vive headset +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#ifdef USE_OPENVR + +#include "gl_openvr.h" +#include "openvr.h" +#include +#include "gl/system/gl_system.h" +#include "doomtype.h" // Printf +#include "d_player.h" +#include "g_game.h" // G_Add... +#include "p_local.h" // P_TryMove +#include "r_utility.h" // viewpitch +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "g_levellocals.h" // pixelstretch +#include "math/cmath.h" +#include "c_cvars.h" +#include "LSMatrix.h" + +// For conversion between real-world and doom units +#define VERTICAL_DOOM_UNITS_PER_METER 27.0f + +EXTERN_CVAR(Int, screenblocks); + +using namespace vr; + +// feature toggles, for testing and debugging +static const bool doTrackHmdYaw = true; +static const bool doTrackHmdPitch = true; +static const bool doTrackHmdRoll = true; +static const bool doLateScheduledRotationTracking = true; +static const bool doStereoscopicViewpointOffset = true; +static const bool doRenderToDesktop = true; // mirroring to the desktop is very helpful for debugging +static const bool doRenderToHmd = true; +static const bool doTrackHmdVerticalPosition = false; // todo: +static const bool doTrackHmdHorizontalPostion = false; // todo: +static const bool doTrackVrControllerPosition = false; // todo: + +namespace s3d +{ + +/* static */ +const Stereo3DMode& OpenVRMode::getInstance() +{ + static OpenVRMode instance; + if (! instance.hmdWasFound) + return MonoView::getInstance(); + return instance; +} + +static HmdVector3d_t eulerAnglesFromQuat(HmdQuaternion_t quat) { + double q0 = quat.w; + // permute axes to make "Y" up/yaw + double q2 = quat.x; + double q3 = quat.y; + double q1 = quat.z; + + // http://stackoverflow.com/questions/18433801/converting-a-3x3-matrix-to-euler-tait-bryan-angles-pitch-yaw-roll + double roll = atan2(2 * (q0*q1 + q2*q3), 1 - 2 * (q1*q1 + q2*q2)); + double pitch = asin(2 * (q0*q2 - q3*q1)); + double yaw = atan2(2 * (q0*q3 + q1*q2), 1 - 2 * (q2*q2 + q3*q3)); + + return HmdVector3d_t{ yaw, pitch, roll }; +} + +static HmdQuaternion_t quatFromMatrix(HmdMatrix34_t matrix) { + HmdQuaternion_t q; + typedef float f34[3][4]; + f34& a = matrix.m; + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ + float trace = a[0][0] + a[1][1] + a[2][2]; // I removed + 1.0f; see discussion with Ethan + if (trace > 0) {// I changed M_EPSILON to 0 + float s = 0.5f / sqrtf(trace + 1.0f); + q.w = 0.25f / s; + q.x = (a[2][1] - a[1][2]) * s; + q.y = (a[0][2] - a[2][0]) * s; + q.z = (a[1][0] - a[0][1]) * s; + } + else { + if (a[0][0] > a[1][1] && a[0][0] > a[2][2]) { + float s = 2.0f * sqrtf(1.0f + a[0][0] - a[1][1] - a[2][2]); + q.w = (a[2][1] - a[1][2]) / s; + q.x = 0.25f * s; + q.y = (a[0][1] + a[1][0]) / s; + q.z = (a[0][2] + a[2][0]) / s; + } + else if (a[1][1] > a[2][2]) { + float s = 2.0f * sqrtf(1.0f + a[1][1] - a[0][0] - a[2][2]); + q.w = (a[0][2] - a[2][0]) / s; + q.x = (a[0][1] + a[1][0]) / s; + q.y = 0.25f * s; + q.z = (a[1][2] + a[2][1]) / s; + } + else { + float s = 2.0f * sqrtf(1.0f + a[2][2] - a[0][0] - a[1][1]); + q.w = (a[1][0] - a[0][1]) / s; + q.x = (a[0][2] + a[2][0]) / s; + q.y = (a[1][2] + a[2][1]) / s; + q.z = 0.25f * s; + } + } + + return q; +} + +static HmdVector3d_t eulerAnglesFromMatrix(HmdMatrix34_t mat) { + return eulerAnglesFromQuat(quatFromMatrix(mat)); +} + +OpenVREyePose::OpenVREyePose(vr::EVREye eye) + : ShiftedEyePose( 0.0f ) + , eye(eye) + , eyeTexture(nullptr) + , verticalDoomUnitsPerMeter(VERTICAL_DOOM_UNITS_PER_METER) + , currentPose(nullptr) +{ +} + + +/* virtual */ +OpenVREyePose::~OpenVREyePose() +{ + dispose(); +} + +static void vSMatrixFromHmdMatrix34(VSMatrix& m1, const vr::HmdMatrix34_t& m2) +{ + float tmp[16]; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + tmp[4 * i + j] = m2.m[i][j]; + } + } + int i = 3; + for (int j = 0; j < 4; ++j) { + tmp[4 * i + j] = 0; + } + tmp[15] = 1; + m1.loadMatrix(&tmp[0]); +} + + +/* virtual */ +void OpenVREyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const +{ + outViewShift[0] = outViewShift[1] = outViewShift[2] = 0; + + if (currentPose == nullptr) + return; + const vr::TrackedDevicePose_t& hmd = *currentPose; + if (! hmd.bDeviceIsConnected) + return; + if (! hmd.bPoseIsValid) + return; + + if (! doStereoscopicViewpointOffset) + return; + + const vr::HmdMatrix34_t& hmdPose = hmd.mDeviceToAbsoluteTracking; + + // Pitch and Roll are identical between OpenVR and Doom worlds. + // But yaw can differ, depending on starting state, and controller movement. + float doomYawDegrees = yaw; + float openVrYawDegrees = RAD2DEG(-eulerAnglesFromMatrix(hmdPose).v[0]); + float deltaYawDegrees = doomYawDegrees - openVrYawDegrees; + while (deltaYawDegrees > 180) + deltaYawDegrees -= 360; + while (deltaYawDegrees < -180) + deltaYawDegrees += 360; + + // extract rotation component from hmd transform + LSMatrix44 openvr_X_hmd(hmdPose); + LSMatrix44 hmdRot = openvr_X_hmd.getWithoutTranslation(); // .transpose(); + + /// In these eye methods, just get local inter-eye stereoscopic shift, not full position shift /// + + // compute local eye shift + LSMatrix44 eyeShift2; + eyeShift2.loadIdentity(); + eyeShift2 = eyeShift2 * eyeToHeadTransform; // eye to head + eyeShift2 = eyeShift2 * hmdRot; // head to openvr + + LSVec3 eye_EyePos = LSVec3(0, 0, 0); // eye position in eye frame + LSVec3 hmd_EyePos = LSMatrix44(eyeToHeadTransform) * eye_EyePos; + LSVec3 hmd_HmdPos = LSVec3(0, 0, 0); // hmd position in hmd frame + LSVec3 openvr_EyePos = openvr_X_hmd * hmd_EyePos; + LSVec3 openvr_HmdPos = openvr_X_hmd * hmd_HmdPos; + LSVec3 hmd_OtherEyePos = LSMatrix44(otherEyeToHeadTransform) * eye_EyePos; + LSVec3 openvr_OtherEyePos = openvr_X_hmd * hmd_OtherEyePos; + LSVec3 openvr_EyeOffset = openvr_EyePos - openvr_HmdPos; + + VSMatrix doomInOpenVR = VSMatrix(); + doomInOpenVR.loadIdentity(); + // permute axes + float permute[] = { // Convert from OpenVR to Doom axis convention, including mirror inversion + -1, 0, 0, 0, // X-right in OpenVR -> X-left in Doom + 0, 0, 1, 0, // Z-backward in OpenVR -> Y-backward in Doom + 0, 1, 0, 0, // Y-up in OpenVR -> Z-up in Doom + 0, 0, 0, 1}; + doomInOpenVR.multMatrix(permute); + doomInOpenVR.scale(verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter); // Doom units are not meters + doomInOpenVR.scale(level.info->pixelstretch, level.info->pixelstretch, 1.0); // Doom universe is scaled by 1990s pixel aspect ratio + doomInOpenVR.rotate(deltaYawDegrees, 0, 0, 1); + + LSVec3 doom_EyeOffset = LSMatrix44(doomInOpenVR) * openvr_EyeOffset; + outViewShift[0] = doom_EyeOffset[0]; + outViewShift[1] = doom_EyeOffset[1]; + outViewShift[2] = doom_EyeOffset[2]; +} + +/* virtual */ +VSMatrix OpenVREyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const +{ + // Ignore those arguments and get the projection from the SDK + VSMatrix vs1 = ShiftedEyePose::GetProjection(fov, aspectRatio, fovRatio); + return projectionMatrix; +} + +void OpenVREyePose::initialize(vr::IVRSystem& vrsystem) +{ + float zNear = 5.0; + float zFar = 65536.0; + vr::HmdMatrix44_t projection = vrsystem.GetProjectionMatrix( + eye, zNear, zFar); + vr::HmdMatrix44_t proj_transpose; + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + proj_transpose.m[i][j] = projection.m[j][i]; + } + } + projectionMatrix.loadIdentity(); + projectionMatrix.multMatrix(&proj_transpose.m[0][0]); + + vr::HmdMatrix34_t eyeToHead = vrsystem.GetEyeToHeadTransform(eye); + vSMatrixFromHmdMatrix34(eyeToHeadTransform, eyeToHead); + vr::HmdMatrix34_t otherEyeToHead = vrsystem.GetEyeToHeadTransform(eye == Eye_Left ? Eye_Right : Eye_Left); + vSMatrixFromHmdMatrix34(otherEyeToHeadTransform, otherEyeToHead); + + if (eyeTexture == nullptr) + eyeTexture = new vr::Texture_t(); + eyeTexture->handle = nullptr; // TODO: populate this at resolve time + eyeTexture->eType = vr::TextureType_OpenGL; + eyeTexture->eColorSpace = vr::ColorSpace_Linear; +} + +void OpenVREyePose::dispose() +{ + if (eyeTexture) { + delete eyeTexture; + eyeTexture = nullptr; + } +} + +bool OpenVREyePose::submitFrame() const +{ + if (eyeTexture == nullptr) + return false; + if (vr::VRCompositor() == nullptr) + return false; + eyeTexture->handle = (void *)GLRenderer->mBuffers->GetEyeTextureGLHandle((int)eye); + vr::VRCompositor()->Submit(eye, eyeTexture); + return true; +} + + +OpenVRMode::OpenVRMode() + : vrSystem(nullptr) + , leftEyeView(vr::Eye_Left) + , rightEyeView(vr::Eye_Right) + , hmdWasFound(false) + , sceneWidth(0), sceneHeight(0) +{ + eye_ptrs.Push(&leftEyeView); // default behavior to Mono non-stereo rendering + + EVRInitError eError; + if (VR_IsHmdPresent()) + { + vrSystem = VR_Init(&eError, VRApplication_Scene); + if (eError != vr::VRInitError_None) { + std::string errMsg = VR_GetVRInitErrorAsEnglishDescription(eError); + vrSystem = nullptr; + return; + // TODO: report error + } + vrSystem->GetRecommendedRenderTargetSize(&sceneWidth, &sceneHeight); + + // OK + leftEyeView.initialize(*vrSystem); + rightEyeView.initialize(*vrSystem); + + if (!vr::VRCompositor()) + return; + + eye_ptrs.Push(&rightEyeView); // NOW we render to two eyes + hmdWasFound = true; + } +} + +/* virtual */ +// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...) +void OpenVRMode::AdjustViewports() const +{ + // Draw the 3D scene into the entire framebuffer + GLRenderer->mSceneViewport.width = sceneWidth; + GLRenderer->mSceneViewport.height = sceneHeight; + GLRenderer->mSceneViewport.left = 0; + GLRenderer->mSceneViewport.top = 0; + + GLRenderer->mScreenViewport.width = sceneWidth; + GLRenderer->mScreenViewport.height = sceneHeight; +} + +/* virtual */ +void OpenVRMode::Present() const { + // TODO: For performance, don't render to the desktop screen here + if (doRenderToDesktop) { + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int leftWidth = GLRenderer->mOutputLetterbox.width / 2; + int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; + GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; + leftHalfScreen.width = leftWidth; + GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; + rightHalfScreen.width = rightWidth; + rightHalfScreen.left += leftWidth; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(leftHalfScreen, true); + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(rightHalfScreen, true); + } + + if (doRenderToHmd) + { + leftEyeView.submitFrame(); + rightEyeView.submitFrame(); + } +} + +static int mAngleFromRadians(double radians) +{ + double m = std::round(65535.0 * radians / (2.0 * M_PI)); + return int(m); +} + +void OpenVRMode::updateHmdPose( + double hmdYawRadians, + double hmdPitchRadians, + double hmdRollRadians) const +{ + double hmdyaw = hmdYawRadians; + double hmdpitch = hmdPitchRadians; + double hmdroll = hmdRollRadians; + + double dYaw = 0; + if (doTrackHmdYaw) { + // Set HMD angle game state parameters for NEXT frame + static double previousYaw = 0; + static bool havePreviousYaw = false; + if (!havePreviousYaw) { + previousYaw = hmdyaw; + havePreviousYaw = true; + } + dYaw = hmdyaw - previousYaw; + G_AddViewAngle(mAngleFromRadians(-dYaw)); + previousYaw = hmdyaw; + } + + /* */ + // Pitch + if (doTrackHmdPitch) { + double hmdPitchInDoom = -atan(tan(hmdpitch) / level.info->pixelstretch); + double viewPitchInDoom = GLRenderer->mAngles.Pitch.Radians(); + double dPitch = hmdPitchInDoom - viewPitchInDoom; + G_AddViewPitch(mAngleFromRadians(-dPitch)); + } + + // Roll can be local, because it doesn't affect gameplay. + if (doTrackHmdRoll) + GLRenderer->mAngles.Roll = RAD2DEG(-hmdroll); + + // Late-schedule update to renderer angles directly, too + if (doLateScheduledRotationTracking) { + if (doTrackHmdPitch) + GLRenderer->mAngles.Pitch = RAD2DEG(-hmdpitch); + if (doTrackHmdYaw) + GLRenderer->mAngles.Yaw += RAD2DEG(dYaw); // "plus" is the correct direction + } +} + +/* virtual */ +void OpenVRMode::SetUp() const +{ + super::SetUp(); + + cachedScreenBlocks = screenblocks; + screenblocks = 12; // always be full-screen during 3D scene render + + if (vr::VRCompositor() == nullptr) + return; + + static vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]; + vr::VRCompositor()->WaitGetPoses( + poses, vr::k_unMaxTrackedDeviceCount, // current pose + nullptr, 0 // future pose? + ); + + TrackedDevicePose_t& hmdPose0 = poses[vr::k_unTrackedDeviceIndex_Hmd]; + + if (hmdPose0.bPoseIsValid) { + const vr::HmdMatrix34_t& hmdPose = hmdPose0.mDeviceToAbsoluteTracking; + HmdVector3d_t eulerAngles = eulerAnglesFromMatrix(hmdPose); + // Printf("%.1f %.1f %.1f\n", eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); + updateHmdPose(eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); + leftEyeView.setCurrentHmdPose(&hmdPose0); + rightEyeView.setCurrentHmdPose(&hmdPose0); + // TODO: position tracking + } +} + +/* virtual */ +void OpenVRMode::TearDown() const +{ + screenblocks = cachedScreenBlocks; + super::TearDown(); +} + +/* virtual */ +OpenVRMode::~OpenVRMode() +{ + if (vrSystem != nullptr) { + VR_Shutdown(); + vrSystem = nullptr; + leftEyeView.dispose(); + rightEyeView.dispose(); + } +} + +} /* namespace s3d */ + +#endif + diff --git a/src/gl/stereo3d/gl_openvr.h b/src/gl/stereo3d/gl_openvr.h new file mode 100644 index 000000000..352be6b7b --- /dev/null +++ b/src/gl/stereo3d/gl_openvr.h @@ -0,0 +1,111 @@ +/* +** gl_openvr.h +** Stereoscopic virtual reality mode for the HTC Vive headset +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_OPENVR_H_ +#define GL_OPENVR_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" + +// forward declaration from openvr.h +namespace vr { + class IVRSystem; + struct HmdMatrix44_t; + struct Texture_t; + struct TrackedDevicePose_t; + enum EVREye; +} + +/* stereoscopic 3D API */ +namespace s3d { + +class OpenVREyePose : public ShiftedEyePose +{ +public: + OpenVREyePose(vr::EVREye eye); + virtual ~OpenVREyePose() override; + virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const override; + virtual void GetViewShift(float yaw, float outViewShift[3]) const override; + + void initialize(vr::IVRSystem& vrsystem); + void dispose(); + void setCurrentHmdPose(const vr::TrackedDevicePose_t * pose) const {currentPose = pose;} + bool submitFrame() const; + +protected: + VSMatrix projectionMatrix; + VSMatrix eyeToHeadTransform; + VSMatrix otherEyeToHeadTransform; + vr::Texture_t* eyeTexture; + vr::EVREye eye; + + // TODO: adjust doomUnitsPerMeter according to player height + float verticalDoomUnitsPerMeter; + + mutable const vr::TrackedDevicePose_t * currentPose; +}; + +class OpenVRMode : public Stereo3DMode +{ +public: + static const Stereo3DMode& getInstance(); // Might return Mono mode, if no HMD available + + virtual ~OpenVRMode() override; + virtual void SetUp() const override; // called immediately before rendering a scene frame + virtual void TearDown() const override; // called immediately after rendering a scene frame + virtual void Present() const override; + virtual void AdjustViewports() const override; + +protected: + OpenVRMode(); + // void updateDoomViewDirection() const; + void updateHmdPose(double hmdYawRadians, double hmdPitchRadians, double hmdRollRadians) const; + + OpenVREyePose leftEyeView; + OpenVREyePose rightEyeView; + + vr::IVRSystem* vrSystem; + mutable int cachedScreenBlocks; + +private: + typedef Stereo3DMode super; + bool hmdWasFound; + uint32_t sceneWidth, sceneHeight; +}; + +} /* namespace st3d */ + + +#endif /* GL_OPENVR_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 201e33590..7c87290e4 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -25,10 +25,12 @@ ** */ -#include "gl/stereo3d/gl_stereo3d.h" -#include "gl/stereo3d/gl_stereo_leftright.h" -#include "gl/stereo3d/gl_anaglyph.h" -#include "gl/stereo3d/gl_quadstereo.h" +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl_anaglyph.h" +#include "gl_openvr.h" +#include "gl_quadstereo.h" +#include "gl_sidebyside3d.h" #include "gl/stereo3d/gl_sidebyside3d.h" #include "gl/stereo3d/gl_interleaved3d.h" #include "gl/system/gl_cvars.h" @@ -101,8 +103,12 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() // TODO: 8: Oculus Rift case 9: setCurrentMode(AmberBlue::getInstance(vr_ipd)); - break; - // TODO: 10: HTC Vive/OpenVR + break; +#ifdef USE_OPENVR + case 10: + setCurrentMode(OpenVRMode::getInstance()); + break; +#endif case 11: setCurrentMode(TopBottom3D::getInstance(vr_ipd)); break; diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index ac2b89a27..5aa1ed08d 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -31,7 +31,7 @@ namespace s3d { -ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters +ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in doom units { // save original values cachedView = r_viewpoint.Pos; diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index bac7f2dac..1306adec1 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -40,7 +40,7 @@ namespace s3d { class ScopedViewShifter { public: - ScopedViewShifter(float dxyz[3]); // in meters + ScopedViewShifter(float dxyz[3]); // in doom units ~ScopedViewShifter(); private: diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index f12fab551..aff18cb93 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2786,6 +2786,7 @@ OPTVAL_ROWINTERLEAVED = "Row Interleaved"; OPTVAL_COLUMNINTERLEAVED = "Column Interleaved"; OPTVAL_CHECKERBOARD = "Checkerboard"; OPTVAL_QUADBUFFERED = "Quad-buffered"; +OPTVAL_OPENVR = "OpenVR-Vive"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; OPTVAL_REINHARD = "Reinhard"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index e27c98a29..e9a4ed3e8 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2097,6 +2097,7 @@ OptionValue VRMode 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED" + 10, "$OPTVAL_OPENVR" } OptionMenu "GLTextureGLOptions" From a149b542260aa1e9347c8fd2d8805033042fefb7 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 27 May 2017 20:16:00 -0400 Subject: [PATCH 23/82] Maybe avoid gcc compile problem with forward declared enum. --- src/gl/stereo3d/gl_openvr.cpp | 8 ++++---- src/gl/stereo3d/gl_openvr.h | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gl/stereo3d/gl_openvr.cpp b/src/gl/stereo3d/gl_openvr.cpp index 7193de0ce..bd0aecdc9 100644 --- a/src/gl/stereo3d/gl_openvr.cpp +++ b/src/gl/stereo3d/gl_openvr.cpp @@ -140,7 +140,7 @@ static HmdVector3d_t eulerAnglesFromMatrix(HmdMatrix34_t mat) { return eulerAnglesFromQuat(quatFromMatrix(mat)); } -OpenVREyePose::OpenVREyePose(vr::EVREye eye) +OpenVREyePose::OpenVREyePose(int eye) : ShiftedEyePose( 0.0f ) , eye(eye) , eyeTexture(nullptr) @@ -254,7 +254,7 @@ void OpenVREyePose::initialize(vr::IVRSystem& vrsystem) float zNear = 5.0; float zFar = 65536.0; vr::HmdMatrix44_t projection = vrsystem.GetProjectionMatrix( - eye, zNear, zFar); + vr::EVREye(eye), zNear, zFar); vr::HmdMatrix44_t proj_transpose; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { @@ -264,7 +264,7 @@ void OpenVREyePose::initialize(vr::IVRSystem& vrsystem) projectionMatrix.loadIdentity(); projectionMatrix.multMatrix(&proj_transpose.m[0][0]); - vr::HmdMatrix34_t eyeToHead = vrsystem.GetEyeToHeadTransform(eye); + vr::HmdMatrix34_t eyeToHead = vrsystem.GetEyeToHeadTransform(vr::EVREye(eye)); vSMatrixFromHmdMatrix34(eyeToHeadTransform, eyeToHead); vr::HmdMatrix34_t otherEyeToHead = vrsystem.GetEyeToHeadTransform(eye == Eye_Left ? Eye_Right : Eye_Left); vSMatrixFromHmdMatrix34(otherEyeToHeadTransform, otherEyeToHead); @@ -291,7 +291,7 @@ bool OpenVREyePose::submitFrame() const if (vr::VRCompositor() == nullptr) return false; eyeTexture->handle = (void *)GLRenderer->mBuffers->GetEyeTextureGLHandle((int)eye); - vr::VRCompositor()->Submit(eye, eyeTexture); + vr::VRCompositor()->Submit(vr::EVREye(eye), eyeTexture); return true; } diff --git a/src/gl/stereo3d/gl_openvr.h b/src/gl/stereo3d/gl_openvr.h index 352be6b7b..9fc905207 100644 --- a/src/gl/stereo3d/gl_openvr.h +++ b/src/gl/stereo3d/gl_openvr.h @@ -45,7 +45,6 @@ namespace vr { struct HmdMatrix44_t; struct Texture_t; struct TrackedDevicePose_t; - enum EVREye; } /* stereoscopic 3D API */ @@ -54,7 +53,7 @@ namespace s3d { class OpenVREyePose : public ShiftedEyePose { public: - OpenVREyePose(vr::EVREye eye); + OpenVREyePose(int eye); virtual ~OpenVREyePose() override; virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const override; virtual void GetViewShift(float yaw, float outViewShift[3]) const override; @@ -69,7 +68,7 @@ protected: VSMatrix eyeToHeadTransform; VSMatrix otherEyeToHeadTransform; vr::Texture_t* eyeTexture; - vr::EVREye eye; + int eye; // TODO: adjust doomUnitsPerMeter according to player height float verticalDoomUnitsPerMeter; From a49afd5bfc6f92c6cdbcc54867dbe66c94ef6dcb Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 28 May 2017 06:20:32 -0400 Subject: [PATCH 24/82] Initial OpenVR mode. Second attempt: clean up commit, and avoid messing with HDR framebuffer format. --- CMakeLists.txt | 2 + src/CMakeLists.txt | 26 ++ src/gl/data/gl_matrix.h | 2 +- src/gl/stereo3d/LSMatrix.h | 162 ++++++++ src/gl/stereo3d/gl_openvr.cpp | 492 ++++++++++++++++++++++++ src/gl/stereo3d/gl_openvr.h | 110 ++++++ src/gl/stereo3d/gl_stereo_cvars.cpp | 18 +- src/gl/stereo3d/scoped_view_shifter.cpp | 2 +- src/gl/stereo3d/scoped_view_shifter.h | 2 +- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 11 files changed, 809 insertions(+), 9 deletions(-) create mode 100644 src/gl/stereo3d/LSMatrix.h create mode 100644 src/gl/stereo3d/gl_openvr.cpp create mode 100644 src/gl/stereo3d/gl_openvr.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d4b402326..da865aaac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,6 +300,8 @@ endif() set( LZMA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lzma/C" ) +option( GZDOOM_USE_OPENVR "Support OpenVR API for virtual reality head mounted displays" OFF ) + if( NOT CMAKE_CROSSCOMPILING ) if( NOT CROSS_EXPORTS ) set( CROSS_EXPORTS "" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 387d6855f..448280c14 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -473,6 +473,31 @@ if( NOT DYN_FLUIDSYNTH ) endif() endif() +if (GZDOOM_USE_OPENVR) + find_path(OPENVR_SDK_PATH + NAMES + headers/openvr.h + HINTS + ENV OPENVR_DIR ENV PROGRAMFILES ENV HOME ENV USERPROFILE + PATH_SUFFIXES + openvr git/openvr + ) + find_path(OPENVR_INCLUDE_DIRECTORY + NAMES + openvr.h + HINTS + ${OPENVR_SDK_PATH}/headers + ) + include_directories("${OPENVR_INCLUDE_DIRECTORY}") + find_library(OPENVR_LIBRARY + NAMES openvr_api + # TODO: Generalize for Mac and Linux and 64-bit Windows + HINTS "${OPENVR_SDK_PATH}/lib/win32/" + ) + list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) + add_definitions("-DUSE_OPENVR") +endif() + # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES sound/mididevices/music_win_mididevice.cpp @@ -1006,6 +1031,7 @@ set (PCH_SOURCES gl/stereo3d/gl_stereo_leftright.cpp gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp + gl/stereo3d/gl_openvr.cpp gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_sidebyside3d.cpp gl/stereo3d/gl_interleaved3d.cpp diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h index 3ec1f5ff4..12ef2f12b 100644 --- a/src/gl/data/gl_matrix.h +++ b/src/gl/data/gl_matrix.h @@ -62,7 +62,7 @@ class VSMatrix { void perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp); void ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp=-1.0f, FLOATTYPE farp=1.0f); void frustum(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp, FLOATTYPE farp); - void copy(FLOATTYPE * pDest) + void copy(FLOATTYPE * pDest) const { memcpy(pDest, mMatrix, 16 * sizeof(FLOATTYPE)); } diff --git a/src/gl/stereo3d/LSMatrix.h b/src/gl/stereo3d/LSMatrix.h new file mode 100644 index 000000000..a0e401838 --- /dev/null +++ b/src/gl/stereo3d/LSMatrix.h @@ -0,0 +1,162 @@ +/* +** LSMatrix.h +** less-simple matrix class +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + + +#ifndef VR_LS_MATRIX_H_ +#define VR_LS_MATRIX_H_ + +#include "gl/data/gl_matrix.h" +#include "openvr.h" + +namespace vr { + HmdMatrix34_t; +} + +class LSVec3 +{ +public: + LSVec3(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w=1.0f) + : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) + { + mVec[0] = x; + mVec[1] = y; + mVec[2] = z; + mVec[3] = w; + } + + LSVec3(const LSVec3& rhs) + : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) + { + *this = rhs; + } + + LSVec3& operator=(const LSVec3& rhs) { + LSVec3& lhs = *this; + for (int i = 0; i < 4; ++i) + lhs[i] = rhs[i]; + return *this; + } + + const FLOATTYPE& operator[](int i) const {return mVec[i];} + FLOATTYPE& operator[](int i) { return mVec[i]; } + + LSVec3 operator-(const LSVec3& rhs) const { + const LSVec3& lhs = *this; + LSVec3 result = *this; + for (int i = 0; i < 4; ++i) + result[i] -= rhs[i]; + return result; + } + + FLOATTYPE mVec[4]; + FLOATTYPE& x; + FLOATTYPE& y; + FLOATTYPE& z; + FLOATTYPE& w; +}; + +LSVec3 operator*(FLOATTYPE s, const LSVec3& rhs) { + LSVec3 result = rhs; + for (int i = 0; i < 4; ++i) + result[i] *= s; + return result; +} + +class LSMatrix44 : public VSMatrix +{ +public: + LSMatrix44() + { + loadIdentity(); + } + + LSMatrix44(const vr::HmdMatrix34_t& m) { + loadIdentity(); + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + (*this)[i][j] = m.m[i][j]; + } + } + } + + LSMatrix44(const VSMatrix& m) { + m.copy(mMatrix); + } + + // overload bracket operator to return one row of the matrix, so you can invoke, say, m[2][3] + FLOATTYPE* operator[](int i) {return &mMatrix[i*4];} + const FLOATTYPE* operator[](int i) const { return &mMatrix[i * 4]; } + + LSMatrix44 operator*(const VSMatrix& rhs) const { + LSMatrix44 result(*this); + result.multMatrix(rhs); + return result; + } + + LSVec3 operator*(const LSVec3& rhs) const { + const LSMatrix44& lhs = *this; + LSVec3 result(0, 0, 0, 0); + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + result[i] += lhs[i][j] * rhs[j]; + } + } + return result; + } + + LSMatrix44 getWithoutTranslation() const { + LSMatrix44 m = *this; + // Remove translation component + m[3][3] = 1.0f; + m[3][2] = m[3][1] = m[3][0] = 0.0f; + m[2][3] = m[1][3] = m[0][3] = 0.0f; + return m; + } + + LSMatrix44 transpose() const { + LSMatrix44 result; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + result[i][j] = (*this)[j][i]; + } + } + return result; + } + +}; + +#endif // VR_LS_MATRIX_H_ + + diff --git a/src/gl/stereo3d/gl_openvr.cpp b/src/gl/stereo3d/gl_openvr.cpp new file mode 100644 index 000000000..181f0bee7 --- /dev/null +++ b/src/gl/stereo3d/gl_openvr.cpp @@ -0,0 +1,492 @@ +/* +** gl_openvr.cpp +** Stereoscopic virtual reality mode for the HTC Vive headset +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#ifdef USE_OPENVR + +#include "gl_openvr.h" +#include "openvr.h" +#include +#include "gl/system/gl_system.h" +#include "doomtype.h" // Printf +#include "d_player.h" +#include "g_game.h" // G_Add... +#include "p_local.h" // P_TryMove +#include "r_utility.h" // viewpitch +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "g_levellocals.h" // pixelstretch +#include "math/cmath.h" +#include "c_cvars.h" +#include "LSMatrix.h" + +// For conversion between real-world and doom units +#define VERTICAL_DOOM_UNITS_PER_METER 27.0f + +EXTERN_CVAR(Int, screenblocks); + +using namespace vr; + +// feature toggles, for testing and debugging +static const bool doTrackHmdYaw = true; +static const bool doTrackHmdPitch = true; +static const bool doTrackHmdRoll = true; +static const bool doLateScheduledRotationTracking = true; +static const bool doStereoscopicViewpointOffset = true; +static const bool doRenderToDesktop = true; // mirroring to the desktop is very helpful for debugging +static const bool doRenderToHmd = true; +static const bool doTrackHmdVerticalPosition = false; // todo: +static const bool doTrackHmdHorizontalPostion = false; // todo: +static const bool doTrackVrControllerPosition = false; // todo: + +namespace s3d +{ + +/* static */ +const Stereo3DMode& OpenVRMode::getInstance() +{ + static OpenVRMode instance; + if (! instance.hmdWasFound) + return MonoView::getInstance(); + return instance; +} + +static HmdVector3d_t eulerAnglesFromQuat(HmdQuaternion_t quat) { + double q0 = quat.w; + // permute axes to make "Y" up/yaw + double q2 = quat.x; + double q3 = quat.y; + double q1 = quat.z; + + // http://stackoverflow.com/questions/18433801/converting-a-3x3-matrix-to-euler-tait-bryan-angles-pitch-yaw-roll + double roll = atan2(2 * (q0*q1 + q2*q3), 1 - 2 * (q1*q1 + q2*q2)); + double pitch = asin(2 * (q0*q2 - q3*q1)); + double yaw = atan2(2 * (q0*q3 + q1*q2), 1 - 2 * (q2*q2 + q3*q3)); + + return HmdVector3d_t{ yaw, pitch, roll }; +} + +static HmdQuaternion_t quatFromMatrix(HmdMatrix34_t matrix) { + HmdQuaternion_t q; + typedef float f34[3][4]; + f34& a = matrix.m; + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ + float trace = a[0][0] + a[1][1] + a[2][2]; // I removed + 1.0f; see discussion with Ethan + if (trace > 0) {// I changed M_EPSILON to 0 + float s = 0.5f / sqrtf(trace + 1.0f); + q.w = 0.25f / s; + q.x = (a[2][1] - a[1][2]) * s; + q.y = (a[0][2] - a[2][0]) * s; + q.z = (a[1][0] - a[0][1]) * s; + } + else { + if (a[0][0] > a[1][1] && a[0][0] > a[2][2]) { + float s = 2.0f * sqrtf(1.0f + a[0][0] - a[1][1] - a[2][2]); + q.w = (a[2][1] - a[1][2]) / s; + q.x = 0.25f * s; + q.y = (a[0][1] + a[1][0]) / s; + q.z = (a[0][2] + a[2][0]) / s; + } + else if (a[1][1] > a[2][2]) { + float s = 2.0f * sqrtf(1.0f + a[1][1] - a[0][0] - a[2][2]); + q.w = (a[0][2] - a[2][0]) / s; + q.x = (a[0][1] + a[1][0]) / s; + q.y = 0.25f * s; + q.z = (a[1][2] + a[2][1]) / s; + } + else { + float s = 2.0f * sqrtf(1.0f + a[2][2] - a[0][0] - a[1][1]); + q.w = (a[1][0] - a[0][1]) / s; + q.x = (a[0][2] + a[2][0]) / s; + q.y = (a[1][2] + a[2][1]) / s; + q.z = 0.25f * s; + } + } + + return q; +} + +static HmdVector3d_t eulerAnglesFromMatrix(HmdMatrix34_t mat) { + return eulerAnglesFromQuat(quatFromMatrix(mat)); +} + +OpenVREyePose::OpenVREyePose(int eye) + : ShiftedEyePose( 0.0f ) + , eye(eye) + , eyeTexture(nullptr) + , verticalDoomUnitsPerMeter(VERTICAL_DOOM_UNITS_PER_METER) + , currentPose(nullptr) +{ +} + + +/* virtual */ +OpenVREyePose::~OpenVREyePose() +{ + dispose(); +} + +static void vSMatrixFromHmdMatrix34(VSMatrix& m1, const vr::HmdMatrix34_t& m2) +{ + float tmp[16]; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + tmp[4 * i + j] = m2.m[i][j]; + } + } + int i = 3; + for (int j = 0; j < 4; ++j) { + tmp[4 * i + j] = 0; + } + tmp[15] = 1; + m1.loadMatrix(&tmp[0]); +} + + +/* virtual */ +void OpenVREyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const +{ + outViewShift[0] = outViewShift[1] = outViewShift[2] = 0; + + if (currentPose == nullptr) + return; + const vr::TrackedDevicePose_t& hmd = *currentPose; + if (! hmd.bDeviceIsConnected) + return; + if (! hmd.bPoseIsValid) + return; + + if (! doStereoscopicViewpointOffset) + return; + + const vr::HmdMatrix34_t& hmdPose = hmd.mDeviceToAbsoluteTracking; + + // Pitch and Roll are identical between OpenVR and Doom worlds. + // But yaw can differ, depending on starting state, and controller movement. + float doomYawDegrees = yaw; + float openVrYawDegrees = RAD2DEG(-eulerAnglesFromMatrix(hmdPose).v[0]); + float deltaYawDegrees = doomYawDegrees - openVrYawDegrees; + while (deltaYawDegrees > 180) + deltaYawDegrees -= 360; + while (deltaYawDegrees < -180) + deltaYawDegrees += 360; + + // extract rotation component from hmd transform + LSMatrix44 openvr_X_hmd(hmdPose); + LSMatrix44 hmdRot = openvr_X_hmd.getWithoutTranslation(); // .transpose(); + + /// In these eye methods, just get local inter-eye stereoscopic shift, not full position shift /// + + // compute local eye shift + LSMatrix44 eyeShift2; + eyeShift2.loadIdentity(); + eyeShift2 = eyeShift2 * eyeToHeadTransform; // eye to head + eyeShift2 = eyeShift2 * hmdRot; // head to openvr + + LSVec3 eye_EyePos = LSVec3(0, 0, 0); // eye position in eye frame + LSVec3 hmd_EyePos = LSMatrix44(eyeToHeadTransform) * eye_EyePos; + LSVec3 hmd_HmdPos = LSVec3(0, 0, 0); // hmd position in hmd frame + LSVec3 openvr_EyePos = openvr_X_hmd * hmd_EyePos; + LSVec3 openvr_HmdPos = openvr_X_hmd * hmd_HmdPos; + LSVec3 hmd_OtherEyePos = LSMatrix44(otherEyeToHeadTransform) * eye_EyePos; + LSVec3 openvr_OtherEyePos = openvr_X_hmd * hmd_OtherEyePos; + LSVec3 openvr_EyeOffset = openvr_EyePos - openvr_HmdPos; + + VSMatrix doomInOpenVR = VSMatrix(); + doomInOpenVR.loadIdentity(); + // permute axes + float permute[] = { // Convert from OpenVR to Doom axis convention, including mirror inversion + -1, 0, 0, 0, // X-right in OpenVR -> X-left in Doom + 0, 0, 1, 0, // Z-backward in OpenVR -> Y-backward in Doom + 0, 1, 0, 0, // Y-up in OpenVR -> Z-up in Doom + 0, 0, 0, 1}; + doomInOpenVR.multMatrix(permute); + doomInOpenVR.scale(verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter); // Doom units are not meters + doomInOpenVR.scale(level.info->pixelstretch, level.info->pixelstretch, 1.0); // Doom universe is scaled by 1990s pixel aspect ratio + doomInOpenVR.rotate(deltaYawDegrees, 0, 0, 1); + + LSVec3 doom_EyeOffset = LSMatrix44(doomInOpenVR) * openvr_EyeOffset; + outViewShift[0] = doom_EyeOffset[0]; + outViewShift[1] = doom_EyeOffset[1]; + outViewShift[2] = doom_EyeOffset[2]; +} + +/* virtual */ +VSMatrix OpenVREyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const +{ + // Ignore those arguments and get the projection from the SDK + VSMatrix vs1 = ShiftedEyePose::GetProjection(fov, aspectRatio, fovRatio); + return projectionMatrix; +} + +void OpenVREyePose::initialize(vr::IVRSystem& vrsystem) +{ + float zNear = 5.0; + float zFar = 65536.0; + vr::HmdMatrix44_t projection = vrsystem.GetProjectionMatrix( + vr::EVREye(eye), zNear, zFar); + vr::HmdMatrix44_t proj_transpose; + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + proj_transpose.m[i][j] = projection.m[j][i]; + } + } + projectionMatrix.loadIdentity(); + projectionMatrix.multMatrix(&proj_transpose.m[0][0]); + + vr::HmdMatrix34_t eyeToHead = vrsystem.GetEyeToHeadTransform(vr::EVREye(eye)); + vSMatrixFromHmdMatrix34(eyeToHeadTransform, eyeToHead); + vr::HmdMatrix34_t otherEyeToHead = vrsystem.GetEyeToHeadTransform(eye == Eye_Left ? Eye_Right : Eye_Left); + vSMatrixFromHmdMatrix34(otherEyeToHeadTransform, otherEyeToHead); + + if (eyeTexture == nullptr) + eyeTexture = new vr::Texture_t(); + eyeTexture->handle = nullptr; // TODO: populate this at resolve time + eyeTexture->eType = vr::TextureType_OpenGL; + eyeTexture->eColorSpace = vr::ColorSpace_Linear; +} + +void OpenVREyePose::dispose() +{ + if (eyeTexture) { + delete eyeTexture; + eyeTexture = nullptr; + } +} + +bool OpenVREyePose::submitFrame() const +{ + if (eyeTexture == nullptr) + return false; + if (vr::VRCompositor() == nullptr) + return false; + // Copy HDR framebuffer into 24-bit RGB texture + GLRenderer->mBuffers->BindEyeFB(eye, true); + if (eyeTexture->handle == nullptr) { + GLuint handle; + glGenTextures(1, &handle); + eyeTexture->handle = (void *)handle; + glBindTexture(GL_TEXTURE_2D, handle); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, GLRenderer->mSceneViewport.width, + GLRenderer->mSceneViewport.height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); + } + glBindTexture(GL_TEXTURE_2D, (GLuint)eyeTexture->handle); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 0, 0, + GLRenderer->mSceneViewport.width, + GLRenderer->mSceneViewport.height, 0); + vr::VRCompositor()->Submit(vr::EVREye(eye), eyeTexture); + return true; +} + + +OpenVRMode::OpenVRMode() + : vrSystem(nullptr) + , leftEyeView(vr::Eye_Left) + , rightEyeView(vr::Eye_Right) + , hmdWasFound(false) + , sceneWidth(0), sceneHeight(0) +{ + eye_ptrs.Push(&leftEyeView); // default behavior to Mono non-stereo rendering + + EVRInitError eError; + if (VR_IsHmdPresent()) + { + vrSystem = VR_Init(&eError, VRApplication_Scene); + if (eError != vr::VRInitError_None) { + std::string errMsg = VR_GetVRInitErrorAsEnglishDescription(eError); + vrSystem = nullptr; + return; + // TODO: report error + } + vrSystem->GetRecommendedRenderTargetSize(&sceneWidth, &sceneHeight); + + // OK + leftEyeView.initialize(*vrSystem); + rightEyeView.initialize(*vrSystem); + + if (!vr::VRCompositor()) + return; + + eye_ptrs.Push(&rightEyeView); // NOW we render to two eyes + hmdWasFound = true; + } +} + +/* virtual */ +// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...) +void OpenVRMode::AdjustViewports() const +{ + // Draw the 3D scene into the entire framebuffer + GLRenderer->mSceneViewport.width = sceneWidth; + GLRenderer->mSceneViewport.height = sceneHeight; + GLRenderer->mSceneViewport.left = 0; + GLRenderer->mSceneViewport.top = 0; + + GLRenderer->mScreenViewport.width = sceneWidth; + GLRenderer->mScreenViewport.height = sceneHeight; +} + +/* virtual */ +void OpenVRMode::Present() const { + // TODO: For performance, don't render to the desktop screen here + if (doRenderToDesktop) { + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int leftWidth = GLRenderer->mOutputLetterbox.width / 2; + int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; + GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; + leftHalfScreen.width = leftWidth; + GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; + rightHalfScreen.width = rightWidth; + rightHalfScreen.left += leftWidth; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(leftHalfScreen, true); + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(rightHalfScreen, true); + } + + if (doRenderToHmd) + { + leftEyeView.submitFrame(); + rightEyeView.submitFrame(); + } +} + +static int mAngleFromRadians(double radians) +{ + double m = std::round(65535.0 * radians / (2.0 * M_PI)); + return int(m); +} + +void OpenVRMode::updateHmdPose( + double hmdYawRadians, + double hmdPitchRadians, + double hmdRollRadians) const +{ + double hmdyaw = hmdYawRadians; + double hmdpitch = hmdPitchRadians; + double hmdroll = hmdRollRadians; + + double dYaw = 0; + if (doTrackHmdYaw) { + // Set HMD angle game state parameters for NEXT frame + static double previousYaw = 0; + static bool havePreviousYaw = false; + if (!havePreviousYaw) { + previousYaw = hmdyaw; + havePreviousYaw = true; + } + dYaw = hmdyaw - previousYaw; + G_AddViewAngle(mAngleFromRadians(-dYaw)); + previousYaw = hmdyaw; + } + + /* */ + // Pitch + if (doTrackHmdPitch) { + double hmdPitchInDoom = -atan(tan(hmdpitch) / level.info->pixelstretch); + double viewPitchInDoom = GLRenderer->mAngles.Pitch.Radians(); + double dPitch = hmdPitchInDoom - viewPitchInDoom; + G_AddViewPitch(mAngleFromRadians(-dPitch)); + } + + // Roll can be local, because it doesn't affect gameplay. + if (doTrackHmdRoll) + GLRenderer->mAngles.Roll = RAD2DEG(-hmdroll); + + // Late-schedule update to renderer angles directly, too + if (doLateScheduledRotationTracking) { + if (doTrackHmdPitch) + GLRenderer->mAngles.Pitch = RAD2DEG(-hmdpitch); + if (doTrackHmdYaw) + GLRenderer->mAngles.Yaw += RAD2DEG(dYaw); // "plus" is the correct direction + } +} + +/* virtual */ +void OpenVRMode::SetUp() const +{ + super::SetUp(); + + cachedScreenBlocks = screenblocks; + screenblocks = 12; // always be full-screen during 3D scene render + + if (vr::VRCompositor() == nullptr) + return; + + static vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]; + vr::VRCompositor()->WaitGetPoses( + poses, vr::k_unMaxTrackedDeviceCount, // current pose + nullptr, 0 // future pose? + ); + + TrackedDevicePose_t& hmdPose0 = poses[vr::k_unTrackedDeviceIndex_Hmd]; + + if (hmdPose0.bPoseIsValid) { + const vr::HmdMatrix34_t& hmdPose = hmdPose0.mDeviceToAbsoluteTracking; + HmdVector3d_t eulerAngles = eulerAnglesFromMatrix(hmdPose); + // Printf("%.1f %.1f %.1f\n", eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); + updateHmdPose(eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); + leftEyeView.setCurrentHmdPose(&hmdPose0); + rightEyeView.setCurrentHmdPose(&hmdPose0); + // TODO: position tracking + } +} + +/* virtual */ +void OpenVRMode::TearDown() const +{ + screenblocks = cachedScreenBlocks; + super::TearDown(); +} + +/* virtual */ +OpenVRMode::~OpenVRMode() +{ + if (vrSystem != nullptr) { + VR_Shutdown(); + vrSystem = nullptr; + leftEyeView.dispose(); + rightEyeView.dispose(); + } +} + +} /* namespace s3d */ + +#endif + diff --git a/src/gl/stereo3d/gl_openvr.h b/src/gl/stereo3d/gl_openvr.h new file mode 100644 index 000000000..9fc905207 --- /dev/null +++ b/src/gl/stereo3d/gl_openvr.h @@ -0,0 +1,110 @@ +/* +** gl_openvr.h +** Stereoscopic virtual reality mode for the HTC Vive headset +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_OPENVR_H_ +#define GL_OPENVR_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" + +// forward declaration from openvr.h +namespace vr { + class IVRSystem; + struct HmdMatrix44_t; + struct Texture_t; + struct TrackedDevicePose_t; +} + +/* stereoscopic 3D API */ +namespace s3d { + +class OpenVREyePose : public ShiftedEyePose +{ +public: + OpenVREyePose(int eye); + virtual ~OpenVREyePose() override; + virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const override; + virtual void GetViewShift(float yaw, float outViewShift[3]) const override; + + void initialize(vr::IVRSystem& vrsystem); + void dispose(); + void setCurrentHmdPose(const vr::TrackedDevicePose_t * pose) const {currentPose = pose;} + bool submitFrame() const; + +protected: + VSMatrix projectionMatrix; + VSMatrix eyeToHeadTransform; + VSMatrix otherEyeToHeadTransform; + vr::Texture_t* eyeTexture; + int eye; + + // TODO: adjust doomUnitsPerMeter according to player height + float verticalDoomUnitsPerMeter; + + mutable const vr::TrackedDevicePose_t * currentPose; +}; + +class OpenVRMode : public Stereo3DMode +{ +public: + static const Stereo3DMode& getInstance(); // Might return Mono mode, if no HMD available + + virtual ~OpenVRMode() override; + virtual void SetUp() const override; // called immediately before rendering a scene frame + virtual void TearDown() const override; // called immediately after rendering a scene frame + virtual void Present() const override; + virtual void AdjustViewports() const override; + +protected: + OpenVRMode(); + // void updateDoomViewDirection() const; + void updateHmdPose(double hmdYawRadians, double hmdPitchRadians, double hmdRollRadians) const; + + OpenVREyePose leftEyeView; + OpenVREyePose rightEyeView; + + vr::IVRSystem* vrSystem; + mutable int cachedScreenBlocks; + +private: + typedef Stereo3DMode super; + bool hmdWasFound; + uint32_t sceneWidth, sceneHeight; +}; + +} /* namespace st3d */ + + +#endif /* GL_OPENVR_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 201e33590..7c87290e4 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -25,10 +25,12 @@ ** */ -#include "gl/stereo3d/gl_stereo3d.h" -#include "gl/stereo3d/gl_stereo_leftright.h" -#include "gl/stereo3d/gl_anaglyph.h" -#include "gl/stereo3d/gl_quadstereo.h" +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl_anaglyph.h" +#include "gl_openvr.h" +#include "gl_quadstereo.h" +#include "gl_sidebyside3d.h" #include "gl/stereo3d/gl_sidebyside3d.h" #include "gl/stereo3d/gl_interleaved3d.h" #include "gl/system/gl_cvars.h" @@ -101,8 +103,12 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() // TODO: 8: Oculus Rift case 9: setCurrentMode(AmberBlue::getInstance(vr_ipd)); - break; - // TODO: 10: HTC Vive/OpenVR + break; +#ifdef USE_OPENVR + case 10: + setCurrentMode(OpenVRMode::getInstance()); + break; +#endif case 11: setCurrentMode(TopBottom3D::getInstance(vr_ipd)); break; diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index ac2b89a27..5aa1ed08d 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -31,7 +31,7 @@ namespace s3d { -ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters +ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in doom units { // save original values cachedView = r_viewpoint.Pos; diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index bac7f2dac..1306adec1 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -40,7 +40,7 @@ namespace s3d { class ScopedViewShifter { public: - ScopedViewShifter(float dxyz[3]); // in meters + ScopedViewShifter(float dxyz[3]); // in doom units ~ScopedViewShifter(); private: diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index f12fab551..aff18cb93 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2786,6 +2786,7 @@ OPTVAL_ROWINTERLEAVED = "Row Interleaved"; OPTVAL_COLUMNINTERLEAVED = "Column Interleaved"; OPTVAL_CHECKERBOARD = "Checkerboard"; OPTVAL_QUADBUFFERED = "Quad-buffered"; +OPTVAL_OPENVR = "OpenVR-Vive"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; OPTVAL_REINHARD = "Reinhard"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index e27c98a29..e9a4ed3e8 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2097,6 +2097,7 @@ OptionValue VRMode 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED" + 10, "$OPTVAL_OPENVR" } OptionMenu "GLTextureGLOptions" From 619281de649df38e382bfb2d376f16d01a065c18 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 28 May 2017 07:12:41 -0400 Subject: [PATCH 25/82] Revert "Merge commit 'refs/pull/336/head' of https://github.com/coelckers/gzdoom" This reverts commit a05c38fefd43c879926c0114f21f7aa4b906a4f1, reversing changes made to 0fb1a0604cf1dc0b04231fb3e23a93241f80c7ef. --- .gitignore | 1 - CMakeLists.txt | 2 - src/CMakeLists.txt | 25 -- src/gl/data/gl_matrix.h | 2 +- src/gl/renderer/gl_renderbuffers.cpp | 8 +- src/gl/renderer/gl_renderbuffers.h | 1 - src/gl/stereo3d/LSMatrix.h | 162 -------- src/gl/stereo3d/gl_openvr.cpp | 477 ------------------------ src/gl/stereo3d/gl_openvr.h | 110 ------ src/gl/stereo3d/gl_stereo_cvars.cpp | 18 +- src/gl/stereo3d/scoped_view_shifter.cpp | 2 +- src/gl/stereo3d/scoped_view_shifter.h | 2 +- wadsrc/static/language.enu | 1 - wadsrc/static/menudef.txt | 1 - 14 files changed, 10 insertions(+), 802 deletions(-) delete mode 100644 src/gl/stereo3d/LSMatrix.h delete mode 100644 src/gl/stereo3d/gl_openvr.cpp delete mode 100644 src/gl/stereo3d/gl_openvr.h diff --git a/.gitignore b/.gitignore index 9f2fd2cb0..a001e38de 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,3 @@ /llvm /src/r_drawersasm.obj /src/r_drawersasm.o -/build_cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f32d0a43c..277fec59c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,8 +300,6 @@ endif() set( LZMA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lzma/C" ) -option( GZDOOM_USE_OPENVR "Support OpenVR API for virtual reality head mounted displays" OFF ) - if( NOT CMAKE_CROSSCOMPILING ) if( NOT CROSS_EXPORTS ) set( CROSS_EXPORTS "" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 17cd911e2..387d6855f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -473,29 +473,6 @@ if( NOT DYN_FLUIDSYNTH ) endif() endif() -if (GZDOOM_USE_OPENVR) - find_path(OPENVR_SDK_PATH - NAMES - headers/openvr.h - PATHS - C:/Users/cmbruns/git/openvr - ) - find_path(OPENVR_INCLUDE_DIRECTORY - NAMES - openvr.h - PATHS - ${OPENVR_SDK_PATH}/headers - ) - include_directories("${OPENVR_INCLUDE_DIRECTORY}") - find_library(OPENVR_LIBRARY - NAMES openvr_api - # TODO: Generalize for Mac and Linux and 64-bit Windows - PATHS "${OPENVR_SDK_PATH}/lib/win32/" - ) - list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) - add_definitions("-DUSE_OPENVR") -endif() - # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES sound/mididevices/music_win_mididevice.cpp @@ -828,7 +805,6 @@ set( FASTMATH_SOURCES gl/scene/gl_vertex.cpp gl/scene/gl_spritelight.cpp gl/dynlights/gl_dynlight1.cpp - gl/dynlights/gl_dynlight1.cpp gl/system/gl_load.c gl/models/gl_models.cpp ) @@ -1030,7 +1006,6 @@ set (PCH_SOURCES gl/stereo3d/gl_stereo_leftright.cpp gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp - gl/stereo3d/gl_openvr.cpp gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_sidebyside3d.cpp gl/stereo3d/gl_interleaved3d.cpp diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h index 12ef2f12b..3ec1f5ff4 100644 --- a/src/gl/data/gl_matrix.h +++ b/src/gl/data/gl_matrix.h @@ -62,7 +62,7 @@ class VSMatrix { void perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp); void ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp=-1.0f, FLOATTYPE farp=1.0f); void frustum(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp, FLOATTYPE farp); - void copy(FLOATTYPE * pDest) const + void copy(FLOATTYPE * pDest) { memcpy(pDest, mMatrix, 16 * sizeof(FLOATTYPE)); } diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index e298b313b..74dc36e72 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -458,8 +458,7 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye) while (mEyeFBs.Size() <= unsigned(eye)) { - // GL_RGBA16F, GL_RGBA16, GL_RGBA32F all do not work with OpenVR and HTC Vive - GLuint texture = Create2DTexture("EyeTexture", GL_RGBA12, mWidth, mHeight); + GLuint texture = Create2DTexture("EyeTexture", GL_RGBA16F, mWidth, mHeight); mEyeTextures.Push(texture); mEyeFBs.Push(CreateFrameBuffer("EyeFB", texture)); } @@ -486,7 +485,6 @@ GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int switch (format) { case GL_RGBA8: dataformat = GL_RGBA; datatype = GL_UNSIGNED_BYTE; break; - case GL_RGBA12: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; case GL_RGBA16: dataformat = GL_RGBA; datatype = GL_UNSIGNED_SHORT; break; case GL_RGBA16F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; case GL_RGBA32F: dataformat = GL_RGBA; datatype = GL_FLOAT; break; @@ -742,10 +740,6 @@ void FGLRenderBuffers::BindEyeFB(int eye, bool readBuffer) glBindFramebuffer(readBuffer ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER, mEyeFBs[eye]); } -GLuint FGLRenderBuffers::GetEyeTextureGLHandle(int eye) const { // Needed for OpenVR API - return mEyeTextures[eye]; -} - //========================================================================== // // Shadow map texture and frame buffers diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h index 1e539d48f..41202b499 100644 --- a/src/gl/renderer/gl_renderbuffers.h +++ b/src/gl/renderer/gl_renderbuffers.h @@ -50,7 +50,6 @@ public: void BlitToEyeTexture(int eye); void BindEyeTexture(int eye, int texunit); void BindEyeFB(int eye, bool readBuffer = false); - GLuint GetEyeTextureGLHandle(int eye) const; // Needed for OpenVR API void BindShadowMapFB(); void BindShadowMapTexture(int index); diff --git a/src/gl/stereo3d/LSMatrix.h b/src/gl/stereo3d/LSMatrix.h deleted file mode 100644 index a0e401838..000000000 --- a/src/gl/stereo3d/LSMatrix.h +++ /dev/null @@ -1,162 +0,0 @@ -/* -** LSMatrix.h -** less-simple matrix class -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** -*/ - - -#ifndef VR_LS_MATRIX_H_ -#define VR_LS_MATRIX_H_ - -#include "gl/data/gl_matrix.h" -#include "openvr.h" - -namespace vr { - HmdMatrix34_t; -} - -class LSVec3 -{ -public: - LSVec3(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w=1.0f) - : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) - { - mVec[0] = x; - mVec[1] = y; - mVec[2] = z; - mVec[3] = w; - } - - LSVec3(const LSVec3& rhs) - : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) - { - *this = rhs; - } - - LSVec3& operator=(const LSVec3& rhs) { - LSVec3& lhs = *this; - for (int i = 0; i < 4; ++i) - lhs[i] = rhs[i]; - return *this; - } - - const FLOATTYPE& operator[](int i) const {return mVec[i];} - FLOATTYPE& operator[](int i) { return mVec[i]; } - - LSVec3 operator-(const LSVec3& rhs) const { - const LSVec3& lhs = *this; - LSVec3 result = *this; - for (int i = 0; i < 4; ++i) - result[i] -= rhs[i]; - return result; - } - - FLOATTYPE mVec[4]; - FLOATTYPE& x; - FLOATTYPE& y; - FLOATTYPE& z; - FLOATTYPE& w; -}; - -LSVec3 operator*(FLOATTYPE s, const LSVec3& rhs) { - LSVec3 result = rhs; - for (int i = 0; i < 4; ++i) - result[i] *= s; - return result; -} - -class LSMatrix44 : public VSMatrix -{ -public: - LSMatrix44() - { - loadIdentity(); - } - - LSMatrix44(const vr::HmdMatrix34_t& m) { - loadIdentity(); - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 4; ++j) { - (*this)[i][j] = m.m[i][j]; - } - } - } - - LSMatrix44(const VSMatrix& m) { - m.copy(mMatrix); - } - - // overload bracket operator to return one row of the matrix, so you can invoke, say, m[2][3] - FLOATTYPE* operator[](int i) {return &mMatrix[i*4];} - const FLOATTYPE* operator[](int i) const { return &mMatrix[i * 4]; } - - LSMatrix44 operator*(const VSMatrix& rhs) const { - LSMatrix44 result(*this); - result.multMatrix(rhs); - return result; - } - - LSVec3 operator*(const LSVec3& rhs) const { - const LSMatrix44& lhs = *this; - LSVec3 result(0, 0, 0, 0); - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - result[i] += lhs[i][j] * rhs[j]; - } - } - return result; - } - - LSMatrix44 getWithoutTranslation() const { - LSMatrix44 m = *this; - // Remove translation component - m[3][3] = 1.0f; - m[3][2] = m[3][1] = m[3][0] = 0.0f; - m[2][3] = m[1][3] = m[0][3] = 0.0f; - return m; - } - - LSMatrix44 transpose() const { - LSMatrix44 result; - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 4; ++j) { - result[i][j] = (*this)[j][i]; - } - } - return result; - } - -}; - -#endif // VR_LS_MATRIX_H_ - - diff --git a/src/gl/stereo3d/gl_openvr.cpp b/src/gl/stereo3d/gl_openvr.cpp deleted file mode 100644 index bd0aecdc9..000000000 --- a/src/gl/stereo3d/gl_openvr.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* -** gl_openvr.cpp -** Stereoscopic virtual reality mode for the HTC Vive headset -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#ifdef USE_OPENVR - -#include "gl_openvr.h" -#include "openvr.h" -#include -#include "gl/system/gl_system.h" -#include "doomtype.h" // Printf -#include "d_player.h" -#include "g_game.h" // G_Add... -#include "p_local.h" // P_TryMove -#include "r_utility.h" // viewpitch -#include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderbuffers.h" -#include "g_levellocals.h" // pixelstretch -#include "math/cmath.h" -#include "c_cvars.h" -#include "LSMatrix.h" - -// For conversion between real-world and doom units -#define VERTICAL_DOOM_UNITS_PER_METER 27.0f - -EXTERN_CVAR(Int, screenblocks); - -using namespace vr; - -// feature toggles, for testing and debugging -static const bool doTrackHmdYaw = true; -static const bool doTrackHmdPitch = true; -static const bool doTrackHmdRoll = true; -static const bool doLateScheduledRotationTracking = true; -static const bool doStereoscopicViewpointOffset = true; -static const bool doRenderToDesktop = true; // mirroring to the desktop is very helpful for debugging -static const bool doRenderToHmd = true; -static const bool doTrackHmdVerticalPosition = false; // todo: -static const bool doTrackHmdHorizontalPostion = false; // todo: -static const bool doTrackVrControllerPosition = false; // todo: - -namespace s3d -{ - -/* static */ -const Stereo3DMode& OpenVRMode::getInstance() -{ - static OpenVRMode instance; - if (! instance.hmdWasFound) - return MonoView::getInstance(); - return instance; -} - -static HmdVector3d_t eulerAnglesFromQuat(HmdQuaternion_t quat) { - double q0 = quat.w; - // permute axes to make "Y" up/yaw - double q2 = quat.x; - double q3 = quat.y; - double q1 = quat.z; - - // http://stackoverflow.com/questions/18433801/converting-a-3x3-matrix-to-euler-tait-bryan-angles-pitch-yaw-roll - double roll = atan2(2 * (q0*q1 + q2*q3), 1 - 2 * (q1*q1 + q2*q2)); - double pitch = asin(2 * (q0*q2 - q3*q1)); - double yaw = atan2(2 * (q0*q3 + q1*q2), 1 - 2 * (q2*q2 + q3*q3)); - - return HmdVector3d_t{ yaw, pitch, roll }; -} - -static HmdQuaternion_t quatFromMatrix(HmdMatrix34_t matrix) { - HmdQuaternion_t q; - typedef float f34[3][4]; - f34& a = matrix.m; - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ - float trace = a[0][0] + a[1][1] + a[2][2]; // I removed + 1.0f; see discussion with Ethan - if (trace > 0) {// I changed M_EPSILON to 0 - float s = 0.5f / sqrtf(trace + 1.0f); - q.w = 0.25f / s; - q.x = (a[2][1] - a[1][2]) * s; - q.y = (a[0][2] - a[2][0]) * s; - q.z = (a[1][0] - a[0][1]) * s; - } - else { - if (a[0][0] > a[1][1] && a[0][0] > a[2][2]) { - float s = 2.0f * sqrtf(1.0f + a[0][0] - a[1][1] - a[2][2]); - q.w = (a[2][1] - a[1][2]) / s; - q.x = 0.25f * s; - q.y = (a[0][1] + a[1][0]) / s; - q.z = (a[0][2] + a[2][0]) / s; - } - else if (a[1][1] > a[2][2]) { - float s = 2.0f * sqrtf(1.0f + a[1][1] - a[0][0] - a[2][2]); - q.w = (a[0][2] - a[2][0]) / s; - q.x = (a[0][1] + a[1][0]) / s; - q.y = 0.25f * s; - q.z = (a[1][2] + a[2][1]) / s; - } - else { - float s = 2.0f * sqrtf(1.0f + a[2][2] - a[0][0] - a[1][1]); - q.w = (a[1][0] - a[0][1]) / s; - q.x = (a[0][2] + a[2][0]) / s; - q.y = (a[1][2] + a[2][1]) / s; - q.z = 0.25f * s; - } - } - - return q; -} - -static HmdVector3d_t eulerAnglesFromMatrix(HmdMatrix34_t mat) { - return eulerAnglesFromQuat(quatFromMatrix(mat)); -} - -OpenVREyePose::OpenVREyePose(int eye) - : ShiftedEyePose( 0.0f ) - , eye(eye) - , eyeTexture(nullptr) - , verticalDoomUnitsPerMeter(VERTICAL_DOOM_UNITS_PER_METER) - , currentPose(nullptr) -{ -} - - -/* virtual */ -OpenVREyePose::~OpenVREyePose() -{ - dispose(); -} - -static void vSMatrixFromHmdMatrix34(VSMatrix& m1, const vr::HmdMatrix34_t& m2) -{ - float tmp[16]; - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 4; ++j) { - tmp[4 * i + j] = m2.m[i][j]; - } - } - int i = 3; - for (int j = 0; j < 4; ++j) { - tmp[4 * i + j] = 0; - } - tmp[15] = 1; - m1.loadMatrix(&tmp[0]); -} - - -/* virtual */ -void OpenVREyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const -{ - outViewShift[0] = outViewShift[1] = outViewShift[2] = 0; - - if (currentPose == nullptr) - return; - const vr::TrackedDevicePose_t& hmd = *currentPose; - if (! hmd.bDeviceIsConnected) - return; - if (! hmd.bPoseIsValid) - return; - - if (! doStereoscopicViewpointOffset) - return; - - const vr::HmdMatrix34_t& hmdPose = hmd.mDeviceToAbsoluteTracking; - - // Pitch and Roll are identical between OpenVR and Doom worlds. - // But yaw can differ, depending on starting state, and controller movement. - float doomYawDegrees = yaw; - float openVrYawDegrees = RAD2DEG(-eulerAnglesFromMatrix(hmdPose).v[0]); - float deltaYawDegrees = doomYawDegrees - openVrYawDegrees; - while (deltaYawDegrees > 180) - deltaYawDegrees -= 360; - while (deltaYawDegrees < -180) - deltaYawDegrees += 360; - - // extract rotation component from hmd transform - LSMatrix44 openvr_X_hmd(hmdPose); - LSMatrix44 hmdRot = openvr_X_hmd.getWithoutTranslation(); // .transpose(); - - /// In these eye methods, just get local inter-eye stereoscopic shift, not full position shift /// - - // compute local eye shift - LSMatrix44 eyeShift2; - eyeShift2.loadIdentity(); - eyeShift2 = eyeShift2 * eyeToHeadTransform; // eye to head - eyeShift2 = eyeShift2 * hmdRot; // head to openvr - - LSVec3 eye_EyePos = LSVec3(0, 0, 0); // eye position in eye frame - LSVec3 hmd_EyePos = LSMatrix44(eyeToHeadTransform) * eye_EyePos; - LSVec3 hmd_HmdPos = LSVec3(0, 0, 0); // hmd position in hmd frame - LSVec3 openvr_EyePos = openvr_X_hmd * hmd_EyePos; - LSVec3 openvr_HmdPos = openvr_X_hmd * hmd_HmdPos; - LSVec3 hmd_OtherEyePos = LSMatrix44(otherEyeToHeadTransform) * eye_EyePos; - LSVec3 openvr_OtherEyePos = openvr_X_hmd * hmd_OtherEyePos; - LSVec3 openvr_EyeOffset = openvr_EyePos - openvr_HmdPos; - - VSMatrix doomInOpenVR = VSMatrix(); - doomInOpenVR.loadIdentity(); - // permute axes - float permute[] = { // Convert from OpenVR to Doom axis convention, including mirror inversion - -1, 0, 0, 0, // X-right in OpenVR -> X-left in Doom - 0, 0, 1, 0, // Z-backward in OpenVR -> Y-backward in Doom - 0, 1, 0, 0, // Y-up in OpenVR -> Z-up in Doom - 0, 0, 0, 1}; - doomInOpenVR.multMatrix(permute); - doomInOpenVR.scale(verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter); // Doom units are not meters - doomInOpenVR.scale(level.info->pixelstretch, level.info->pixelstretch, 1.0); // Doom universe is scaled by 1990s pixel aspect ratio - doomInOpenVR.rotate(deltaYawDegrees, 0, 0, 1); - - LSVec3 doom_EyeOffset = LSMatrix44(doomInOpenVR) * openvr_EyeOffset; - outViewShift[0] = doom_EyeOffset[0]; - outViewShift[1] = doom_EyeOffset[1]; - outViewShift[2] = doom_EyeOffset[2]; -} - -/* virtual */ -VSMatrix OpenVREyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const -{ - // Ignore those arguments and get the projection from the SDK - VSMatrix vs1 = ShiftedEyePose::GetProjection(fov, aspectRatio, fovRatio); - return projectionMatrix; -} - -void OpenVREyePose::initialize(vr::IVRSystem& vrsystem) -{ - float zNear = 5.0; - float zFar = 65536.0; - vr::HmdMatrix44_t projection = vrsystem.GetProjectionMatrix( - vr::EVREye(eye), zNear, zFar); - vr::HmdMatrix44_t proj_transpose; - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - proj_transpose.m[i][j] = projection.m[j][i]; - } - } - projectionMatrix.loadIdentity(); - projectionMatrix.multMatrix(&proj_transpose.m[0][0]); - - vr::HmdMatrix34_t eyeToHead = vrsystem.GetEyeToHeadTransform(vr::EVREye(eye)); - vSMatrixFromHmdMatrix34(eyeToHeadTransform, eyeToHead); - vr::HmdMatrix34_t otherEyeToHead = vrsystem.GetEyeToHeadTransform(eye == Eye_Left ? Eye_Right : Eye_Left); - vSMatrixFromHmdMatrix34(otherEyeToHeadTransform, otherEyeToHead); - - if (eyeTexture == nullptr) - eyeTexture = new vr::Texture_t(); - eyeTexture->handle = nullptr; // TODO: populate this at resolve time - eyeTexture->eType = vr::TextureType_OpenGL; - eyeTexture->eColorSpace = vr::ColorSpace_Linear; -} - -void OpenVREyePose::dispose() -{ - if (eyeTexture) { - delete eyeTexture; - eyeTexture = nullptr; - } -} - -bool OpenVREyePose::submitFrame() const -{ - if (eyeTexture == nullptr) - return false; - if (vr::VRCompositor() == nullptr) - return false; - eyeTexture->handle = (void *)GLRenderer->mBuffers->GetEyeTextureGLHandle((int)eye); - vr::VRCompositor()->Submit(vr::EVREye(eye), eyeTexture); - return true; -} - - -OpenVRMode::OpenVRMode() - : vrSystem(nullptr) - , leftEyeView(vr::Eye_Left) - , rightEyeView(vr::Eye_Right) - , hmdWasFound(false) - , sceneWidth(0), sceneHeight(0) -{ - eye_ptrs.Push(&leftEyeView); // default behavior to Mono non-stereo rendering - - EVRInitError eError; - if (VR_IsHmdPresent()) - { - vrSystem = VR_Init(&eError, VRApplication_Scene); - if (eError != vr::VRInitError_None) { - std::string errMsg = VR_GetVRInitErrorAsEnglishDescription(eError); - vrSystem = nullptr; - return; - // TODO: report error - } - vrSystem->GetRecommendedRenderTargetSize(&sceneWidth, &sceneHeight); - - // OK - leftEyeView.initialize(*vrSystem); - rightEyeView.initialize(*vrSystem); - - if (!vr::VRCompositor()) - return; - - eye_ptrs.Push(&rightEyeView); // NOW we render to two eyes - hmdWasFound = true; - } -} - -/* virtual */ -// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...) -void OpenVRMode::AdjustViewports() const -{ - // Draw the 3D scene into the entire framebuffer - GLRenderer->mSceneViewport.width = sceneWidth; - GLRenderer->mSceneViewport.height = sceneHeight; - GLRenderer->mSceneViewport.left = 0; - GLRenderer->mSceneViewport.top = 0; - - GLRenderer->mScreenViewport.width = sceneWidth; - GLRenderer->mScreenViewport.height = sceneHeight; -} - -/* virtual */ -void OpenVRMode::Present() const { - // TODO: For performance, don't render to the desktop screen here - if (doRenderToDesktop) { - GLRenderer->mBuffers->BindOutputFB(); - GLRenderer->ClearBorders(); - - // Compute screen regions to use for left and right eye views - int leftWidth = GLRenderer->mOutputLetterbox.width / 2; - int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; - GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; - leftHalfScreen.width = leftWidth; - GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; - rightHalfScreen.width = rightWidth; - rightHalfScreen.left += leftWidth; - - GLRenderer->mBuffers->BindEyeTexture(0, 0); - GLRenderer->DrawPresentTexture(leftHalfScreen, true); - GLRenderer->mBuffers->BindEyeTexture(1, 0); - GLRenderer->DrawPresentTexture(rightHalfScreen, true); - } - - if (doRenderToHmd) - { - leftEyeView.submitFrame(); - rightEyeView.submitFrame(); - } -} - -static int mAngleFromRadians(double radians) -{ - double m = std::round(65535.0 * radians / (2.0 * M_PI)); - return int(m); -} - -void OpenVRMode::updateHmdPose( - double hmdYawRadians, - double hmdPitchRadians, - double hmdRollRadians) const -{ - double hmdyaw = hmdYawRadians; - double hmdpitch = hmdPitchRadians; - double hmdroll = hmdRollRadians; - - double dYaw = 0; - if (doTrackHmdYaw) { - // Set HMD angle game state parameters for NEXT frame - static double previousYaw = 0; - static bool havePreviousYaw = false; - if (!havePreviousYaw) { - previousYaw = hmdyaw; - havePreviousYaw = true; - } - dYaw = hmdyaw - previousYaw; - G_AddViewAngle(mAngleFromRadians(-dYaw)); - previousYaw = hmdyaw; - } - - /* */ - // Pitch - if (doTrackHmdPitch) { - double hmdPitchInDoom = -atan(tan(hmdpitch) / level.info->pixelstretch); - double viewPitchInDoom = GLRenderer->mAngles.Pitch.Radians(); - double dPitch = hmdPitchInDoom - viewPitchInDoom; - G_AddViewPitch(mAngleFromRadians(-dPitch)); - } - - // Roll can be local, because it doesn't affect gameplay. - if (doTrackHmdRoll) - GLRenderer->mAngles.Roll = RAD2DEG(-hmdroll); - - // Late-schedule update to renderer angles directly, too - if (doLateScheduledRotationTracking) { - if (doTrackHmdPitch) - GLRenderer->mAngles.Pitch = RAD2DEG(-hmdpitch); - if (doTrackHmdYaw) - GLRenderer->mAngles.Yaw += RAD2DEG(dYaw); // "plus" is the correct direction - } -} - -/* virtual */ -void OpenVRMode::SetUp() const -{ - super::SetUp(); - - cachedScreenBlocks = screenblocks; - screenblocks = 12; // always be full-screen during 3D scene render - - if (vr::VRCompositor() == nullptr) - return; - - static vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]; - vr::VRCompositor()->WaitGetPoses( - poses, vr::k_unMaxTrackedDeviceCount, // current pose - nullptr, 0 // future pose? - ); - - TrackedDevicePose_t& hmdPose0 = poses[vr::k_unTrackedDeviceIndex_Hmd]; - - if (hmdPose0.bPoseIsValid) { - const vr::HmdMatrix34_t& hmdPose = hmdPose0.mDeviceToAbsoluteTracking; - HmdVector3d_t eulerAngles = eulerAnglesFromMatrix(hmdPose); - // Printf("%.1f %.1f %.1f\n", eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); - updateHmdPose(eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); - leftEyeView.setCurrentHmdPose(&hmdPose0); - rightEyeView.setCurrentHmdPose(&hmdPose0); - // TODO: position tracking - } -} - -/* virtual */ -void OpenVRMode::TearDown() const -{ - screenblocks = cachedScreenBlocks; - super::TearDown(); -} - -/* virtual */ -OpenVRMode::~OpenVRMode() -{ - if (vrSystem != nullptr) { - VR_Shutdown(); - vrSystem = nullptr; - leftEyeView.dispose(); - rightEyeView.dispose(); - } -} - -} /* namespace s3d */ - -#endif - diff --git a/src/gl/stereo3d/gl_openvr.h b/src/gl/stereo3d/gl_openvr.h deleted file mode 100644 index 9fc905207..000000000 --- a/src/gl/stereo3d/gl_openvr.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -** gl_openvr.h -** Stereoscopic virtual reality mode for the HTC Vive headset -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** -*/ - -#ifndef GL_OPENVR_H_ -#define GL_OPENVR_H_ - -#include "gl_stereo3d.h" -#include "gl_stereo_leftright.h" - -// forward declaration from openvr.h -namespace vr { - class IVRSystem; - struct HmdMatrix44_t; - struct Texture_t; - struct TrackedDevicePose_t; -} - -/* stereoscopic 3D API */ -namespace s3d { - -class OpenVREyePose : public ShiftedEyePose -{ -public: - OpenVREyePose(int eye); - virtual ~OpenVREyePose() override; - virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const override; - virtual void GetViewShift(float yaw, float outViewShift[3]) const override; - - void initialize(vr::IVRSystem& vrsystem); - void dispose(); - void setCurrentHmdPose(const vr::TrackedDevicePose_t * pose) const {currentPose = pose;} - bool submitFrame() const; - -protected: - VSMatrix projectionMatrix; - VSMatrix eyeToHeadTransform; - VSMatrix otherEyeToHeadTransform; - vr::Texture_t* eyeTexture; - int eye; - - // TODO: adjust doomUnitsPerMeter according to player height - float verticalDoomUnitsPerMeter; - - mutable const vr::TrackedDevicePose_t * currentPose; -}; - -class OpenVRMode : public Stereo3DMode -{ -public: - static const Stereo3DMode& getInstance(); // Might return Mono mode, if no HMD available - - virtual ~OpenVRMode() override; - virtual void SetUp() const override; // called immediately before rendering a scene frame - virtual void TearDown() const override; // called immediately after rendering a scene frame - virtual void Present() const override; - virtual void AdjustViewports() const override; - -protected: - OpenVRMode(); - // void updateDoomViewDirection() const; - void updateHmdPose(double hmdYawRadians, double hmdPitchRadians, double hmdRollRadians) const; - - OpenVREyePose leftEyeView; - OpenVREyePose rightEyeView; - - vr::IVRSystem* vrSystem; - mutable int cachedScreenBlocks; - -private: - typedef Stereo3DMode super; - bool hmdWasFound; - uint32_t sceneWidth, sceneHeight; -}; - -} /* namespace st3d */ - - -#endif /* GL_OPENVR_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 7c87290e4..201e33590 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -25,12 +25,10 @@ ** */ -#include "gl_stereo3d.h" -#include "gl_stereo_leftright.h" -#include "gl_anaglyph.h" -#include "gl_openvr.h" -#include "gl_quadstereo.h" -#include "gl_sidebyside3d.h" +#include "gl/stereo3d/gl_stereo3d.h" +#include "gl/stereo3d/gl_stereo_leftright.h" +#include "gl/stereo3d/gl_anaglyph.h" +#include "gl/stereo3d/gl_quadstereo.h" #include "gl/stereo3d/gl_sidebyside3d.h" #include "gl/stereo3d/gl_interleaved3d.h" #include "gl/system/gl_cvars.h" @@ -103,12 +101,8 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() // TODO: 8: Oculus Rift case 9: setCurrentMode(AmberBlue::getInstance(vr_ipd)); - break; -#ifdef USE_OPENVR - case 10: - setCurrentMode(OpenVRMode::getInstance()); - break; -#endif + break; + // TODO: 10: HTC Vive/OpenVR case 11: setCurrentMode(TopBottom3D::getInstance(vr_ipd)); break; diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index 5aa1ed08d..ac2b89a27 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -31,7 +31,7 @@ namespace s3d { -ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in doom units +ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters { // save original values cachedView = r_viewpoint.Pos; diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index 1306adec1..bac7f2dac 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -40,7 +40,7 @@ namespace s3d { class ScopedViewShifter { public: - ScopedViewShifter(float dxyz[3]); // in doom units + ScopedViewShifter(float dxyz[3]); // in meters ~ScopedViewShifter(); private: diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 4ab1de2ba..41a804ed2 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2787,7 +2787,6 @@ OPTVAL_ROWINTERLEAVED = "Row Interleaved"; OPTVAL_COLUMNINTERLEAVED = "Column Interleaved"; OPTVAL_CHECKERBOARD = "Checkerboard"; OPTVAL_QUADBUFFERED = "Quad-buffered"; -OPTVAL_OPENVR = "OpenVR-Vive"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; OPTVAL_REINHARD = "Reinhard"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 4666a0176..bb7c03b7a 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2097,7 +2097,6 @@ OptionValue VRMode 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED" - 10, "$OPTVAL_OPENVR" } OptionMenu "GLTextureGLOptions" From 9db4dfd9631d9c43967c3f3ab400c2d14139ebde Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 28 May 2017 10:28:07 -0400 Subject: [PATCH 26/82] Link to platform specific openvr library, and install it, and update license headers. --- src/CMakeLists.txt | 27 ++++++++++++++++-- src/gl/stereo3d/LSMatrix.h | 52 ++++++++++++++--------------------- src/gl/stereo3d/gl_openvr.cpp | 49 ++++++++++++++------------------- src/gl/stereo3d/gl_openvr.h | 51 ++++++++++++++-------------------- 4 files changed, 88 insertions(+), 91 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 448280c14..c6bf7f74e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -489,13 +489,31 @@ if (GZDOOM_USE_OPENVR) ${OPENVR_SDK_PATH}/headers ) include_directories("${OPENVR_INCLUDE_DIRECTORY}") + # Link to correct library for this platform + if(WIN32) + set(OPENVR_PLAT "win") + elseif( APPLE ) + set(OPENVR_PLAT "osx") + else() + set(OPENVR_PLAT "linux") + endif() + if(X64) + set(OPENVR_PLAT ${OPENVR_PLAT}64) + else() + set(OPENVR_PLAT ${OPENVR_PLAT}32) + endif() find_library(OPENVR_LIBRARY NAMES openvr_api - # TODO: Generalize for Mac and Linux and 64-bit Windows - HINTS "${OPENVR_SDK_PATH}/lib/win32/" + HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/" ) list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) add_definitions("-DUSE_OPENVR") + # Find shared library file needed for package distribution + find_program(OPENVR_SHARED_LIBRARY + NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll + PATHS "${OPENVR_SDK_PATH}/bin/${OPENVR_PLAT}/" + NO_DEFAULT_PATH + ) endif() # Start defining source files for ZDoom @@ -1321,6 +1339,11 @@ endif() install(TARGETS zdoom DESTINATION ${INSTALL_PATH} COMPONENT "Game executable") +if(OPENVR_SHARED_LIBRARY) + install(PROGRAMS ${OPENVR_SHARED_LIBRARY} + DESTINATION ${INSTALL_PATH} + COMPONENT "Shared libraries") +endif() source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+") source_group("Audio Files\\OPL Synth" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/oplsynth/.+") diff --git a/src/gl/stereo3d/LSMatrix.h b/src/gl/stereo3d/LSMatrix.h index a0e401838..926e4a606 100644 --- a/src/gl/stereo3d/LSMatrix.h +++ b/src/gl/stereo3d/LSMatrix.h @@ -1,39 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016-2017 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** LSMatrix.h ** less-simple matrix class -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ - #ifndef VR_LS_MATRIX_H_ #define VR_LS_MATRIX_H_ diff --git a/src/gl/stereo3d/gl_openvr.cpp b/src/gl/stereo3d/gl_openvr.cpp index 181f0bee7..bd872dfa1 100644 --- a/src/gl/stereo3d/gl_openvr.cpp +++ b/src/gl/stereo3d/gl_openvr.cpp @@ -1,35 +1,28 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016-2017 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_openvr.cpp ** Stereoscopic virtual reality mode for the HTC Vive headset ** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** */ #ifdef USE_OPENVR diff --git a/src/gl/stereo3d/gl_openvr.h b/src/gl/stereo3d/gl_openvr.h index 9fc905207..e3091c630 100644 --- a/src/gl/stereo3d/gl_openvr.h +++ b/src/gl/stereo3d/gl_openvr.h @@ -1,36 +1,27 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016-2017 Christopher Bruns +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// /* ** gl_openvr.h ** Stereoscopic virtual reality mode for the HTC Vive headset -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** */ #ifndef GL_OPENVR_H_ From a9fdaf3827fdff1f3332f5fb5572cc8353f45b40 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 28 May 2017 05:28:00 -0400 Subject: [PATCH 27/82] - Added numerous compatibility fixes for Doom2: Maps 02 to 11. These fixes mark previously unmarked secrets, and texture fixes in several locations that had HOMs. --- wadsrc/static/compatibility.txt | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index 621c4920e..ca643f618 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -484,6 +484,63 @@ F6EE16F770AD309D608EA0B1F1E249FC // Ultimate Doom, e4m3 setsectorspecial 263 0 setsectorspecial 264 0 } +AB24AE6E2CB13CBDD04600A4D37F9189 // doom2.wad map02 +1EC0AF1E3985650F0C9000319C599D0C // doom2bfg.wad map02 +{ + // missing textures + setwalltexture 327 front bot STONE4 + setwalltexture 328 front bot STONE4 + setwalltexture 338 front bot STONE4 + setwalltexture 339 front bot STONE4 +} +5E8679670469F92E15CF4219B5B98FEF // doom2.wad map03 +{ + // unmarked secret + setsectorspecial 62 1024 +} +CEC791136A83EEC4B91D39718BDF9D82 // doom2.wad map04 +{ + // missing textures + setwalltexture 456 back top SUPPORT3 + setwalltexture 108 front top STONE + setwalltexture 109 front top STONE + setwalltexture 110 front top STONE + setwalltexture 111 front top STONE + setwalltexture 127 front top STONE + setwalltexture 128 front top STONE + // remove erronious blue keycard pickup ambush sector tags (nearby viewing windows, and the lights) + setsectortag 19 0 + setsectortag 20 0 + setsectortag 23 0 + setsectortag 28 0 + setsectortag 33 0 + setsectortag 34 0 + setsectortag 83 0 + setsectortag 85 0 +} +9E061AD7FBCD7FAD968C976CB4AA3B9D // doom2.wad map05 +{ + // fix bug with opening westmost door in door hallway - incorrect sector tagging - see doomwiki.org for more info + setsectortag 4 0 + setsectortag 153 0 +} +66C46385EB1A23D60839D1532522076B // doom2.wad map08 +{ + setwalltexture 101 back top BRICK7 +} +6C620F43705BEC0ABBABBF46AC3E62D2 // doom2.wad map10 +{ + // unmarked secrets + setsectorspecial 25 1090 + setsectorspecial 137 1024 + setsectorspecial 176 1024 +} +73D9E03CEE7BF1A97EFD2EAD86688EF8 // doom2.wad map11 +{ + // unmarked secrets + setsectorspecial 94 1024 + setsectorspecial 138 1024 +} 1A540BA717BF9EC85F8522594C352F2A // Doom II, map15 { setsectorspecial 147 0 From 7c33554a2d83ed43500a9d816a8bd7d52ddd5ba7 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 28 May 2017 09:02:53 -0400 Subject: [PATCH 28/82] - fixed a spelling error --- wadsrc/static/compatibility.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index ca643f618..8e856ecbb 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -508,7 +508,7 @@ CEC791136A83EEC4B91D39718BDF9D82 // doom2.wad map04 setwalltexture 111 front top STONE setwalltexture 127 front top STONE setwalltexture 128 front top STONE - // remove erronious blue keycard pickup ambush sector tags (nearby viewing windows, and the lights) + // remove erroneous blue keycard pickup ambush sector tags (nearby viewing windows, and the lights) setsectortag 19 0 setsectortag 20 0 setsectortag 23 0 From 857c183e5fbe16bdb41219b3b5a584c9a12e739b Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Tue, 30 May 2017 13:59:14 -0400 Subject: [PATCH 29/82] Default to statically linking OpenVR API directly from the public API source files. --- src/CMakeLists.txt | 55 +++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6bf7f74e..89d8ae5e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -489,31 +489,39 @@ if (GZDOOM_USE_OPENVR) ${OPENVR_SDK_PATH}/headers ) include_directories("${OPENVR_INCLUDE_DIRECTORY}") - # Link to correct library for this platform - if(WIN32) - set(OPENVR_PLAT "win") - elseif( APPLE ) - set(OPENVR_PLAT "osx") - else() - set(OPENVR_PLAT "linux") + option( GZDOOM_OPENVR_STATIC "Statically link OpenVR API" ON ) + if(GZDOOM_OPENVR_STATIC) + # Incorporate the whole openvr API into zdoom, using a few rules lifted from the OpenVR CMakeLists.txt files + add_definitions( -DVR_API_PUBLIC ) + include_directories(${OPENVR_SDK_PATH}/src ${OPENVR_SDK_PATH}/src/vrcommon) + file(GLOB OPENVR_SOURCES "${OPENVR_SDK_PATH}/src/*.cpp" "${OPENVR_SDK_PATH}/src/vrcommon/*.cpp") + else() # link to shared OpenVR library + # Link to correct library for this platform + if(WIN32) + set(OPENVR_PLAT "win") + elseif( APPLE ) + set(OPENVR_PLAT "osx") + else() + set(OPENVR_PLAT "linux") + endif() + if(X64) + set(OPENVR_PLAT ${OPENVR_PLAT}64) + else() + set(OPENVR_PLAT ${OPENVR_PLAT}32) + endif() + find_library(OPENVR_LIBRARY + NAMES openvr_api + HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/" + ) + list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) + # Find shared library file needed for package distribution + find_program(OPENVR_SHARED_LIBRARY + NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll + PATHS "${OPENVR_SDK_PATH}/bin/${OPENVR_PLAT}/" + NO_DEFAULT_PATH + ) endif() - if(X64) - set(OPENVR_PLAT ${OPENVR_PLAT}64) - else() - set(OPENVR_PLAT ${OPENVR_PLAT}32) - endif() - find_library(OPENVR_LIBRARY - NAMES openvr_api - HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/" - ) - list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) add_definitions("-DUSE_OPENVR") - # Find shared library file needed for package distribution - find_program(OPENVR_SHARED_LIBRARY - NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll - PATHS "${OPENVR_SDK_PATH}/bin/${OPENVR_PLAT}/" - NO_DEFAULT_PATH - ) endif() # Start defining source files for ZDoom @@ -1202,6 +1210,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE ${X86_SOURCES} ${FASTMATH_SOURCES} ${PCH_SOURCES} + ${OPENVR_SOURCES} x86.cpp strnatcmp.c zstring.cpp From b8074a4e53f26467eadda8591e4ef0f2edca2dcc Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 31 May 2017 09:15:13 -0400 Subject: [PATCH 30/82] - Sync VER_MAJOR and VER_MINOR in version.h with GZDoom parent. --- src/version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/version.h b/src/version.h index 19347fafe..27d5894ac 100644 --- a/src/version.h +++ b/src/version.h @@ -55,9 +55,9 @@ const char *GetVersionString(); #define RC_FILEVERSION 1,3,9999,0 #define RC_PRODUCTVERSION 1,3,9999,0 #define RC_PRODUCTVERSION2 VERSIONSTR -// These are for content versioning. The current state is '2.4'. -#define VER_MAJOR 2 -#define VER_MINOR 5 +// These are for content versioning. The current state is '3.2'. +#define VER_MAJOR 3 +#define VER_MINOR 2 #define VER_REVISION 0 // Version identifier for network games. From d2f4dd41f89e5d2fbcf1079171e778b73d41b279 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Wed, 31 May 2017 19:44:14 -0400 Subject: [PATCH 31/82] Add a comment --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cad0a4950..2f3805a3c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -480,6 +480,7 @@ if (GZDOOM_USE_OPENVR) option( GZDOOM_OPENVR_STATIC "Statically link OpenVR API" ON ) if(GZDOOM_OPENVR_STATIC) # Incorporate the whole openvr API into zdoom, using a few rules lifted from the OpenVR CMakeLists.txt files + # This branch avoids the need to ship openvr_api.dll add_definitions( -DVR_API_PUBLIC ) include_directories(${OPENVR_SDK_PATH}/src ${OPENVR_SDK_PATH}/src/vrcommon) file(GLOB OPENVR_SOURCES "${OPENVR_SDK_PATH}/src/*.cpp" "${OPENVR_SDK_PATH}/src/vrcommon/*.cpp") From 813b321c45b5d52680bbe91e5e7fa796745da240 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 10:41:52 -0400 Subject: [PATCH 32/82] - Added 'canonical transparency' cvar r_canontrans - this simply turns off transparency for Doom objects that were marked as transparent sometime in ZDoom's development cycle --- src/actor.h | 1 + src/gl/scene/gl_sprite.cpp | 8 ++++++++ src/polyrenderer/scene/poly_sprite.cpp | 6 +++++- src/r_data/renderstyle.cpp | 1 + src/scripting/thingdef_data.cpp | 1 + src/swrenderer/things/r_sprite.cpp | 3 +++ wadsrc/static/zscript/doom/arachnotron.txt | 1 + wadsrc/static/zscript/doom/archvile.txt | 2 +- wadsrc/static/zscript/doom/bossbrain.txt | 1 + wadsrc/static/zscript/doom/bruiser.txt | 1 + wadsrc/static/zscript/doom/cacodemon.txt | 1 + wadsrc/static/zscript/doom/doomartifacts.txt | 1 + wadsrc/static/zscript/doom/doomimp.txt | 1 + wadsrc/static/zscript/doom/doommisc.txt | 1 + wadsrc/static/zscript/doom/fatso.txt | 1 + wadsrc/static/zscript/doom/lostsoul.txt | 2 +- wadsrc/static/zscript/doom/revenant.txt | 2 ++ wadsrc/static/zscript/doom/weaponbfg.txt | 1 + wadsrc/static/zscript/doom/weaponplasma.txt | 1 + 19 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/actor.h b/src/actor.h index be3f28ec6..5474a8213 100644 --- a/src/actor.h +++ b/src/actor.h @@ -402,6 +402,7 @@ enum ActorFlag8 { MF8_FRIGHTENING = 0x00000001, // for those moments when halloween just won't do MF8_INSCROLLSEC = 0x00000002, // actor is partially inside a scrolling sector + MF8_ZDOOMTRANS = 0x00000004, // is not normally transparent in Vanilla Doom }; // --- mobj.renderflags --- diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c491bb33e..fa5b40dec 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -75,6 +75,7 @@ CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) } EXTERN_CVAR (Float, transsouls) +EXTERN_CVAR (Bool, r_canontrans) extern TArray sprites; extern TArray SpriteFrames; @@ -992,6 +993,13 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { trans = 1.f; } + if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + { // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects + trans = 1.f; + RenderStyle.BlendOp = STYLEOP_Add; + RenderStyle.SrcAlpha = STYLEALPHA_One; + RenderStyle.DestAlpha = STYLEALPHA_Zero; + } if (trans >= 1.f - FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 2ddf46df3..fb2c4ea28 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -31,6 +31,7 @@ EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) +EXTERN_CVAR (Bool, r_canontrans) bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) { @@ -145,7 +146,10 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); + if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); + else + args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); args.SetSubsectorDepthTest(true); args.SetWriteSubsectorDepth(false); args.SetWriteStencil(false); diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index 987de82b9..11943f46d 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -38,6 +38,7 @@ #include "serializer.h" CVAR (Bool, r_drawtrans, true, 0) +CVAR (Bool, r_canontrans, false, CVAR_ARCHIVE) CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) // Convert legacy render styles to flexible render styles. diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index f62ba0c88..d978136b8 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -325,6 +325,7 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF7, SPRITEFLIP, AActor, flags7), DEFINE_FLAG(MF8, FRIGHTENING, AActor, flags8), + DEFINE_FLAG(MF8, ZDOOMTRANS, AActor, flags8), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 889430004..c7c2898ba 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -68,6 +68,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, gl_light_sprites) +EXTERN_CVAR (Bool, r_canontrans) namespace swrenderer { @@ -212,6 +213,8 @@ namespace swrenderer if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->RenderStyle = thing->RenderStyle; + if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table vis->FakeFlatStat = fakeside; diff --git a/wadsrc/static/zscript/doom/arachnotron.txt b/wadsrc/static/zscript/doom/arachnotron.txt index c7e11ab14..36bb2b38e 100644 --- a/wadsrc/static/zscript/doom/arachnotron.txt +++ b/wadsrc/static/zscript/doom/arachnotron.txt @@ -72,6 +72,7 @@ class ArachnotronPlasma : Actor Damage 5; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "baby/attack"; diff --git a/wadsrc/static/zscript/doom/archvile.txt b/wadsrc/static/zscript/doom/archvile.txt index 2ea153be1..8e0a98dcb 100644 --- a/wadsrc/static/zscript/doom/archvile.txt +++ b/wadsrc/static/zscript/doom/archvile.txt @@ -70,7 +70,7 @@ class ArchvileFire : Actor { Default { - +NOBLOCKMAP +NOGRAVITY + +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; Alpha 1; } diff --git a/wadsrc/static/zscript/doom/bossbrain.txt b/wadsrc/static/zscript/doom/bossbrain.txt index 07f0cc946..5b87182c9 100644 --- a/wadsrc/static/zscript/doom/bossbrain.txt +++ b/wadsrc/static/zscript/doom/bossbrain.txt @@ -120,6 +120,7 @@ class SpawnFire : Actor Height 78; +NOBLOCKMAP +NOGRAVITY + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/doom/bruiser.txt b/wadsrc/static/zscript/doom/bruiser.txt index c1faa23c1..81f12db54 100644 --- a/wadsrc/static/zscript/doom/bruiser.txt +++ b/wadsrc/static/zscript/doom/bruiser.txt @@ -121,6 +121,7 @@ class BaronBall : Actor Damage 8; Projectile ; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "baron/attack"; diff --git a/wadsrc/static/zscript/doom/cacodemon.txt b/wadsrc/static/zscript/doom/cacodemon.txt index b21acacd2..8cd3a5089 100644 --- a/wadsrc/static/zscript/doom/cacodemon.txt +++ b/wadsrc/static/zscript/doom/cacodemon.txt @@ -71,6 +71,7 @@ class CacodemonBall : Actor Damage 5; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "caco/attack"; diff --git a/wadsrc/static/zscript/doom/doomartifacts.txt b/wadsrc/static/zscript/doom/doomartifacts.txt index a6996cb88..bb04da93c 100644 --- a/wadsrc/static/zscript/doom/doomartifacts.txt +++ b/wadsrc/static/zscript/doom/doomartifacts.txt @@ -97,6 +97,7 @@ class BlurSphere : PowerupGiver { +COUNTITEM +VISIBILITYPULSE + +ZDOOMTRANS +INVENTORY.AUTOACTIVATE +INVENTORY.ALWAYSPICKUP +INVENTORY.BIGPOWERUP diff --git a/wadsrc/static/zscript/doom/doomimp.txt b/wadsrc/static/zscript/doom/doomimp.txt index d2b93acdd..c3a187b38 100644 --- a/wadsrc/static/zscript/doom/doomimp.txt +++ b/wadsrc/static/zscript/doom/doomimp.txt @@ -77,6 +77,7 @@ class DoomImpBall : Actor Damage 3; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "imp/attack"; diff --git a/wadsrc/static/zscript/doom/doommisc.txt b/wadsrc/static/zscript/doom/doommisc.txt index 7d4c9dec4..c6d8af717 100644 --- a/wadsrc/static/zscript/doom/doommisc.txt +++ b/wadsrc/static/zscript/doom/doommisc.txt @@ -61,6 +61,7 @@ class BulletPuff : Actor +NOGRAVITY +ALLOWPARTICLES +RANDOMIZE + +ZDOOMTRANS RenderStyle "Translucent"; Alpha 0.5; VSpeed 1; diff --git a/wadsrc/static/zscript/doom/fatso.txt b/wadsrc/static/zscript/doom/fatso.txt index e70c97924..2e6321650 100644 --- a/wadsrc/static/zscript/doom/fatso.txt +++ b/wadsrc/static/zscript/doom/fatso.txt @@ -74,6 +74,7 @@ class FatShot : Actor Damage 8; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "fatso/attack"; diff --git a/wadsrc/static/zscript/doom/lostsoul.txt b/wadsrc/static/zscript/doom/lostsoul.txt index 7d918aa10..ce7f07f51 100644 --- a/wadsrc/static/zscript/doom/lostsoul.txt +++ b/wadsrc/static/zscript/doom/lostsoul.txt @@ -15,7 +15,7 @@ class LostSoul : Actor Damage 3; PainChance 256; Monster; - +FLOAT +NOGRAVITY +MISSILEMORE +DONTFALL +NOICEDEATH; + +FLOAT +NOGRAVITY +MISSILEMORE +DONTFALL +NOICEDEATH +ZDOOMTRANS; AttackSound "skull/melee"; PainSound "skull/pain"; DeathSound "skull/death"; diff --git a/wadsrc/static/zscript/doom/revenant.txt b/wadsrc/static/zscript/doom/revenant.txt index 82d563934..c3a7c218d 100644 --- a/wadsrc/static/zscript/doom/revenant.txt +++ b/wadsrc/static/zscript/doom/revenant.txt @@ -80,6 +80,7 @@ class RevenantTracer : Actor Projectile; +SEEKERMISSILE +RANDOMIZE + +ZDOOMTRANS SeeSound "skeleton/attack"; DeathSound "skeleton/tracex"; RenderStyle "Add"; @@ -110,6 +111,7 @@ class RevenantTracerSmoke : Actor +NOBLOCKMAP +NOGRAVITY +NOTELEPORT + +ZDOOMTRANS RenderStyle "Translucent"; Alpha 0.5; } diff --git a/wadsrc/static/zscript/doom/weaponbfg.txt b/wadsrc/static/zscript/doom/weaponbfg.txt index 9bf0084b3..9da326313 100644 --- a/wadsrc/static/zscript/doom/weaponbfg.txt +++ b/wadsrc/static/zscript/doom/weaponbfg.txt @@ -142,6 +142,7 @@ class BFGBall : Actor Damage 100; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; DeathSound "weapons/bfgx"; diff --git a/wadsrc/static/zscript/doom/weaponplasma.txt b/wadsrc/static/zscript/doom/weaponplasma.txt index 945339a35..b66092b82 100644 --- a/wadsrc/static/zscript/doom/weaponplasma.txt +++ b/wadsrc/static/zscript/doom/weaponplasma.txt @@ -51,6 +51,7 @@ class PlasmaBall : Actor Damage 5; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "weapons/plasmaf"; From 45d7401885cd0f46d7309ee46c9a66ad4c343005 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 12:05:43 -0400 Subject: [PATCH 33/82] - fixed: forgot to assign +ZDOOMTRANS to rockets --- wadsrc/static/zscript/doom/weaponrlaunch.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/doom/weaponrlaunch.txt b/wadsrc/static/zscript/doom/weaponrlaunch.txt index 906db3823..042b96823 100644 --- a/wadsrc/static/zscript/doom/weaponrlaunch.txt +++ b/wadsrc/static/zscript/doom/weaponrlaunch.txt @@ -55,6 +55,7 @@ class Rocket : Actor +RANDOMIZE +DEHEXPLOSION +ROCKETTRAIL + +ZDOOMTRANS SeeSound "weapons/rocklf"; DeathSound "weapons/rocklx"; Obituary "$OB_MPROCKET"; From aa93990d3b221ce6798259c2c8a144ffc6a89a57 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 13:13:30 -0400 Subject: [PATCH 34/82] - Changed MF7_SPRITEFLIP, MF8_ZDOOMTRANS to RenderFlags - Added RF_ZDOOMADD - renamed r_canontrans to r_vanillatrans - this developer's insanity level has increased by 231%. --- src/actor.h | 6 +++-- src/gl/scene/gl_sprite.cpp | 33 ++++++++++++++++--------- src/polyrenderer/scene/poly_sprite.cpp | 6 +++-- src/r_data/renderstyle.cpp | 2 +- src/scripting/thingdef_data.cpp | 5 ++-- src/swrenderer/scene/r_opaque_pass.cpp | 2 +- src/swrenderer/things/r_sprite.cpp | 13 +++++++--- wadsrc/static/zscript/heretic/beast.txt | 2 ++ 8 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/actor.h b/src/actor.h index 5474a8213..7dccdc397 100644 --- a/src/actor.h +++ b/src/actor.h @@ -396,13 +396,11 @@ enum ActorFlag7 MF7_FORCEZERORADIUSDMG = 0x10000000, // passes zero radius damage on to P_DamageMobj, this is necessary in some cases where DoSpecialDamage gets overrideen. MF7_NOINFIGHTSPECIES = 0x20000000, // don't start infights with one's own species. MF7_FORCEINFIGHTING = 0x40000000, // overrides a map setting of 'no infighting'. - MF7_SPRITEFLIP = 0x80000000, // sprite flipped on x-axis }; enum ActorFlag8 { MF8_FRIGHTENING = 0x00000001, // for those moments when halloween just won't do MF8_INSCROLLSEC = 0x00000002, // actor is partially inside a scrolling sector - MF8_ZDOOMTRANS = 0x00000004, // is not normally transparent in Vanilla Doom }; // --- mobj.renderflags --- @@ -444,6 +442,10 @@ enum ActorRenderFlag RF_INTERPOLATEANGLES = 0x01000000, // [MC] Allow interpolation of the actor's angle, pitch and roll. RF_MAYBEINVISIBLE = 0x02000000, RF_DONTINTERPOLATE = 0x04000000, // no render interpolation ever! + + RF_SPRITEFLIP = 0x08000000, // sprite flipped on x-axis + RF_ZDOOMTRANS = 0x10000000, // is not normally transparent in Vanilla Doom + RF_ZDOOMADD = 0x20000000, // is not normally additive in Vanilla Hexen/Heretic/Strife }; // This translucency value produces the closest match to Heretic's TINTTAB. diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index fa5b40dec..f6fecf0b1 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -75,7 +75,7 @@ CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) } EXTERN_CVAR (Float, transsouls) -EXTERN_CVAR (Bool, r_canontrans) +EXTERN_CVAR (Bool, r_vanillatrans) extern TArray sprites; extern TArray SpriteFrames; @@ -801,7 +801,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) sprangle = 0.; rot = 0; } - patch = sprites[spritenum].GetSpriteFrame(thing->frame, rot, sprangle, &mirror, !!(thing->flags7 & MF7_SPRITEFLIP)); + patch = sprites[spritenum].GetSpriteFrame(thing->frame, rot, sprangle, &mirror, !!(thing->renderflags & RF_SPRITEFLIP)); } if (!patch.isValid()) return; @@ -817,7 +817,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) gltexture->GetSpriteRect(&r); // [SP] SpriteFlip - if (thing->flags7 & MF7_SPRITEFLIP) + if (thing->renderflags & RF_SPRITEFLIP) thing->renderflags ^= RF_XFLIP; if (mirror ^ !!(thing->renderflags & RF_XFLIP)) @@ -832,7 +832,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) ur = gltexture->GetSpriteUL(); } - if (thing->flags7 & MF7_SPRITEFLIP) // [SP] Flip back + if (thing->renderflags & RF_SPRITEFLIP) // [SP] Flip back thing->renderflags ^= RF_XFLIP; r.Scale(sprscale.X, sprscale.Y); @@ -993,14 +993,25 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { trans = 1.f; } - if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) - { // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects - trans = 1.f; - RenderStyle.BlendOp = STYLEOP_Add; - RenderStyle.SrcAlpha = STYLEALPHA_One; - RenderStyle.DestAlpha = STYLEALPHA_Zero; - } + if (r_vanillatrans) + { + // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects, + // and disable 'additive' translucency for certain objects from other games. + if (thing->renderflags & RF_ZDOOMTRANS) + { + trans = 1.f; + RenderStyle.BlendOp = STYLEOP_Add; + RenderStyle.SrcAlpha = STYLEALPHA_One; + RenderStyle.DestAlpha = STYLEALPHA_Zero; + } + if (thing->renderflags & RF_ZDOOMADD) + { + RenderStyle.BlendOp = STYLEOP_Add; + RenderStyle.SrcAlpha = STYLEALPHA_Src; + RenderStyle.DestAlpha = STYLEALPHA_InvSrc; + } + } if (trans >= 1.f - FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || (RenderStyle.SrcAlpha == STYLEALPHA_Src && RenderStyle.DestAlpha == STYLEALPHA_InvSrc) diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index fb2c4ea28..398f37e7b 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -31,7 +31,7 @@ EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) -EXTERN_CVAR (Bool, r_canontrans) +EXTERN_CVAR (Bool, r_vanillatrans) bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) { @@ -146,8 +146,10 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + if ((thing->renderflags & RF_ZDOOMTRANS) && r_vanillatrans) args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); + else if ((thing->renderflags & RF_ZDOOMADD) && r_vanillatrans) + args.SetStyle(LegacyRenderStyles[STYLE_Translucent], thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); args.SetSubsectorDepthTest(true); diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index 11943f46d..fc1905f91 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -38,7 +38,7 @@ #include "serializer.h" CVAR (Bool, r_drawtrans, true, 0) -CVAR (Bool, r_canontrans, false, CVAR_ARCHIVE) +CVAR (Bool, r_vanillatrans, false, CVAR_ARCHIVE) CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) // Convert legacy render styles to flexible render styles. diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index d978136b8..e53a7d48a 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -322,10 +322,8 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF7, FORCEZERORADIUSDMG, AActor, flags7), DEFINE_FLAG(MF7, NOINFIGHTSPECIES, AActor, flags7), DEFINE_FLAG(MF7, FORCEINFIGHTING, AActor, flags7), - DEFINE_FLAG(MF7, SPRITEFLIP, AActor, flags7), DEFINE_FLAG(MF8, FRIGHTENING, AActor, flags8), - DEFINE_FLAG(MF8, ZDOOMTRANS, AActor, flags8), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), @@ -347,6 +345,9 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(RF, YFLIP, AActor, renderflags), DEFINE_FLAG(RF, INTERPOLATEANGLES, AActor, renderflags), DEFINE_FLAG(RF, DONTINTERPOLATE, AActor, renderflags), + DEFINE_FLAG(RF, SPRITEFLIP, AActor, renderflags), + DEFINE_FLAG(RF, ZDOOMTRANS, AActor, renderflags), + DEFINE_FLAG(RF, ZDOOMADD, AActor, renderflags), // Bounce flags DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 1838122d0..bb8081a27 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -1007,7 +1007,7 @@ namespace swrenderer DAngle sprangle = thing->GetSpriteAngle((sprite.pos - viewpoint.Pos).Angle(), viewpoint.TicFrac); bool flipX; - FTextureID tex = sprdef->GetSpriteFrame(thing->frame, -1, sprangle, &flipX, !!(thing->flags7 & MF7_SPRITEFLIP)); + FTextureID tex = sprdef->GetSpriteFrame(thing->frame, -1, sprangle, &flipX, !!(thing->renderflags & RF_SPRITEFLIP)); if (tex.isValid()) { if (flipX) diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index c7c2898ba..7dcab13ec 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -68,7 +68,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, gl_light_sprites) -EXTERN_CVAR (Bool, r_canontrans) +EXTERN_CVAR (Bool, r_vanillatrans) namespace swrenderer { @@ -147,7 +147,7 @@ namespace swrenderer renderflags ^= renderportal->MirrorFlags & RF_XFLIP; // [SP] SpriteFlip - if (thing->flags7 & MF7_SPRITEFLIP) + if (thing->renderflags & RF_SPRITEFLIP) renderflags ^= RF_XFLIP; // calculate edges of the shape @@ -213,8 +213,13 @@ namespace swrenderer if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->RenderStyle = thing->RenderStyle; - if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) - vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; + if (r_vanillatrans) + { + if (thing->renderflags & RF_ZDOOMTRANS) + vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; + if (thing->renderflags & RF_ZDOOMADD) + vis->RenderStyle = LegacyRenderStyles[STYLE_Translucent]; + } vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table vis->FakeFlatStat = fakeside; diff --git a/wadsrc/static/zscript/heretic/beast.txt b/wadsrc/static/zscript/heretic/beast.txt index 209b2da56..9e004f5c1 100644 --- a/wadsrc/static/zscript/heretic/beast.txt +++ b/wadsrc/static/zscript/heretic/beast.txt @@ -75,6 +75,7 @@ class BeastBall : Actor -NOBLOCKMAP +WINDTHRUST +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "beast/attack"; } @@ -104,6 +105,7 @@ class Puffy : Actor +MISSILE +NOTELEPORT +DONTSPLASH + +ZDOOMADD RenderStyle "Add"; } States From b4dea12a4f611052d2f5305f22be4082635b09de Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 13:41:05 -0400 Subject: [PATCH 35/82] - Added +ZDOOMADD to all Heretic, Hexen, and Strife actors that needed it (that I know of...) - this developer's insanity level increased another 21% --- wadsrc/static/zscript/heretic/dsparil.txt | 4 ++++ wadsrc/static/zscript/heretic/hereticimp.txt | 1 + wadsrc/static/zscript/heretic/hereticmisc.txt | 2 +- wadsrc/static/zscript/heretic/ironlich.txt | 3 +++ wadsrc/static/zscript/heretic/mummy.txt | 1 + wadsrc/static/zscript/heretic/snake.txt | 1 + wadsrc/static/zscript/heretic/weaponblaster.txt | 1 + wadsrc/static/zscript/heretic/weaponcrossbow.txt | 1 + wadsrc/static/zscript/heretic/weaponphoenix.txt | 1 + wadsrc/static/zscript/heretic/weaponskullrod.txt | 3 +++ wadsrc/static/zscript/heretic/weaponstaff.txt | 1 + wadsrc/static/zscript/heretic/weaponwand.txt | 1 + wadsrc/static/zscript/heretic/wizard.txt | 1 + wadsrc/static/zscript/hexen/bishop.txt | 2 +- wadsrc/static/zscript/hexen/centaur.txt | 1 + wadsrc/static/zscript/hexen/clericflame.txt | 8 +++++--- wadsrc/static/zscript/hexen/demons.txt | 2 ++ wadsrc/static/zscript/hexen/dragon.txt | 2 ++ wadsrc/static/zscript/hexen/fighteraxe.txt | 1 + wadsrc/static/zscript/hexen/fighterquietus.txt | 1 + wadsrc/static/zscript/hexen/firedemon.txt | 1 + wadsrc/static/zscript/hexen/flame.txt | 4 ++++ wadsrc/static/zscript/hexen/heresiarch.txt | 1 + wadsrc/static/zscript/hexen/magelightning.txt | 3 +++ wadsrc/static/zscript/hexen/scriptprojectiles.txt | 1 + wadsrc/static/zscript/hexen/serpent.txt | 1 + wadsrc/static/zscript/raven/minotaur.txt | 1 + wadsrc/static/zscript/strife/sentinel.txt | 1 + wadsrc/static/zscript/strife/spectral.txt | 2 ++ wadsrc/static/zscript/strife/strifestuff.txt | 1 + wadsrc/static/zscript/strife/strifeweapons.txt | 1 + wadsrc/static/zscript/strife/thingstoblowup.txt | 1 + wadsrc/static/zscript/strife/weaponflamer.txt | 1 + wadsrc/static/zscript/strife/weapongrenade.txt | 1 + wadsrc/static/zscript/strife/weaponmauler.txt | 3 +++ 35 files changed, 56 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/zscript/heretic/dsparil.txt b/wadsrc/static/zscript/heretic/dsparil.txt index 579f47492..bc2054f70 100644 --- a/wadsrc/static/zscript/heretic/dsparil.txt +++ b/wadsrc/static/zscript/heretic/dsparil.txt @@ -192,6 +192,7 @@ class SorcererFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } @@ -410,6 +411,7 @@ class Sorcerer2FX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } @@ -457,6 +459,7 @@ class Sorcerer2FXSpark : Actor +NOGRAVITY +NOTELEPORT +CANNOTPUSH + +ZDOOMADD RenderStyle "Add"; } @@ -481,6 +484,7 @@ class Sorcerer2FX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/heretic/hereticimp.txt b/wadsrc/static/zscript/heretic/hereticimp.txt index e6915c7f6..be3e2e7df 100644 --- a/wadsrc/static/zscript/heretic/hereticimp.txt +++ b/wadsrc/static/zscript/heretic/hereticimp.txt @@ -228,6 +228,7 @@ class HereticImpBall : Actor +SPAWNSOUNDSOURCE -ACTIVATEPCROSS -ACTIVATEIMPACT + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/heretic/hereticmisc.txt b/wadsrc/static/zscript/heretic/hereticmisc.txt index b66217352..895c04ed2 100644 --- a/wadsrc/static/zscript/heretic/hereticmisc.txt +++ b/wadsrc/static/zscript/heretic/hereticmisc.txt @@ -205,7 +205,7 @@ class TeleGlitter1 : Actor { Default { - +NOBLOCKMAP +NOGRAVITY +MISSILE + +NOBLOCKMAP +NOGRAVITY +MISSILE +ZDOOMADD RenderStyle "Add"; Damage 0; } diff --git a/wadsrc/static/zscript/heretic/ironlich.txt b/wadsrc/static/zscript/heretic/ironlich.txt index 65e510932..52fddc6f7 100644 --- a/wadsrc/static/zscript/heretic/ironlich.txt +++ b/wadsrc/static/zscript/heretic/ironlich.txt @@ -144,6 +144,7 @@ class HeadFX1 : Actor -ACTIVATEIMPACT -ACTIVATEPCROSS +THRUGHOST + +ZDOOMADD RenderStyle "Add"; } @@ -195,6 +196,7 @@ class HeadFX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } @@ -223,6 +225,7 @@ class HeadFX3 : Actor Damage 5; Projectile; +WINDTHRUST + +ZDOOMADD -ACTIVATEIMPACT -ACTIVATEPCROSS -NOBLOCKMAP diff --git a/wadsrc/static/zscript/heretic/mummy.txt b/wadsrc/static/zscript/heretic/mummy.txt index 6d01fcea4..453c6e83c 100644 --- a/wadsrc/static/zscript/heretic/mummy.txt +++ b/wadsrc/static/zscript/heretic/mummy.txt @@ -135,6 +135,7 @@ class MummyFX1 : Actor -ACTIVATEPCROSS -ACTIVATEIMPACT +SEEKERMISSILE + +ZDOOMADD } States { diff --git a/wadsrc/static/zscript/heretic/snake.txt b/wadsrc/static/zscript/heretic/snake.txt index 15ae342aa..bc0d8344a 100644 --- a/wadsrc/static/zscript/heretic/snake.txt +++ b/wadsrc/static/zscript/heretic/snake.txt @@ -64,6 +64,7 @@ class SnakeProjA : Actor -ACTIVATEPCROSS +WINDTHRUST +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "snake/attack"; } diff --git a/wadsrc/static/zscript/heretic/weaponblaster.txt b/wadsrc/static/zscript/heretic/weaponblaster.txt index e7e1e92b5..38c30ee14 100644 --- a/wadsrc/static/zscript/heretic/weaponblaster.txt +++ b/wadsrc/static/zscript/heretic/weaponblaster.txt @@ -244,6 +244,7 @@ class BlasterPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMADD RenderStyle "Add"; SeeSound "weapons/blasterhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponcrossbow.txt b/wadsrc/static/zscript/heretic/weaponcrossbow.txt index bd5e9517a..69fd108be 100644 --- a/wadsrc/static/zscript/heretic/weaponcrossbow.txt +++ b/wadsrc/static/zscript/heretic/weaponcrossbow.txt @@ -129,6 +129,7 @@ class CrossbowFX1 : Actor SeeSound "weapons/bowshoot"; DeathSound "weapons/bowhit"; Obituary "$OB_MPCROSSBOW"; + +ZDOOMADD } States diff --git a/wadsrc/static/zscript/heretic/weaponphoenix.txt b/wadsrc/static/zscript/heretic/weaponphoenix.txt index 558a257cd..a44bb4c13 100644 --- a/wadsrc/static/zscript/heretic/weaponphoenix.txt +++ b/wadsrc/static/zscript/heretic/weaponphoenix.txt @@ -292,6 +292,7 @@ class PhoenixFX2 : Actor DamageType "Fire"; Projectile; RenderStyle "Add"; + +ZDOOMADD Obituary "$OB_MPPPHOENIXROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponskullrod.txt b/wadsrc/static/zscript/heretic/weaponskullrod.txt index da959f7ae..0e651807e 100644 --- a/wadsrc/static/zscript/heretic/weaponskullrod.txt +++ b/wadsrc/static/zscript/heretic/weaponskullrod.txt @@ -143,6 +143,7 @@ class HornRodFX1 : Actor Damage 3; Projectile; +WINDTHRUST + +ZDOOMADD -NOBLOCKMAP RenderStyle "Add"; SeeSound "weapons/hornrodshoot"; @@ -177,6 +178,7 @@ class HornRodFX2 : Actor Health 140; Projectile; RenderStyle "Add"; + +ZDOOMADD SeeSound "weapons/hornrodpowshoot"; DeathSound "weapons/hornrodpowhit"; Obituary "$OB_MPPSKULLROD"; @@ -364,6 +366,7 @@ class RainPillar : Actor Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPPSKULLROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponstaff.txt b/wadsrc/static/zscript/heretic/weaponstaff.txt index 85126f503..1e1237780 100644 --- a/wadsrc/static/zscript/heretic/weaponstaff.txt +++ b/wadsrc/static/zscript/heretic/weaponstaff.txt @@ -132,6 +132,7 @@ class StaffPuff2 : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMADD AttackSound "weapons/staffpowerhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponwand.txt b/wadsrc/static/zscript/heretic/weaponwand.txt index 9516aa76c..38cd9e2de 100644 --- a/wadsrc/static/zscript/heretic/weaponwand.txt +++ b/wadsrc/static/zscript/heretic/weaponwand.txt @@ -142,6 +142,7 @@ class GoldWandFX1 : Actor Damage 2; Projectile; RenderStyle "Add"; + +ZDOOMADD DeathSound "weapons/wandhit"; Obituary "$OB_MPPGOLDWAND"; } diff --git a/wadsrc/static/zscript/heretic/wizard.txt b/wadsrc/static/zscript/heretic/wizard.txt index d146ae220..a3772573c 100644 --- a/wadsrc/static/zscript/heretic/wizard.txt +++ b/wadsrc/static/zscript/heretic/wizard.txt @@ -145,6 +145,7 @@ class WizardFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/bishop.txt b/wadsrc/static/zscript/hexen/bishop.txt index 32f0f3e63..8f4b2bd22 100644 --- a/wadsrc/static/zscript/hexen/bishop.txt +++ b/wadsrc/static/zscript/hexen/bishop.txt @@ -290,7 +290,7 @@ class BishopFX : Actor Projectile; +SEEKERMISSILE -ACTIVATEIMPACT -ACTIVATEPCROSS - +STRIFEDAMAGE + +STRIFEDAMAGE +ZDOOMADD RenderStyle "Add"; DeathSound "BishopMissileExplode"; } diff --git a/wadsrc/static/zscript/hexen/centaur.txt b/wadsrc/static/zscript/hexen/centaur.txt index abf2f19d2..960e79557 100644 --- a/wadsrc/static/zscript/hexen/centaur.txt +++ b/wadsrc/static/zscript/hexen/centaur.txt @@ -154,6 +154,7 @@ class CentaurFX : Actor Damage 4; Projectile; +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "CentaurLeaderAttack"; DeathSound "CentaurMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/clericflame.txt b/wadsrc/static/zscript/hexen/clericflame.txt index 1978f43f1..a61891452 100644 --- a/wadsrc/static/zscript/hexen/clericflame.txt +++ b/wadsrc/static/zscript/hexen/clericflame.txt @@ -72,7 +72,7 @@ class CFlameFloor : Actor { Default { - +NOBLOCKMAP +NOGRAVITY + +NOBLOCKMAP +NOGRAVITY +ZDOOMADD RenderStyle "Add"; } States @@ -93,8 +93,8 @@ class FlamePuff : Actor { Radius 1; Height 1; - +NOBLOCKMAP +NOGRAVITY - RenderStyle "Add";; + +NOBLOCKMAP +NOGRAVITY +ZDOOMADD + RenderStyle "Add"; SeeSound "ClericFlameExplode"; AttackSound "ClericFlameExplode"; } @@ -159,6 +159,7 @@ class CircleFlame : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; DeathSound "ClericFlameCircle"; Obituary "$OB_MPCWEAPFLAME"; @@ -216,6 +217,7 @@ class CFlameMissile : FastProjectile Damage 8; DamageType "Fire"; +INVISIBLE + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPCWEAPFLAME"; } diff --git a/wadsrc/static/zscript/hexen/demons.txt b/wadsrc/static/zscript/hexen/demons.txt index ef4c96d8d..6bdbbe9f1 100644 --- a/wadsrc/static/zscript/hexen/demons.txt +++ b/wadsrc/static/zscript/hexen/demons.txt @@ -205,6 +205,7 @@ class Demon1FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; @@ -392,6 +393,7 @@ class Demon2FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/dragon.txt b/wadsrc/static/zscript/hexen/dragon.txt index 6082d1c61..231055186 100644 --- a/wadsrc/static/zscript/hexen/dragon.txt +++ b/wadsrc/static/zscript/hexen/dragon.txt @@ -311,6 +311,7 @@ class DragonFireball : Actor DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; DeathSound "DragonFireballExplode"; } @@ -364,6 +365,7 @@ class DragonExplosion : Actor +NOBLOCKMAP +NOTELEPORT +INVISIBLE + +ZDOOMADD RenderStyle "Add"; DeathSound "DragonFireballExplode"; } diff --git a/wadsrc/static/zscript/hexen/fighteraxe.txt b/wadsrc/static/zscript/hexen/fighteraxe.txt index ccf8b5294..d20a5fc35 100644 --- a/wadsrc/static/zscript/hexen/fighteraxe.txt +++ b/wadsrc/static/zscript/hexen/fighteraxe.txt @@ -307,6 +307,7 @@ class AxePuffGlow : AxePuff Default { +PUFFONACTORS + +ZDOOMADD RenderStyle "Add"; Alpha 1; } diff --git a/wadsrc/static/zscript/hexen/fighterquietus.txt b/wadsrc/static/zscript/hexen/fighterquietus.txt index 53388eece..c3e5f9b2d 100644 --- a/wadsrc/static/zscript/hexen/fighterquietus.txt +++ b/wadsrc/static/zscript/hexen/fighterquietus.txt @@ -168,6 +168,7 @@ class FSwordMissile : Actor Damage 8; Projectile; +EXTREMEDEATH + +ZDOOMADD RenderStyle "Add"; DeathSound "FighterSwordExplode"; Obituary "$OB_MPFWEAPQUIETUS"; diff --git a/wadsrc/static/zscript/hexen/firedemon.txt b/wadsrc/static/zscript/hexen/firedemon.txt index 9ca12529f..65dff9544 100644 --- a/wadsrc/static/zscript/hexen/firedemon.txt +++ b/wadsrc/static/zscript/hexen/firedemon.txt @@ -436,6 +436,7 @@ class FireDemonMissile : Actor Projectile; RenderStyle "Add"; DeathSound "FireDemonMissileHit"; + +ZDOOMADD } States { diff --git a/wadsrc/static/zscript/hexen/flame.txt b/wadsrc/static/zscript/hexen/flame.txt index 4eab6c6d3..b4574031b 100644 --- a/wadsrc/static/zscript/hexen/flame.txt +++ b/wadsrc/static/zscript/hexen/flame.txt @@ -5,6 +5,7 @@ class FlameSmallTemp : Actor Default { +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; } @@ -28,6 +29,7 @@ class FlameLargeTemp : Actor Default { +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; } @@ -62,6 +64,7 @@ class FlameSmall : SwitchableDecoration { +NOTELEPORT +INVISIBLE + +ZDOOMADD Radius 15; RenderStyle "Add"; } @@ -95,6 +98,7 @@ class FlameLarge : SwitchableDecoration { +NOTELEPORT +INVISIBLE + +ZDOOMADD Radius 15; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/heresiarch.txt b/wadsrc/static/zscript/hexen/heresiarch.txt index f89d2fb83..fd9176a61 100644 --- a/wadsrc/static/zscript/hexen/heresiarch.txt +++ b/wadsrc/static/zscript/hexen/heresiarch.txt @@ -1125,6 +1125,7 @@ class SorcSpark1 : Actor +NOBLOCKMAP +DROPOFF +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/hexen/magelightning.txt b/wadsrc/static/zscript/hexen/magelightning.txt index d45162d49..a70eeb8e1 100644 --- a/wadsrc/static/zscript/hexen/magelightning.txt +++ b/wadsrc/static/zscript/hexen/magelightning.txt @@ -165,6 +165,7 @@ class LightningCeiling : Lightning Damage 8; Projectile; +CEILINGHUGGER + +ZDOOMADD RenderStyle "Add"; } @@ -319,6 +320,7 @@ class LightningFloor : LightningCeiling { -CEILINGHUGGER +FLOORHUGGER + +ZDOOMADD RenderStyle "Add"; } @@ -374,6 +376,7 @@ class LightningZap : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPMWEAPLIGHTNING"; } diff --git a/wadsrc/static/zscript/hexen/scriptprojectiles.txt b/wadsrc/static/zscript/hexen/scriptprojectiles.txt index 5bf3f254f..eebb89b54 100644 --- a/wadsrc/static/zscript/hexen/scriptprojectiles.txt +++ b/wadsrc/static/zscript/hexen/scriptprojectiles.txt @@ -11,6 +11,7 @@ class FireBall : Actor DamageType "Fire"; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; DeathSound "Fireball"; } diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index 98ca6643f..11bb01fb9 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -317,6 +317,7 @@ class SerpentFX : Actor Damage 4; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; DeathSound "SerpentFXHit"; } diff --git a/wadsrc/static/zscript/raven/minotaur.txt b/wadsrc/static/zscript/raven/minotaur.txt index d45ce03f6..14d18a19a 100644 --- a/wadsrc/static/zscript/raven/minotaur.txt +++ b/wadsrc/static/zscript/raven/minotaur.txt @@ -655,6 +655,7 @@ class MinotaurFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/sentinel.txt b/wadsrc/static/zscript/strife/sentinel.txt index e9e6255d4..268cd47da 100644 --- a/wadsrc/static/zscript/strife/sentinel.txt +++ b/wadsrc/static/zscript/strife/sentinel.txt @@ -97,6 +97,7 @@ class SentinelFX1 : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/strife/spectral.txt b/wadsrc/static/zscript/strife/spectral.txt index a56d9e717..8fa4cc44a 100644 --- a/wadsrc/static/zscript/strife/spectral.txt +++ b/wadsrc/static/zscript/strife/spectral.txt @@ -112,6 +112,7 @@ class SpectralLightningBase : Actor +ACTIVATEIMPACT +ACTIVATEPCROSS +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/sigil"; @@ -257,6 +258,7 @@ class SpectralLightningHTail : Actor +NOBLOCKMAP +NOGRAVITY +DROPOFF + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/strifestuff.txt b/wadsrc/static/zscript/strife/strifestuff.txt index f08eaa6a5..04f364c75 100644 --- a/wadsrc/static/zscript/strife/strifestuff.txt +++ b/wadsrc/static/zscript/strife/strifestuff.txt @@ -632,6 +632,7 @@ class TeleportSwirl : Actor Default { +NOBLOCKMAP + +ZDOOMADD RenderStyle "Add"; Alpha 0.25; } diff --git a/wadsrc/static/zscript/strife/strifeweapons.txt b/wadsrc/static/zscript/strife/strifeweapons.txt index 5cb01342e..e0d5f8f13 100644 --- a/wadsrc/static/zscript/strife/strifeweapons.txt +++ b/wadsrc/static/zscript/strife/strifeweapons.txt @@ -40,6 +40,7 @@ class StrifeSpark : StrifePuff { Default { + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/thingstoblowup.txt b/wadsrc/static/zscript/strife/thingstoblowup.txt index a2b515efb..abc032093 100644 --- a/wadsrc/static/zscript/strife/thingstoblowup.txt +++ b/wadsrc/static/zscript/strife/thingstoblowup.txt @@ -49,6 +49,7 @@ class Bang4Cloud : Actor { +NOBLOCKMAP +NOGRAVITY + +ZDOOMADD RenderStyle "Add"; VSpeed 1; } diff --git a/wadsrc/static/zscript/strife/weaponflamer.txt b/wadsrc/static/zscript/strife/weaponflamer.txt index 9a47bc242..521cbc0c5 100644 --- a/wadsrc/static/zscript/strife/weaponflamer.txt +++ b/wadsrc/static/zscript/strife/weaponflamer.txt @@ -85,6 +85,7 @@ class FlameMissile : Actor Projectile; -NOGRAVITY +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/flamethrower"; diff --git a/wadsrc/static/zscript/strife/weapongrenade.txt b/wadsrc/static/zscript/strife/weapongrenade.txt index 21e568313..eebf028db 100644 --- a/wadsrc/static/zscript/strife/weapongrenade.txt +++ b/wadsrc/static/zscript/strife/weapongrenade.txt @@ -217,6 +217,7 @@ class PhosphorousFire : Actor +NOTELEPORT +NODAMAGETHRUST +DONTSPLASH + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPPHOSPHOROUSGRENADE"; } diff --git a/wadsrc/static/zscript/strife/weaponmauler.txt b/wadsrc/static/zscript/strife/weaponmauler.txt index 80f3afcde..4ee9e1baf 100644 --- a/wadsrc/static/zscript/strife/weaponmauler.txt +++ b/wadsrc/static/zscript/strife/weaponmauler.txt @@ -181,6 +181,7 @@ class MaulerPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMADD RenderStyle "Add"; DamageType "Disintegrate"; } @@ -206,6 +207,7 @@ class MaulerTorpedo : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/mauler2fire"; @@ -268,6 +270,7 @@ class MaulerTorpedoWave : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; Obituary "$OB_MPMAULER"; From bf12d38afdd8902459ce8e5a08d62c0592a0d223 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 14:03:51 -0400 Subject: [PATCH 36/82] - removed ZDOOMADD and updated actors in question with ZDOOMTRANS --- src/actor.h | 1 - src/gl/scene/gl_sprite.cpp | 7 ------- src/polyrenderer/scene/poly_sprite.cpp | 2 -- src/scripting/thingdef_data.cpp | 1 - src/swrenderer/things/r_sprite.cpp | 2 -- wadsrc/static/zscript/heretic/beast.txt | 4 ++-- wadsrc/static/zscript/heretic/dsparil.txt | 8 ++++---- wadsrc/static/zscript/heretic/hereticimp.txt | 2 +- wadsrc/static/zscript/heretic/hereticmisc.txt | 2 +- wadsrc/static/zscript/heretic/ironlich.txt | 6 +++--- wadsrc/static/zscript/heretic/mummy.txt | 2 +- wadsrc/static/zscript/heretic/snake.txt | 2 +- wadsrc/static/zscript/heretic/weaponblaster.txt | 2 +- wadsrc/static/zscript/heretic/weaponcrossbow.txt | 2 +- wadsrc/static/zscript/heretic/weaponphoenix.txt | 2 +- wadsrc/static/zscript/heretic/weaponskullrod.txt | 6 +++--- wadsrc/static/zscript/heretic/weaponstaff.txt | 2 +- wadsrc/static/zscript/heretic/weaponwand.txt | 2 +- wadsrc/static/zscript/heretic/wizard.txt | 2 +- wadsrc/static/zscript/hexen/bishop.txt | 2 +- wadsrc/static/zscript/hexen/centaur.txt | 2 +- wadsrc/static/zscript/hexen/clericflame.txt | 8 ++++---- wadsrc/static/zscript/hexen/demons.txt | 4 ++-- wadsrc/static/zscript/hexen/dragon.txt | 4 ++-- wadsrc/static/zscript/hexen/fighteraxe.txt | 2 +- wadsrc/static/zscript/hexen/fighterquietus.txt | 2 +- wadsrc/static/zscript/hexen/firedemon.txt | 2 +- wadsrc/static/zscript/hexen/flame.txt | 8 ++++---- wadsrc/static/zscript/hexen/heresiarch.txt | 2 +- wadsrc/static/zscript/hexen/magelightning.txt | 6 +++--- wadsrc/static/zscript/hexen/scriptprojectiles.txt | 2 +- wadsrc/static/zscript/hexen/serpent.txt | 2 +- wadsrc/static/zscript/raven/minotaur.txt | 2 +- wadsrc/static/zscript/strife/sentinel.txt | 2 +- wadsrc/static/zscript/strife/spectral.txt | 4 ++-- wadsrc/static/zscript/strife/strifestuff.txt | 2 +- wadsrc/static/zscript/strife/strifeweapons.txt | 2 +- wadsrc/static/zscript/strife/thingstoblowup.txt | 2 +- wadsrc/static/zscript/strife/weaponflamer.txt | 2 +- wadsrc/static/zscript/strife/weapongrenade.txt | 2 +- wadsrc/static/zscript/strife/weaponmauler.txt | 6 +++--- 41 files changed, 57 insertions(+), 70 deletions(-) diff --git a/src/actor.h b/src/actor.h index 7dccdc397..aafb5cec9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -445,7 +445,6 @@ enum ActorRenderFlag RF_SPRITEFLIP = 0x08000000, // sprite flipped on x-axis RF_ZDOOMTRANS = 0x10000000, // is not normally transparent in Vanilla Doom - RF_ZDOOMADD = 0x20000000, // is not normally additive in Vanilla Hexen/Heretic/Strife }; // This translucency value produces the closest match to Heretic's TINTTAB. diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index f6fecf0b1..8d053e81c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -1004,13 +1004,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) RenderStyle.SrcAlpha = STYLEALPHA_One; RenderStyle.DestAlpha = STYLEALPHA_Zero; } - if (thing->renderflags & RF_ZDOOMADD) - { - RenderStyle.BlendOp = STYLEOP_Add; - RenderStyle.SrcAlpha = STYLEALPHA_Src; - RenderStyle.DestAlpha = STYLEALPHA_InvSrc; - } - } if (trans >= 1.f - FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 398f37e7b..ba91f005b 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -148,8 +148,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetClipPlane(clipPlane); if ((thing->renderflags & RF_ZDOOMTRANS) && r_vanillatrans) args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); - else if ((thing->renderflags & RF_ZDOOMADD) && r_vanillatrans) - args.SetStyle(LegacyRenderStyles[STYLE_Translucent], thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); args.SetSubsectorDepthTest(true); diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index e53a7d48a..b63fd4eca 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -347,7 +347,6 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(RF, DONTINTERPOLATE, AActor, renderflags), DEFINE_FLAG(RF, SPRITEFLIP, AActor, renderflags), DEFINE_FLAG(RF, ZDOOMTRANS, AActor, renderflags), - DEFINE_FLAG(RF, ZDOOMADD, AActor, renderflags), // Bounce flags DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 7dcab13ec..d067b9007 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -217,8 +217,6 @@ namespace swrenderer { if (thing->renderflags & RF_ZDOOMTRANS) vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; - if (thing->renderflags & RF_ZDOOMADD) - vis->RenderStyle = LegacyRenderStyles[STYLE_Translucent]; } vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table diff --git a/wadsrc/static/zscript/heretic/beast.txt b/wadsrc/static/zscript/heretic/beast.txt index 9e004f5c1..e5f30d25b 100644 --- a/wadsrc/static/zscript/heretic/beast.txt +++ b/wadsrc/static/zscript/heretic/beast.txt @@ -75,7 +75,7 @@ class BeastBall : Actor -NOBLOCKMAP +WINDTHRUST +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "beast/attack"; } @@ -105,7 +105,7 @@ class Puffy : Actor +MISSILE +NOTELEPORT +DONTSPLASH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/heretic/dsparil.txt b/wadsrc/static/zscript/heretic/dsparil.txt index bc2054f70..70e3c33db 100644 --- a/wadsrc/static/zscript/heretic/dsparil.txt +++ b/wadsrc/static/zscript/heretic/dsparil.txt @@ -192,7 +192,7 @@ class SorcererFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -411,7 +411,7 @@ class Sorcerer2FX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -459,7 +459,7 @@ class Sorcerer2FXSpark : Actor +NOGRAVITY +NOTELEPORT +CANNOTPUSH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -484,7 +484,7 @@ class Sorcerer2FX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/heretic/hereticimp.txt b/wadsrc/static/zscript/heretic/hereticimp.txt index be3e2e7df..11430712a 100644 --- a/wadsrc/static/zscript/heretic/hereticimp.txt +++ b/wadsrc/static/zscript/heretic/hereticimp.txt @@ -228,7 +228,7 @@ class HereticImpBall : Actor +SPAWNSOUNDSOURCE -ACTIVATEPCROSS -ACTIVATEIMPACT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/heretic/hereticmisc.txt b/wadsrc/static/zscript/heretic/hereticmisc.txt index 895c04ed2..fde9ec582 100644 --- a/wadsrc/static/zscript/heretic/hereticmisc.txt +++ b/wadsrc/static/zscript/heretic/hereticmisc.txt @@ -205,7 +205,7 @@ class TeleGlitter1 : Actor { Default { - +NOBLOCKMAP +NOGRAVITY +MISSILE +ZDOOMADD + +NOBLOCKMAP +NOGRAVITY +MISSILE +ZDOOMTRANS RenderStyle "Add"; Damage 0; } diff --git a/wadsrc/static/zscript/heretic/ironlich.txt b/wadsrc/static/zscript/heretic/ironlich.txt index 52fddc6f7..c3497a7e2 100644 --- a/wadsrc/static/zscript/heretic/ironlich.txt +++ b/wadsrc/static/zscript/heretic/ironlich.txt @@ -144,7 +144,7 @@ class HeadFX1 : Actor -ACTIVATEIMPACT -ACTIVATEPCROSS +THRUGHOST - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -196,7 +196,7 @@ class HeadFX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -225,7 +225,7 @@ class HeadFX3 : Actor Damage 5; Projectile; +WINDTHRUST - +ZDOOMADD + +ZDOOMTRANS -ACTIVATEIMPACT -ACTIVATEPCROSS -NOBLOCKMAP diff --git a/wadsrc/static/zscript/heretic/mummy.txt b/wadsrc/static/zscript/heretic/mummy.txt index 453c6e83c..5ccedc9e4 100644 --- a/wadsrc/static/zscript/heretic/mummy.txt +++ b/wadsrc/static/zscript/heretic/mummy.txt @@ -135,7 +135,7 @@ class MummyFX1 : Actor -ACTIVATEPCROSS -ACTIVATEIMPACT +SEEKERMISSILE - +ZDOOMADD + +ZDOOMTRANS } States { diff --git a/wadsrc/static/zscript/heretic/snake.txt b/wadsrc/static/zscript/heretic/snake.txt index bc0d8344a..e2f5b381f 100644 --- a/wadsrc/static/zscript/heretic/snake.txt +++ b/wadsrc/static/zscript/heretic/snake.txt @@ -64,7 +64,7 @@ class SnakeProjA : Actor -ACTIVATEPCROSS +WINDTHRUST +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "snake/attack"; } diff --git a/wadsrc/static/zscript/heretic/weaponblaster.txt b/wadsrc/static/zscript/heretic/weaponblaster.txt index 38c30ee14..7a5d60981 100644 --- a/wadsrc/static/zscript/heretic/weaponblaster.txt +++ b/wadsrc/static/zscript/heretic/weaponblaster.txt @@ -244,7 +244,7 @@ class BlasterPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "weapons/blasterhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponcrossbow.txt b/wadsrc/static/zscript/heretic/weaponcrossbow.txt index 69fd108be..011e57947 100644 --- a/wadsrc/static/zscript/heretic/weaponcrossbow.txt +++ b/wadsrc/static/zscript/heretic/weaponcrossbow.txt @@ -129,7 +129,7 @@ class CrossbowFX1 : Actor SeeSound "weapons/bowshoot"; DeathSound "weapons/bowhit"; Obituary "$OB_MPCROSSBOW"; - +ZDOOMADD + +ZDOOMTRANS } States diff --git a/wadsrc/static/zscript/heretic/weaponphoenix.txt b/wadsrc/static/zscript/heretic/weaponphoenix.txt index a44bb4c13..162184f6e 100644 --- a/wadsrc/static/zscript/heretic/weaponphoenix.txt +++ b/wadsrc/static/zscript/heretic/weaponphoenix.txt @@ -292,7 +292,7 @@ class PhoenixFX2 : Actor DamageType "Fire"; Projectile; RenderStyle "Add"; - +ZDOOMADD + +ZDOOMTRANS Obituary "$OB_MPPPHOENIXROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponskullrod.txt b/wadsrc/static/zscript/heretic/weaponskullrod.txt index 0e651807e..edfda93ff 100644 --- a/wadsrc/static/zscript/heretic/weaponskullrod.txt +++ b/wadsrc/static/zscript/heretic/weaponskullrod.txt @@ -143,7 +143,7 @@ class HornRodFX1 : Actor Damage 3; Projectile; +WINDTHRUST - +ZDOOMADD + +ZDOOMTRANS -NOBLOCKMAP RenderStyle "Add"; SeeSound "weapons/hornrodshoot"; @@ -178,7 +178,7 @@ class HornRodFX2 : Actor Health 140; Projectile; RenderStyle "Add"; - +ZDOOMADD + +ZDOOMTRANS SeeSound "weapons/hornrodpowshoot"; DeathSound "weapons/hornrodpowhit"; Obituary "$OB_MPPSKULLROD"; @@ -366,7 +366,7 @@ class RainPillar : Actor Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPPSKULLROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponstaff.txt b/wadsrc/static/zscript/heretic/weaponstaff.txt index 1e1237780..ff57db620 100644 --- a/wadsrc/static/zscript/heretic/weaponstaff.txt +++ b/wadsrc/static/zscript/heretic/weaponstaff.txt @@ -132,7 +132,7 @@ class StaffPuff2 : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS AttackSound "weapons/staffpowerhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponwand.txt b/wadsrc/static/zscript/heretic/weaponwand.txt index 38cd9e2de..62d46a240 100644 --- a/wadsrc/static/zscript/heretic/weaponwand.txt +++ b/wadsrc/static/zscript/heretic/weaponwand.txt @@ -142,7 +142,7 @@ class GoldWandFX1 : Actor Damage 2; Projectile; RenderStyle "Add"; - +ZDOOMADD + +ZDOOMTRANS DeathSound "weapons/wandhit"; Obituary "$OB_MPPGOLDWAND"; } diff --git a/wadsrc/static/zscript/heretic/wizard.txt b/wadsrc/static/zscript/heretic/wizard.txt index a3772573c..a1ce5a98b 100644 --- a/wadsrc/static/zscript/heretic/wizard.txt +++ b/wadsrc/static/zscript/heretic/wizard.txt @@ -145,7 +145,7 @@ class WizardFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/bishop.txt b/wadsrc/static/zscript/hexen/bishop.txt index 8f4b2bd22..352839e27 100644 --- a/wadsrc/static/zscript/hexen/bishop.txt +++ b/wadsrc/static/zscript/hexen/bishop.txt @@ -290,7 +290,7 @@ class BishopFX : Actor Projectile; +SEEKERMISSILE -ACTIVATEIMPACT -ACTIVATEPCROSS - +STRIFEDAMAGE +ZDOOMADD + +STRIFEDAMAGE +ZDOOMTRANS RenderStyle "Add"; DeathSound "BishopMissileExplode"; } diff --git a/wadsrc/static/zscript/hexen/centaur.txt b/wadsrc/static/zscript/hexen/centaur.txt index 960e79557..8cd5639a2 100644 --- a/wadsrc/static/zscript/hexen/centaur.txt +++ b/wadsrc/static/zscript/hexen/centaur.txt @@ -154,7 +154,7 @@ class CentaurFX : Actor Damage 4; Projectile; +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "CentaurLeaderAttack"; DeathSound "CentaurMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/clericflame.txt b/wadsrc/static/zscript/hexen/clericflame.txt index a61891452..660abf538 100644 --- a/wadsrc/static/zscript/hexen/clericflame.txt +++ b/wadsrc/static/zscript/hexen/clericflame.txt @@ -72,7 +72,7 @@ class CFlameFloor : Actor { Default { - +NOBLOCKMAP +NOGRAVITY +ZDOOMADD + +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; } States @@ -93,7 +93,7 @@ class FlamePuff : Actor { Radius 1; Height 1; - +NOBLOCKMAP +NOGRAVITY +ZDOOMADD + +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; SeeSound "ClericFlameExplode"; AttackSound "ClericFlameExplode"; @@ -159,7 +159,7 @@ class CircleFlame : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "ClericFlameCircle"; Obituary "$OB_MPCWEAPFLAME"; @@ -217,7 +217,7 @@ class CFlameMissile : FastProjectile Damage 8; DamageType "Fire"; +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPCWEAPFLAME"; } diff --git a/wadsrc/static/zscript/hexen/demons.txt b/wadsrc/static/zscript/hexen/demons.txt index 6bdbbe9f1..778bb957e 100644 --- a/wadsrc/static/zscript/hexen/demons.txt +++ b/wadsrc/static/zscript/hexen/demons.txt @@ -205,7 +205,7 @@ class Demon1FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; @@ -393,7 +393,7 @@ class Demon2FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/dragon.txt b/wadsrc/static/zscript/hexen/dragon.txt index 231055186..dceedd55d 100644 --- a/wadsrc/static/zscript/hexen/dragon.txt +++ b/wadsrc/static/zscript/hexen/dragon.txt @@ -311,7 +311,7 @@ class DragonFireball : Actor DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "DragonFireballExplode"; } @@ -365,7 +365,7 @@ class DragonExplosion : Actor +NOBLOCKMAP +NOTELEPORT +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "DragonFireballExplode"; } diff --git a/wadsrc/static/zscript/hexen/fighteraxe.txt b/wadsrc/static/zscript/hexen/fighteraxe.txt index d20a5fc35..61e509744 100644 --- a/wadsrc/static/zscript/hexen/fighteraxe.txt +++ b/wadsrc/static/zscript/hexen/fighteraxe.txt @@ -307,7 +307,7 @@ class AxePuffGlow : AxePuff Default { +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; } diff --git a/wadsrc/static/zscript/hexen/fighterquietus.txt b/wadsrc/static/zscript/hexen/fighterquietus.txt index c3e5f9b2d..b935f8e11 100644 --- a/wadsrc/static/zscript/hexen/fighterquietus.txt +++ b/wadsrc/static/zscript/hexen/fighterquietus.txt @@ -168,7 +168,7 @@ class FSwordMissile : Actor Damage 8; Projectile; +EXTREMEDEATH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "FighterSwordExplode"; Obituary "$OB_MPFWEAPQUIETUS"; diff --git a/wadsrc/static/zscript/hexen/firedemon.txt b/wadsrc/static/zscript/hexen/firedemon.txt index 65dff9544..e10156402 100644 --- a/wadsrc/static/zscript/hexen/firedemon.txt +++ b/wadsrc/static/zscript/hexen/firedemon.txt @@ -436,7 +436,7 @@ class FireDemonMissile : Actor Projectile; RenderStyle "Add"; DeathSound "FireDemonMissileHit"; - +ZDOOMADD + +ZDOOMTRANS } States { diff --git a/wadsrc/static/zscript/hexen/flame.txt b/wadsrc/static/zscript/hexen/flame.txt index b4574031b..b11e5c2d5 100644 --- a/wadsrc/static/zscript/hexen/flame.txt +++ b/wadsrc/static/zscript/hexen/flame.txt @@ -5,7 +5,7 @@ class FlameSmallTemp : Actor Default { +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -29,7 +29,7 @@ class FlameLargeTemp : Actor Default { +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -64,7 +64,7 @@ class FlameSmall : SwitchableDecoration { +NOTELEPORT +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS Radius 15; RenderStyle "Add"; } @@ -98,7 +98,7 @@ class FlameLarge : SwitchableDecoration { +NOTELEPORT +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS Radius 15; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/heresiarch.txt b/wadsrc/static/zscript/hexen/heresiarch.txt index fd9176a61..ffb26b136 100644 --- a/wadsrc/static/zscript/hexen/heresiarch.txt +++ b/wadsrc/static/zscript/hexen/heresiarch.txt @@ -1125,7 +1125,7 @@ class SorcSpark1 : Actor +NOBLOCKMAP +DROPOFF +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/hexen/magelightning.txt b/wadsrc/static/zscript/hexen/magelightning.txt index a70eeb8e1..a4b23706b 100644 --- a/wadsrc/static/zscript/hexen/magelightning.txt +++ b/wadsrc/static/zscript/hexen/magelightning.txt @@ -165,7 +165,7 @@ class LightningCeiling : Lightning Damage 8; Projectile; +CEILINGHUGGER - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -320,7 +320,7 @@ class LightningFloor : LightningCeiling { -CEILINGHUGGER +FLOORHUGGER - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -376,7 +376,7 @@ class LightningZap : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPMWEAPLIGHTNING"; } diff --git a/wadsrc/static/zscript/hexen/scriptprojectiles.txt b/wadsrc/static/zscript/hexen/scriptprojectiles.txt index eebb89b54..819e38e26 100644 --- a/wadsrc/static/zscript/hexen/scriptprojectiles.txt +++ b/wadsrc/static/zscript/hexen/scriptprojectiles.txt @@ -11,7 +11,7 @@ class FireBall : Actor DamageType "Fire"; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "Fireball"; } diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index 11bb01fb9..fa1b53d6c 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -317,7 +317,7 @@ class SerpentFX : Actor Damage 4; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "SerpentFXHit"; } diff --git a/wadsrc/static/zscript/raven/minotaur.txt b/wadsrc/static/zscript/raven/minotaur.txt index 14d18a19a..b44684cb6 100644 --- a/wadsrc/static/zscript/raven/minotaur.txt +++ b/wadsrc/static/zscript/raven/minotaur.txt @@ -655,7 +655,7 @@ class MinotaurFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/sentinel.txt b/wadsrc/static/zscript/strife/sentinel.txt index 268cd47da..190111be7 100644 --- a/wadsrc/static/zscript/strife/sentinel.txt +++ b/wadsrc/static/zscript/strife/sentinel.txt @@ -97,7 +97,7 @@ class SentinelFX1 : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/strife/spectral.txt b/wadsrc/static/zscript/strife/spectral.txt index 8fa4cc44a..bc7f11f3b 100644 --- a/wadsrc/static/zscript/strife/spectral.txt +++ b/wadsrc/static/zscript/strife/spectral.txt @@ -112,7 +112,7 @@ class SpectralLightningBase : Actor +ACTIVATEIMPACT +ACTIVATEPCROSS +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/sigil"; @@ -258,7 +258,7 @@ class SpectralLightningHTail : Actor +NOBLOCKMAP +NOGRAVITY +DROPOFF - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/strifestuff.txt b/wadsrc/static/zscript/strife/strifestuff.txt index 04f364c75..a26e5b697 100644 --- a/wadsrc/static/zscript/strife/strifestuff.txt +++ b/wadsrc/static/zscript/strife/strifestuff.txt @@ -632,7 +632,7 @@ class TeleportSwirl : Actor Default { +NOBLOCKMAP - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.25; } diff --git a/wadsrc/static/zscript/strife/strifeweapons.txt b/wadsrc/static/zscript/strife/strifeweapons.txt index e0d5f8f13..15f5dea4a 100644 --- a/wadsrc/static/zscript/strife/strifeweapons.txt +++ b/wadsrc/static/zscript/strife/strifeweapons.txt @@ -40,7 +40,7 @@ class StrifeSpark : StrifePuff { Default { - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/thingstoblowup.txt b/wadsrc/static/zscript/strife/thingstoblowup.txt index abc032093..f18e783f7 100644 --- a/wadsrc/static/zscript/strife/thingstoblowup.txt +++ b/wadsrc/static/zscript/strife/thingstoblowup.txt @@ -49,7 +49,7 @@ class Bang4Cloud : Actor { +NOBLOCKMAP +NOGRAVITY - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; VSpeed 1; } diff --git a/wadsrc/static/zscript/strife/weaponflamer.txt b/wadsrc/static/zscript/strife/weaponflamer.txt index 521cbc0c5..1c7a0873a 100644 --- a/wadsrc/static/zscript/strife/weaponflamer.txt +++ b/wadsrc/static/zscript/strife/weaponflamer.txt @@ -85,7 +85,7 @@ class FlameMissile : Actor Projectile; -NOGRAVITY +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/flamethrower"; diff --git a/wadsrc/static/zscript/strife/weapongrenade.txt b/wadsrc/static/zscript/strife/weapongrenade.txt index eebf028db..8d6a12b2d 100644 --- a/wadsrc/static/zscript/strife/weapongrenade.txt +++ b/wadsrc/static/zscript/strife/weapongrenade.txt @@ -217,7 +217,7 @@ class PhosphorousFire : Actor +NOTELEPORT +NODAMAGETHRUST +DONTSPLASH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPPHOSPHOROUSGRENADE"; } diff --git a/wadsrc/static/zscript/strife/weaponmauler.txt b/wadsrc/static/zscript/strife/weaponmauler.txt index 4ee9e1baf..cc4e7c30c 100644 --- a/wadsrc/static/zscript/strife/weaponmauler.txt +++ b/wadsrc/static/zscript/strife/weaponmauler.txt @@ -181,7 +181,7 @@ class MaulerPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DamageType "Disintegrate"; } @@ -207,7 +207,7 @@ class MaulerTorpedo : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/mauler2fire"; @@ -270,7 +270,7 @@ class MaulerTorpedoWave : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; Obituary "$OB_MPMAULER"; From 7d7b1b3b97fadaf24603e6d47180bad8e4880fd7 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 14:17:49 -0400 Subject: [PATCH 37/82] - fixed: missed the golden wand puff for the +ZDOOMTRANS flag --- wadsrc/static/zscript/heretic/weaponwand.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/heretic/weaponwand.txt b/wadsrc/static/zscript/heretic/weaponwand.txt index 62d46a240..aa08f5c66 100644 --- a/wadsrc/static/zscript/heretic/weaponwand.txt +++ b/wadsrc/static/zscript/heretic/weaponwand.txt @@ -186,6 +186,7 @@ class GoldWandPuff1 : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMTRANS RenderStyle "Add"; } From daad76547d990be11dae200434055c1608054645 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 10:41:52 -0400 Subject: [PATCH 38/82] - Added 'canonical transparency' cvar r_canontrans - this simply turns off transparency for Doom objects that were marked as transparent sometime in ZDoom's development cycle --- src/actor.h | 1 + src/gl/scene/gl_sprite.cpp | 8 ++++++++ src/polyrenderer/scene/poly_sprite.cpp | 6 +++++- src/r_data/renderstyle.cpp | 1 + src/scripting/thingdef_data.cpp | 1 + src/swrenderer/things/r_sprite.cpp | 3 +++ wadsrc/static/zscript/doom/arachnotron.txt | 1 + wadsrc/static/zscript/doom/archvile.txt | 2 +- wadsrc/static/zscript/doom/bossbrain.txt | 1 + wadsrc/static/zscript/doom/bruiser.txt | 1 + wadsrc/static/zscript/doom/cacodemon.txt | 1 + wadsrc/static/zscript/doom/doomartifacts.txt | 1 + wadsrc/static/zscript/doom/doomimp.txt | 1 + wadsrc/static/zscript/doom/doommisc.txt | 1 + wadsrc/static/zscript/doom/fatso.txt | 1 + wadsrc/static/zscript/doom/lostsoul.txt | 2 +- wadsrc/static/zscript/doom/revenant.txt | 2 ++ wadsrc/static/zscript/doom/weaponbfg.txt | 1 + wadsrc/static/zscript/doom/weaponplasma.txt | 1 + 19 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/actor.h b/src/actor.h index be3f28ec6..5474a8213 100644 --- a/src/actor.h +++ b/src/actor.h @@ -402,6 +402,7 @@ enum ActorFlag8 { MF8_FRIGHTENING = 0x00000001, // for those moments when halloween just won't do MF8_INSCROLLSEC = 0x00000002, // actor is partially inside a scrolling sector + MF8_ZDOOMTRANS = 0x00000004, // is not normally transparent in Vanilla Doom }; // --- mobj.renderflags --- diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index c491bb33e..fa5b40dec 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -75,6 +75,7 @@ CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) } EXTERN_CVAR (Float, transsouls) +EXTERN_CVAR (Bool, r_canontrans) extern TArray sprites; extern TArray SpriteFrames; @@ -992,6 +993,13 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { trans = 1.f; } + if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + { // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects + trans = 1.f; + RenderStyle.BlendOp = STYLEOP_Add; + RenderStyle.SrcAlpha = STYLEALPHA_One; + RenderStyle.DestAlpha = STYLEALPHA_Zero; + } if (trans >= 1.f - FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 2ddf46df3..fb2c4ea28 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -31,6 +31,7 @@ EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) +EXTERN_CVAR (Bool, r_canontrans) bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) { @@ -145,7 +146,10 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); + if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); + else + args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); args.SetSubsectorDepthTest(true); args.SetWriteSubsectorDepth(false); args.SetWriteStencil(false); diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index 987de82b9..11943f46d 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -38,6 +38,7 @@ #include "serializer.h" CVAR (Bool, r_drawtrans, true, 0) +CVAR (Bool, r_canontrans, false, CVAR_ARCHIVE) CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) // Convert legacy render styles to flexible render styles. diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index f62ba0c88..d978136b8 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -325,6 +325,7 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF7, SPRITEFLIP, AActor, flags7), DEFINE_FLAG(MF8, FRIGHTENING, AActor, flags8), + DEFINE_FLAG(MF8, ZDOOMTRANS, AActor, flags8), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 889430004..c7c2898ba 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -68,6 +68,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, gl_light_sprites) +EXTERN_CVAR (Bool, r_canontrans) namespace swrenderer { @@ -212,6 +213,8 @@ namespace swrenderer if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->RenderStyle = thing->RenderStyle; + if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table vis->FakeFlatStat = fakeside; diff --git a/wadsrc/static/zscript/doom/arachnotron.txt b/wadsrc/static/zscript/doom/arachnotron.txt index c7e11ab14..36bb2b38e 100644 --- a/wadsrc/static/zscript/doom/arachnotron.txt +++ b/wadsrc/static/zscript/doom/arachnotron.txt @@ -72,6 +72,7 @@ class ArachnotronPlasma : Actor Damage 5; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "baby/attack"; diff --git a/wadsrc/static/zscript/doom/archvile.txt b/wadsrc/static/zscript/doom/archvile.txt index 2ea153be1..8e0a98dcb 100644 --- a/wadsrc/static/zscript/doom/archvile.txt +++ b/wadsrc/static/zscript/doom/archvile.txt @@ -70,7 +70,7 @@ class ArchvileFire : Actor { Default { - +NOBLOCKMAP +NOGRAVITY + +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; Alpha 1; } diff --git a/wadsrc/static/zscript/doom/bossbrain.txt b/wadsrc/static/zscript/doom/bossbrain.txt index 07f0cc946..5b87182c9 100644 --- a/wadsrc/static/zscript/doom/bossbrain.txt +++ b/wadsrc/static/zscript/doom/bossbrain.txt @@ -120,6 +120,7 @@ class SpawnFire : Actor Height 78; +NOBLOCKMAP +NOGRAVITY + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/doom/bruiser.txt b/wadsrc/static/zscript/doom/bruiser.txt index c1faa23c1..81f12db54 100644 --- a/wadsrc/static/zscript/doom/bruiser.txt +++ b/wadsrc/static/zscript/doom/bruiser.txt @@ -121,6 +121,7 @@ class BaronBall : Actor Damage 8; Projectile ; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "baron/attack"; diff --git a/wadsrc/static/zscript/doom/cacodemon.txt b/wadsrc/static/zscript/doom/cacodemon.txt index b21acacd2..8cd3a5089 100644 --- a/wadsrc/static/zscript/doom/cacodemon.txt +++ b/wadsrc/static/zscript/doom/cacodemon.txt @@ -71,6 +71,7 @@ class CacodemonBall : Actor Damage 5; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "caco/attack"; diff --git a/wadsrc/static/zscript/doom/doomartifacts.txt b/wadsrc/static/zscript/doom/doomartifacts.txt index a6996cb88..bb04da93c 100644 --- a/wadsrc/static/zscript/doom/doomartifacts.txt +++ b/wadsrc/static/zscript/doom/doomartifacts.txt @@ -97,6 +97,7 @@ class BlurSphere : PowerupGiver { +COUNTITEM +VISIBILITYPULSE + +ZDOOMTRANS +INVENTORY.AUTOACTIVATE +INVENTORY.ALWAYSPICKUP +INVENTORY.BIGPOWERUP diff --git a/wadsrc/static/zscript/doom/doomimp.txt b/wadsrc/static/zscript/doom/doomimp.txt index d2b93acdd..c3a187b38 100644 --- a/wadsrc/static/zscript/doom/doomimp.txt +++ b/wadsrc/static/zscript/doom/doomimp.txt @@ -77,6 +77,7 @@ class DoomImpBall : Actor Damage 3; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "imp/attack"; diff --git a/wadsrc/static/zscript/doom/doommisc.txt b/wadsrc/static/zscript/doom/doommisc.txt index 7d4c9dec4..c6d8af717 100644 --- a/wadsrc/static/zscript/doom/doommisc.txt +++ b/wadsrc/static/zscript/doom/doommisc.txt @@ -61,6 +61,7 @@ class BulletPuff : Actor +NOGRAVITY +ALLOWPARTICLES +RANDOMIZE + +ZDOOMTRANS RenderStyle "Translucent"; Alpha 0.5; VSpeed 1; diff --git a/wadsrc/static/zscript/doom/fatso.txt b/wadsrc/static/zscript/doom/fatso.txt index e70c97924..2e6321650 100644 --- a/wadsrc/static/zscript/doom/fatso.txt +++ b/wadsrc/static/zscript/doom/fatso.txt @@ -74,6 +74,7 @@ class FatShot : Actor Damage 8; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "fatso/attack"; diff --git a/wadsrc/static/zscript/doom/lostsoul.txt b/wadsrc/static/zscript/doom/lostsoul.txt index 7d918aa10..ce7f07f51 100644 --- a/wadsrc/static/zscript/doom/lostsoul.txt +++ b/wadsrc/static/zscript/doom/lostsoul.txt @@ -15,7 +15,7 @@ class LostSoul : Actor Damage 3; PainChance 256; Monster; - +FLOAT +NOGRAVITY +MISSILEMORE +DONTFALL +NOICEDEATH; + +FLOAT +NOGRAVITY +MISSILEMORE +DONTFALL +NOICEDEATH +ZDOOMTRANS; AttackSound "skull/melee"; PainSound "skull/pain"; DeathSound "skull/death"; diff --git a/wadsrc/static/zscript/doom/revenant.txt b/wadsrc/static/zscript/doom/revenant.txt index 82d563934..c3a7c218d 100644 --- a/wadsrc/static/zscript/doom/revenant.txt +++ b/wadsrc/static/zscript/doom/revenant.txt @@ -80,6 +80,7 @@ class RevenantTracer : Actor Projectile; +SEEKERMISSILE +RANDOMIZE + +ZDOOMTRANS SeeSound "skeleton/attack"; DeathSound "skeleton/tracex"; RenderStyle "Add"; @@ -110,6 +111,7 @@ class RevenantTracerSmoke : Actor +NOBLOCKMAP +NOGRAVITY +NOTELEPORT + +ZDOOMTRANS RenderStyle "Translucent"; Alpha 0.5; } diff --git a/wadsrc/static/zscript/doom/weaponbfg.txt b/wadsrc/static/zscript/doom/weaponbfg.txt index 9bf0084b3..9da326313 100644 --- a/wadsrc/static/zscript/doom/weaponbfg.txt +++ b/wadsrc/static/zscript/doom/weaponbfg.txt @@ -142,6 +142,7 @@ class BFGBall : Actor Damage 100; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; DeathSound "weapons/bfgx"; diff --git a/wadsrc/static/zscript/doom/weaponplasma.txt b/wadsrc/static/zscript/doom/weaponplasma.txt index 945339a35..b66092b82 100644 --- a/wadsrc/static/zscript/doom/weaponplasma.txt +++ b/wadsrc/static/zscript/doom/weaponplasma.txt @@ -51,6 +51,7 @@ class PlasmaBall : Actor Damage 5; Projectile; +RANDOMIZE + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "weapons/plasmaf"; From eeaf6214f7655bf6a832c1a5888c295167b62f40 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 12:05:43 -0400 Subject: [PATCH 39/82] - fixed: forgot to assign +ZDOOMTRANS to rockets --- wadsrc/static/zscript/doom/weaponrlaunch.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/doom/weaponrlaunch.txt b/wadsrc/static/zscript/doom/weaponrlaunch.txt index 906db3823..042b96823 100644 --- a/wadsrc/static/zscript/doom/weaponrlaunch.txt +++ b/wadsrc/static/zscript/doom/weaponrlaunch.txt @@ -55,6 +55,7 @@ class Rocket : Actor +RANDOMIZE +DEHEXPLOSION +ROCKETTRAIL + +ZDOOMTRANS SeeSound "weapons/rocklf"; DeathSound "weapons/rocklx"; Obituary "$OB_MPROCKET"; From 00bfee8b1e1f2c4de26f8da5889dd9e244885f4a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 13:13:30 -0400 Subject: [PATCH 40/82] - Changed MF7_SPRITEFLIP, MF8_ZDOOMTRANS to RenderFlags - Added RF_ZDOOMADD - renamed r_canontrans to r_vanillatrans - this developer's insanity level has increased by 231%. --- src/actor.h | 6 +++-- src/gl/scene/gl_sprite.cpp | 33 ++++++++++++++++--------- src/polyrenderer/scene/poly_sprite.cpp | 6 +++-- src/r_data/renderstyle.cpp | 2 +- src/scripting/thingdef_data.cpp | 5 ++-- src/swrenderer/scene/r_opaque_pass.cpp | 2 +- src/swrenderer/things/r_sprite.cpp | 13 +++++++--- wadsrc/static/zscript/heretic/beast.txt | 2 ++ 8 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/actor.h b/src/actor.h index 5474a8213..7dccdc397 100644 --- a/src/actor.h +++ b/src/actor.h @@ -396,13 +396,11 @@ enum ActorFlag7 MF7_FORCEZERORADIUSDMG = 0x10000000, // passes zero radius damage on to P_DamageMobj, this is necessary in some cases where DoSpecialDamage gets overrideen. MF7_NOINFIGHTSPECIES = 0x20000000, // don't start infights with one's own species. MF7_FORCEINFIGHTING = 0x40000000, // overrides a map setting of 'no infighting'. - MF7_SPRITEFLIP = 0x80000000, // sprite flipped on x-axis }; enum ActorFlag8 { MF8_FRIGHTENING = 0x00000001, // for those moments when halloween just won't do MF8_INSCROLLSEC = 0x00000002, // actor is partially inside a scrolling sector - MF8_ZDOOMTRANS = 0x00000004, // is not normally transparent in Vanilla Doom }; // --- mobj.renderflags --- @@ -444,6 +442,10 @@ enum ActorRenderFlag RF_INTERPOLATEANGLES = 0x01000000, // [MC] Allow interpolation of the actor's angle, pitch and roll. RF_MAYBEINVISIBLE = 0x02000000, RF_DONTINTERPOLATE = 0x04000000, // no render interpolation ever! + + RF_SPRITEFLIP = 0x08000000, // sprite flipped on x-axis + RF_ZDOOMTRANS = 0x10000000, // is not normally transparent in Vanilla Doom + RF_ZDOOMADD = 0x20000000, // is not normally additive in Vanilla Hexen/Heretic/Strife }; // This translucency value produces the closest match to Heretic's TINTTAB. diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index fa5b40dec..f6fecf0b1 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -75,7 +75,7 @@ CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) } EXTERN_CVAR (Float, transsouls) -EXTERN_CVAR (Bool, r_canontrans) +EXTERN_CVAR (Bool, r_vanillatrans) extern TArray sprites; extern TArray SpriteFrames; @@ -801,7 +801,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) sprangle = 0.; rot = 0; } - patch = sprites[spritenum].GetSpriteFrame(thing->frame, rot, sprangle, &mirror, !!(thing->flags7 & MF7_SPRITEFLIP)); + patch = sprites[spritenum].GetSpriteFrame(thing->frame, rot, sprangle, &mirror, !!(thing->renderflags & RF_SPRITEFLIP)); } if (!patch.isValid()) return; @@ -817,7 +817,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) gltexture->GetSpriteRect(&r); // [SP] SpriteFlip - if (thing->flags7 & MF7_SPRITEFLIP) + if (thing->renderflags & RF_SPRITEFLIP) thing->renderflags ^= RF_XFLIP; if (mirror ^ !!(thing->renderflags & RF_XFLIP)) @@ -832,7 +832,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) ur = gltexture->GetSpriteUL(); } - if (thing->flags7 & MF7_SPRITEFLIP) // [SP] Flip back + if (thing->renderflags & RF_SPRITEFLIP) // [SP] Flip back thing->renderflags ^= RF_XFLIP; r.Scale(sprscale.X, sprscale.Y); @@ -993,14 +993,25 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { trans = 1.f; } - if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) - { // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects - trans = 1.f; - RenderStyle.BlendOp = STYLEOP_Add; - RenderStyle.SrcAlpha = STYLEALPHA_One; - RenderStyle.DestAlpha = STYLEALPHA_Zero; - } + if (r_vanillatrans) + { + // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects, + // and disable 'additive' translucency for certain objects from other games. + if (thing->renderflags & RF_ZDOOMTRANS) + { + trans = 1.f; + RenderStyle.BlendOp = STYLEOP_Add; + RenderStyle.SrcAlpha = STYLEALPHA_One; + RenderStyle.DestAlpha = STYLEALPHA_Zero; + } + if (thing->renderflags & RF_ZDOOMADD) + { + RenderStyle.BlendOp = STYLEOP_Add; + RenderStyle.SrcAlpha = STYLEALPHA_Src; + RenderStyle.DestAlpha = STYLEALPHA_InvSrc; + } + } if (trans >= 1.f - FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || (RenderStyle.SrcAlpha == STYLEALPHA_Src && RenderStyle.DestAlpha == STYLEALPHA_InvSrc) diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index fb2c4ea28..398f37e7b 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -31,7 +31,7 @@ EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) -EXTERN_CVAR (Bool, r_canontrans) +EXTERN_CVAR (Bool, r_vanillatrans) bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) { @@ -146,8 +146,10 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) + if ((thing->renderflags & RF_ZDOOMTRANS) && r_vanillatrans) args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); + else if ((thing->renderflags & RF_ZDOOMADD) && r_vanillatrans) + args.SetStyle(LegacyRenderStyles[STYLE_Translucent], thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); args.SetSubsectorDepthTest(true); diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index 11943f46d..fc1905f91 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -38,7 +38,7 @@ #include "serializer.h" CVAR (Bool, r_drawtrans, true, 0) -CVAR (Bool, r_canontrans, false, CVAR_ARCHIVE) +CVAR (Bool, r_vanillatrans, false, CVAR_ARCHIVE) CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) // Convert legacy render styles to flexible render styles. diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index d978136b8..e53a7d48a 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -322,10 +322,8 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF7, FORCEZERORADIUSDMG, AActor, flags7), DEFINE_FLAG(MF7, NOINFIGHTSPECIES, AActor, flags7), DEFINE_FLAG(MF7, FORCEINFIGHTING, AActor, flags7), - DEFINE_FLAG(MF7, SPRITEFLIP, AActor, flags7), DEFINE_FLAG(MF8, FRIGHTENING, AActor, flags8), - DEFINE_FLAG(MF8, ZDOOMTRANS, AActor, flags8), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), @@ -347,6 +345,9 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(RF, YFLIP, AActor, renderflags), DEFINE_FLAG(RF, INTERPOLATEANGLES, AActor, renderflags), DEFINE_FLAG(RF, DONTINTERPOLATE, AActor, renderflags), + DEFINE_FLAG(RF, SPRITEFLIP, AActor, renderflags), + DEFINE_FLAG(RF, ZDOOMTRANS, AActor, renderflags), + DEFINE_FLAG(RF, ZDOOMADD, AActor, renderflags), // Bounce flags DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 1838122d0..bb8081a27 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -1007,7 +1007,7 @@ namespace swrenderer DAngle sprangle = thing->GetSpriteAngle((sprite.pos - viewpoint.Pos).Angle(), viewpoint.TicFrac); bool flipX; - FTextureID tex = sprdef->GetSpriteFrame(thing->frame, -1, sprangle, &flipX, !!(thing->flags7 & MF7_SPRITEFLIP)); + FTextureID tex = sprdef->GetSpriteFrame(thing->frame, -1, sprangle, &flipX, !!(thing->renderflags & RF_SPRITEFLIP)); if (tex.isValid()) { if (flipX) diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index c7c2898ba..7dcab13ec 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -68,7 +68,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, gl_light_sprites) -EXTERN_CVAR (Bool, r_canontrans) +EXTERN_CVAR (Bool, r_vanillatrans) namespace swrenderer { @@ -147,7 +147,7 @@ namespace swrenderer renderflags ^= renderportal->MirrorFlags & RF_XFLIP; // [SP] SpriteFlip - if (thing->flags7 & MF7_SPRITEFLIP) + if (thing->renderflags & RF_SPRITEFLIP) renderflags ^= RF_XFLIP; // calculate edges of the shape @@ -213,8 +213,13 @@ namespace swrenderer if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->RenderStyle = thing->RenderStyle; - if ((thing->flags8 & MF8_ZDOOMTRANS) && r_canontrans) - vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; + if (r_vanillatrans) + { + if (thing->renderflags & RF_ZDOOMTRANS) + vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; + if (thing->renderflags & RF_ZDOOMADD) + vis->RenderStyle = LegacyRenderStyles[STYLE_Translucent]; + } vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table vis->FakeFlatStat = fakeside; diff --git a/wadsrc/static/zscript/heretic/beast.txt b/wadsrc/static/zscript/heretic/beast.txt index 209b2da56..9e004f5c1 100644 --- a/wadsrc/static/zscript/heretic/beast.txt +++ b/wadsrc/static/zscript/heretic/beast.txt @@ -75,6 +75,7 @@ class BeastBall : Actor -NOBLOCKMAP +WINDTHRUST +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "beast/attack"; } @@ -104,6 +105,7 @@ class Puffy : Actor +MISSILE +NOTELEPORT +DONTSPLASH + +ZDOOMADD RenderStyle "Add"; } States From 91e3b1926459f62a02fdbdb90c9f198cdd015fda Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 13:41:05 -0400 Subject: [PATCH 41/82] - Added +ZDOOMADD to all Heretic, Hexen, and Strife actors that needed it (that I know of...) - this developer's insanity level increased another 21% --- wadsrc/static/zscript/heretic/dsparil.txt | 4 ++++ wadsrc/static/zscript/heretic/hereticimp.txt | 1 + wadsrc/static/zscript/heretic/hereticmisc.txt | 2 +- wadsrc/static/zscript/heretic/ironlich.txt | 3 +++ wadsrc/static/zscript/heretic/mummy.txt | 1 + wadsrc/static/zscript/heretic/snake.txt | 1 + wadsrc/static/zscript/heretic/weaponblaster.txt | 1 + wadsrc/static/zscript/heretic/weaponcrossbow.txt | 1 + wadsrc/static/zscript/heretic/weaponphoenix.txt | 1 + wadsrc/static/zscript/heretic/weaponskullrod.txt | 3 +++ wadsrc/static/zscript/heretic/weaponstaff.txt | 1 + wadsrc/static/zscript/heretic/weaponwand.txt | 1 + wadsrc/static/zscript/heretic/wizard.txt | 1 + wadsrc/static/zscript/hexen/bishop.txt | 2 +- wadsrc/static/zscript/hexen/centaur.txt | 1 + wadsrc/static/zscript/hexen/clericflame.txt | 8 +++++--- wadsrc/static/zscript/hexen/demons.txt | 2 ++ wadsrc/static/zscript/hexen/dragon.txt | 2 ++ wadsrc/static/zscript/hexen/fighteraxe.txt | 1 + wadsrc/static/zscript/hexen/fighterquietus.txt | 1 + wadsrc/static/zscript/hexen/firedemon.txt | 1 + wadsrc/static/zscript/hexen/flame.txt | 4 ++++ wadsrc/static/zscript/hexen/heresiarch.txt | 1 + wadsrc/static/zscript/hexen/magelightning.txt | 3 +++ wadsrc/static/zscript/hexen/scriptprojectiles.txt | 1 + wadsrc/static/zscript/hexen/serpent.txt | 1 + wadsrc/static/zscript/raven/minotaur.txt | 1 + wadsrc/static/zscript/strife/sentinel.txt | 1 + wadsrc/static/zscript/strife/spectral.txt | 2 ++ wadsrc/static/zscript/strife/strifestuff.txt | 1 + wadsrc/static/zscript/strife/strifeweapons.txt | 1 + wadsrc/static/zscript/strife/thingstoblowup.txt | 1 + wadsrc/static/zscript/strife/weaponflamer.txt | 1 + wadsrc/static/zscript/strife/weapongrenade.txt | 1 + wadsrc/static/zscript/strife/weaponmauler.txt | 3 +++ 35 files changed, 56 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/zscript/heretic/dsparil.txt b/wadsrc/static/zscript/heretic/dsparil.txt index 579f47492..bc2054f70 100644 --- a/wadsrc/static/zscript/heretic/dsparil.txt +++ b/wadsrc/static/zscript/heretic/dsparil.txt @@ -192,6 +192,7 @@ class SorcererFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } @@ -410,6 +411,7 @@ class Sorcerer2FX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } @@ -457,6 +459,7 @@ class Sorcerer2FXSpark : Actor +NOGRAVITY +NOTELEPORT +CANNOTPUSH + +ZDOOMADD RenderStyle "Add"; } @@ -481,6 +484,7 @@ class Sorcerer2FX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/heretic/hereticimp.txt b/wadsrc/static/zscript/heretic/hereticimp.txt index e6915c7f6..be3e2e7df 100644 --- a/wadsrc/static/zscript/heretic/hereticimp.txt +++ b/wadsrc/static/zscript/heretic/hereticimp.txt @@ -228,6 +228,7 @@ class HereticImpBall : Actor +SPAWNSOUNDSOURCE -ACTIVATEPCROSS -ACTIVATEIMPACT + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/heretic/hereticmisc.txt b/wadsrc/static/zscript/heretic/hereticmisc.txt index b66217352..895c04ed2 100644 --- a/wadsrc/static/zscript/heretic/hereticmisc.txt +++ b/wadsrc/static/zscript/heretic/hereticmisc.txt @@ -205,7 +205,7 @@ class TeleGlitter1 : Actor { Default { - +NOBLOCKMAP +NOGRAVITY +MISSILE + +NOBLOCKMAP +NOGRAVITY +MISSILE +ZDOOMADD RenderStyle "Add"; Damage 0; } diff --git a/wadsrc/static/zscript/heretic/ironlich.txt b/wadsrc/static/zscript/heretic/ironlich.txt index 65e510932..52fddc6f7 100644 --- a/wadsrc/static/zscript/heretic/ironlich.txt +++ b/wadsrc/static/zscript/heretic/ironlich.txt @@ -144,6 +144,7 @@ class HeadFX1 : Actor -ACTIVATEIMPACT -ACTIVATEPCROSS +THRUGHOST + +ZDOOMADD RenderStyle "Add"; } @@ -195,6 +196,7 @@ class HeadFX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } @@ -223,6 +225,7 @@ class HeadFX3 : Actor Damage 5; Projectile; +WINDTHRUST + +ZDOOMADD -ACTIVATEIMPACT -ACTIVATEPCROSS -NOBLOCKMAP diff --git a/wadsrc/static/zscript/heretic/mummy.txt b/wadsrc/static/zscript/heretic/mummy.txt index 6d01fcea4..453c6e83c 100644 --- a/wadsrc/static/zscript/heretic/mummy.txt +++ b/wadsrc/static/zscript/heretic/mummy.txt @@ -135,6 +135,7 @@ class MummyFX1 : Actor -ACTIVATEPCROSS -ACTIVATEIMPACT +SEEKERMISSILE + +ZDOOMADD } States { diff --git a/wadsrc/static/zscript/heretic/snake.txt b/wadsrc/static/zscript/heretic/snake.txt index 15ae342aa..bc0d8344a 100644 --- a/wadsrc/static/zscript/heretic/snake.txt +++ b/wadsrc/static/zscript/heretic/snake.txt @@ -64,6 +64,7 @@ class SnakeProjA : Actor -ACTIVATEPCROSS +WINDTHRUST +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "snake/attack"; } diff --git a/wadsrc/static/zscript/heretic/weaponblaster.txt b/wadsrc/static/zscript/heretic/weaponblaster.txt index e7e1e92b5..38c30ee14 100644 --- a/wadsrc/static/zscript/heretic/weaponblaster.txt +++ b/wadsrc/static/zscript/heretic/weaponblaster.txt @@ -244,6 +244,7 @@ class BlasterPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMADD RenderStyle "Add"; SeeSound "weapons/blasterhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponcrossbow.txt b/wadsrc/static/zscript/heretic/weaponcrossbow.txt index bd5e9517a..69fd108be 100644 --- a/wadsrc/static/zscript/heretic/weaponcrossbow.txt +++ b/wadsrc/static/zscript/heretic/weaponcrossbow.txt @@ -129,6 +129,7 @@ class CrossbowFX1 : Actor SeeSound "weapons/bowshoot"; DeathSound "weapons/bowhit"; Obituary "$OB_MPCROSSBOW"; + +ZDOOMADD } States diff --git a/wadsrc/static/zscript/heretic/weaponphoenix.txt b/wadsrc/static/zscript/heretic/weaponphoenix.txt index 558a257cd..a44bb4c13 100644 --- a/wadsrc/static/zscript/heretic/weaponphoenix.txt +++ b/wadsrc/static/zscript/heretic/weaponphoenix.txt @@ -292,6 +292,7 @@ class PhoenixFX2 : Actor DamageType "Fire"; Projectile; RenderStyle "Add"; + +ZDOOMADD Obituary "$OB_MPPPHOENIXROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponskullrod.txt b/wadsrc/static/zscript/heretic/weaponskullrod.txt index da959f7ae..0e651807e 100644 --- a/wadsrc/static/zscript/heretic/weaponskullrod.txt +++ b/wadsrc/static/zscript/heretic/weaponskullrod.txt @@ -143,6 +143,7 @@ class HornRodFX1 : Actor Damage 3; Projectile; +WINDTHRUST + +ZDOOMADD -NOBLOCKMAP RenderStyle "Add"; SeeSound "weapons/hornrodshoot"; @@ -177,6 +178,7 @@ class HornRodFX2 : Actor Health 140; Projectile; RenderStyle "Add"; + +ZDOOMADD SeeSound "weapons/hornrodpowshoot"; DeathSound "weapons/hornrodpowhit"; Obituary "$OB_MPPSKULLROD"; @@ -364,6 +366,7 @@ class RainPillar : Actor Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPPSKULLROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponstaff.txt b/wadsrc/static/zscript/heretic/weaponstaff.txt index 85126f503..1e1237780 100644 --- a/wadsrc/static/zscript/heretic/weaponstaff.txt +++ b/wadsrc/static/zscript/heretic/weaponstaff.txt @@ -132,6 +132,7 @@ class StaffPuff2 : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMADD AttackSound "weapons/staffpowerhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponwand.txt b/wadsrc/static/zscript/heretic/weaponwand.txt index 9516aa76c..38cd9e2de 100644 --- a/wadsrc/static/zscript/heretic/weaponwand.txt +++ b/wadsrc/static/zscript/heretic/weaponwand.txt @@ -142,6 +142,7 @@ class GoldWandFX1 : Actor Damage 2; Projectile; RenderStyle "Add"; + +ZDOOMADD DeathSound "weapons/wandhit"; Obituary "$OB_MPPGOLDWAND"; } diff --git a/wadsrc/static/zscript/heretic/wizard.txt b/wadsrc/static/zscript/heretic/wizard.txt index d146ae220..a3772573c 100644 --- a/wadsrc/static/zscript/heretic/wizard.txt +++ b/wadsrc/static/zscript/heretic/wizard.txt @@ -145,6 +145,7 @@ class WizardFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/bishop.txt b/wadsrc/static/zscript/hexen/bishop.txt index 32f0f3e63..8f4b2bd22 100644 --- a/wadsrc/static/zscript/hexen/bishop.txt +++ b/wadsrc/static/zscript/hexen/bishop.txt @@ -290,7 +290,7 @@ class BishopFX : Actor Projectile; +SEEKERMISSILE -ACTIVATEIMPACT -ACTIVATEPCROSS - +STRIFEDAMAGE + +STRIFEDAMAGE +ZDOOMADD RenderStyle "Add"; DeathSound "BishopMissileExplode"; } diff --git a/wadsrc/static/zscript/hexen/centaur.txt b/wadsrc/static/zscript/hexen/centaur.txt index abf2f19d2..960e79557 100644 --- a/wadsrc/static/zscript/hexen/centaur.txt +++ b/wadsrc/static/zscript/hexen/centaur.txt @@ -154,6 +154,7 @@ class CentaurFX : Actor Damage 4; Projectile; +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "CentaurLeaderAttack"; DeathSound "CentaurMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/clericflame.txt b/wadsrc/static/zscript/hexen/clericflame.txt index 1978f43f1..a61891452 100644 --- a/wadsrc/static/zscript/hexen/clericflame.txt +++ b/wadsrc/static/zscript/hexen/clericflame.txt @@ -72,7 +72,7 @@ class CFlameFloor : Actor { Default { - +NOBLOCKMAP +NOGRAVITY + +NOBLOCKMAP +NOGRAVITY +ZDOOMADD RenderStyle "Add"; } States @@ -93,8 +93,8 @@ class FlamePuff : Actor { Radius 1; Height 1; - +NOBLOCKMAP +NOGRAVITY - RenderStyle "Add";; + +NOBLOCKMAP +NOGRAVITY +ZDOOMADD + RenderStyle "Add"; SeeSound "ClericFlameExplode"; AttackSound "ClericFlameExplode"; } @@ -159,6 +159,7 @@ class CircleFlame : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; DeathSound "ClericFlameCircle"; Obituary "$OB_MPCWEAPFLAME"; @@ -216,6 +217,7 @@ class CFlameMissile : FastProjectile Damage 8; DamageType "Fire"; +INVISIBLE + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPCWEAPFLAME"; } diff --git a/wadsrc/static/zscript/hexen/demons.txt b/wadsrc/static/zscript/hexen/demons.txt index ef4c96d8d..6bdbbe9f1 100644 --- a/wadsrc/static/zscript/hexen/demons.txt +++ b/wadsrc/static/zscript/hexen/demons.txt @@ -205,6 +205,7 @@ class Demon1FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; @@ -392,6 +393,7 @@ class Demon2FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE + +ZDOOMADD RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/dragon.txt b/wadsrc/static/zscript/hexen/dragon.txt index 6082d1c61..231055186 100644 --- a/wadsrc/static/zscript/hexen/dragon.txt +++ b/wadsrc/static/zscript/hexen/dragon.txt @@ -311,6 +311,7 @@ class DragonFireball : Actor DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; DeathSound "DragonFireballExplode"; } @@ -364,6 +365,7 @@ class DragonExplosion : Actor +NOBLOCKMAP +NOTELEPORT +INVISIBLE + +ZDOOMADD RenderStyle "Add"; DeathSound "DragonFireballExplode"; } diff --git a/wadsrc/static/zscript/hexen/fighteraxe.txt b/wadsrc/static/zscript/hexen/fighteraxe.txt index ccf8b5294..d20a5fc35 100644 --- a/wadsrc/static/zscript/hexen/fighteraxe.txt +++ b/wadsrc/static/zscript/hexen/fighteraxe.txt @@ -307,6 +307,7 @@ class AxePuffGlow : AxePuff Default { +PUFFONACTORS + +ZDOOMADD RenderStyle "Add"; Alpha 1; } diff --git a/wadsrc/static/zscript/hexen/fighterquietus.txt b/wadsrc/static/zscript/hexen/fighterquietus.txt index 53388eece..c3e5f9b2d 100644 --- a/wadsrc/static/zscript/hexen/fighterquietus.txt +++ b/wadsrc/static/zscript/hexen/fighterquietus.txt @@ -168,6 +168,7 @@ class FSwordMissile : Actor Damage 8; Projectile; +EXTREMEDEATH + +ZDOOMADD RenderStyle "Add"; DeathSound "FighterSwordExplode"; Obituary "$OB_MPFWEAPQUIETUS"; diff --git a/wadsrc/static/zscript/hexen/firedemon.txt b/wadsrc/static/zscript/hexen/firedemon.txt index 9ca12529f..65dff9544 100644 --- a/wadsrc/static/zscript/hexen/firedemon.txt +++ b/wadsrc/static/zscript/hexen/firedemon.txt @@ -436,6 +436,7 @@ class FireDemonMissile : Actor Projectile; RenderStyle "Add"; DeathSound "FireDemonMissileHit"; + +ZDOOMADD } States { diff --git a/wadsrc/static/zscript/hexen/flame.txt b/wadsrc/static/zscript/hexen/flame.txt index 4eab6c6d3..b4574031b 100644 --- a/wadsrc/static/zscript/hexen/flame.txt +++ b/wadsrc/static/zscript/hexen/flame.txt @@ -5,6 +5,7 @@ class FlameSmallTemp : Actor Default { +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; } @@ -28,6 +29,7 @@ class FlameLargeTemp : Actor Default { +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; } @@ -62,6 +64,7 @@ class FlameSmall : SwitchableDecoration { +NOTELEPORT +INVISIBLE + +ZDOOMADD Radius 15; RenderStyle "Add"; } @@ -95,6 +98,7 @@ class FlameLarge : SwitchableDecoration { +NOTELEPORT +INVISIBLE + +ZDOOMADD Radius 15; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/heresiarch.txt b/wadsrc/static/zscript/hexen/heresiarch.txt index f89d2fb83..fd9176a61 100644 --- a/wadsrc/static/zscript/hexen/heresiarch.txt +++ b/wadsrc/static/zscript/hexen/heresiarch.txt @@ -1125,6 +1125,7 @@ class SorcSpark1 : Actor +NOBLOCKMAP +DROPOFF +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/hexen/magelightning.txt b/wadsrc/static/zscript/hexen/magelightning.txt index d45162d49..a70eeb8e1 100644 --- a/wadsrc/static/zscript/hexen/magelightning.txt +++ b/wadsrc/static/zscript/hexen/magelightning.txt @@ -165,6 +165,7 @@ class LightningCeiling : Lightning Damage 8; Projectile; +CEILINGHUGGER + +ZDOOMADD RenderStyle "Add"; } @@ -319,6 +320,7 @@ class LightningFloor : LightningCeiling { -CEILINGHUGGER +FLOORHUGGER + +ZDOOMADD RenderStyle "Add"; } @@ -374,6 +376,7 @@ class LightningZap : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPMWEAPLIGHTNING"; } diff --git a/wadsrc/static/zscript/hexen/scriptprojectiles.txt b/wadsrc/static/zscript/hexen/scriptprojectiles.txt index 5bf3f254f..eebb89b54 100644 --- a/wadsrc/static/zscript/hexen/scriptprojectiles.txt +++ b/wadsrc/static/zscript/hexen/scriptprojectiles.txt @@ -11,6 +11,7 @@ class FireBall : Actor DamageType "Fire"; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT + +ZDOOMADD RenderStyle "Add"; DeathSound "Fireball"; } diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index 98ca6643f..11bb01fb9 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -317,6 +317,7 @@ class SerpentFX : Actor Damage 4; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; DeathSound "SerpentFXHit"; } diff --git a/wadsrc/static/zscript/raven/minotaur.txt b/wadsrc/static/zscript/raven/minotaur.txt index d45ce03f6..14d18a19a 100644 --- a/wadsrc/static/zscript/raven/minotaur.txt +++ b/wadsrc/static/zscript/raven/minotaur.txt @@ -655,6 +655,7 @@ class MinotaurFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/sentinel.txt b/wadsrc/static/zscript/strife/sentinel.txt index e9e6255d4..268cd47da 100644 --- a/wadsrc/static/zscript/strife/sentinel.txt +++ b/wadsrc/static/zscript/strife/sentinel.txt @@ -97,6 +97,7 @@ class SentinelFX1 : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/strife/spectral.txt b/wadsrc/static/zscript/strife/spectral.txt index a56d9e717..8fa4cc44a 100644 --- a/wadsrc/static/zscript/strife/spectral.txt +++ b/wadsrc/static/zscript/strife/spectral.txt @@ -112,6 +112,7 @@ class SpectralLightningBase : Actor +ACTIVATEIMPACT +ACTIVATEPCROSS +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/sigil"; @@ -257,6 +258,7 @@ class SpectralLightningHTail : Actor +NOBLOCKMAP +NOGRAVITY +DROPOFF + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/strifestuff.txt b/wadsrc/static/zscript/strife/strifestuff.txt index f08eaa6a5..04f364c75 100644 --- a/wadsrc/static/zscript/strife/strifestuff.txt +++ b/wadsrc/static/zscript/strife/strifestuff.txt @@ -632,6 +632,7 @@ class TeleportSwirl : Actor Default { +NOBLOCKMAP + +ZDOOMADD RenderStyle "Add"; Alpha 0.25; } diff --git a/wadsrc/static/zscript/strife/strifeweapons.txt b/wadsrc/static/zscript/strife/strifeweapons.txt index 5cb01342e..e0d5f8f13 100644 --- a/wadsrc/static/zscript/strife/strifeweapons.txt +++ b/wadsrc/static/zscript/strife/strifeweapons.txt @@ -40,6 +40,7 @@ class StrifeSpark : StrifePuff { Default { + +ZDOOMADD RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/thingstoblowup.txt b/wadsrc/static/zscript/strife/thingstoblowup.txt index a2b515efb..abc032093 100644 --- a/wadsrc/static/zscript/strife/thingstoblowup.txt +++ b/wadsrc/static/zscript/strife/thingstoblowup.txt @@ -49,6 +49,7 @@ class Bang4Cloud : Actor { +NOBLOCKMAP +NOGRAVITY + +ZDOOMADD RenderStyle "Add"; VSpeed 1; } diff --git a/wadsrc/static/zscript/strife/weaponflamer.txt b/wadsrc/static/zscript/strife/weaponflamer.txt index 9a47bc242..521cbc0c5 100644 --- a/wadsrc/static/zscript/strife/weaponflamer.txt +++ b/wadsrc/static/zscript/strife/weaponflamer.txt @@ -85,6 +85,7 @@ class FlameMissile : Actor Projectile; -NOGRAVITY +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/flamethrower"; diff --git a/wadsrc/static/zscript/strife/weapongrenade.txt b/wadsrc/static/zscript/strife/weapongrenade.txt index 21e568313..eebf028db 100644 --- a/wadsrc/static/zscript/strife/weapongrenade.txt +++ b/wadsrc/static/zscript/strife/weapongrenade.txt @@ -217,6 +217,7 @@ class PhosphorousFire : Actor +NOTELEPORT +NODAMAGETHRUST +DONTSPLASH + +ZDOOMADD RenderStyle "Add"; Obituary "$OB_MPPHOSPHOROUSGRENADE"; } diff --git a/wadsrc/static/zscript/strife/weaponmauler.txt b/wadsrc/static/zscript/strife/weaponmauler.txt index 80f3afcde..4ee9e1baf 100644 --- a/wadsrc/static/zscript/strife/weaponmauler.txt +++ b/wadsrc/static/zscript/strife/weaponmauler.txt @@ -181,6 +181,7 @@ class MaulerPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMADD RenderStyle "Add"; DamageType "Disintegrate"; } @@ -206,6 +207,7 @@ class MaulerTorpedo : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/mauler2fire"; @@ -268,6 +270,7 @@ class MaulerTorpedoWave : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE + +ZDOOMADD MaxStepHeight 4; RenderStyle "Add"; Obituary "$OB_MPMAULER"; From b240ad081487873a1d4f7892e2db2bd42af5d6aa Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 14:03:51 -0400 Subject: [PATCH 42/82] - removed ZDOOMADD and updated actors in question with ZDOOMTRANS --- src/actor.h | 1 - src/gl/scene/gl_sprite.cpp | 7 ------- src/polyrenderer/scene/poly_sprite.cpp | 2 -- src/scripting/thingdef_data.cpp | 1 - src/swrenderer/things/r_sprite.cpp | 2 -- wadsrc/static/zscript/heretic/beast.txt | 4 ++-- wadsrc/static/zscript/heretic/dsparil.txt | 8 ++++---- wadsrc/static/zscript/heretic/hereticimp.txt | 2 +- wadsrc/static/zscript/heretic/hereticmisc.txt | 2 +- wadsrc/static/zscript/heretic/ironlich.txt | 6 +++--- wadsrc/static/zscript/heretic/mummy.txt | 2 +- wadsrc/static/zscript/heretic/snake.txt | 2 +- wadsrc/static/zscript/heretic/weaponblaster.txt | 2 +- wadsrc/static/zscript/heretic/weaponcrossbow.txt | 2 +- wadsrc/static/zscript/heretic/weaponphoenix.txt | 2 +- wadsrc/static/zscript/heretic/weaponskullrod.txt | 6 +++--- wadsrc/static/zscript/heretic/weaponstaff.txt | 2 +- wadsrc/static/zscript/heretic/weaponwand.txt | 2 +- wadsrc/static/zscript/heretic/wizard.txt | 2 +- wadsrc/static/zscript/hexen/bishop.txt | 2 +- wadsrc/static/zscript/hexen/centaur.txt | 2 +- wadsrc/static/zscript/hexen/clericflame.txt | 8 ++++---- wadsrc/static/zscript/hexen/demons.txt | 4 ++-- wadsrc/static/zscript/hexen/dragon.txt | 4 ++-- wadsrc/static/zscript/hexen/fighteraxe.txt | 2 +- wadsrc/static/zscript/hexen/fighterquietus.txt | 2 +- wadsrc/static/zscript/hexen/firedemon.txt | 2 +- wadsrc/static/zscript/hexen/flame.txt | 8 ++++---- wadsrc/static/zscript/hexen/heresiarch.txt | 2 +- wadsrc/static/zscript/hexen/magelightning.txt | 6 +++--- wadsrc/static/zscript/hexen/scriptprojectiles.txt | 2 +- wadsrc/static/zscript/hexen/serpent.txt | 2 +- wadsrc/static/zscript/raven/minotaur.txt | 2 +- wadsrc/static/zscript/strife/sentinel.txt | 2 +- wadsrc/static/zscript/strife/spectral.txt | 4 ++-- wadsrc/static/zscript/strife/strifestuff.txt | 2 +- wadsrc/static/zscript/strife/strifeweapons.txt | 2 +- wadsrc/static/zscript/strife/thingstoblowup.txt | 2 +- wadsrc/static/zscript/strife/weaponflamer.txt | 2 +- wadsrc/static/zscript/strife/weapongrenade.txt | 2 +- wadsrc/static/zscript/strife/weaponmauler.txt | 6 +++--- 41 files changed, 57 insertions(+), 70 deletions(-) diff --git a/src/actor.h b/src/actor.h index 7dccdc397..aafb5cec9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -445,7 +445,6 @@ enum ActorRenderFlag RF_SPRITEFLIP = 0x08000000, // sprite flipped on x-axis RF_ZDOOMTRANS = 0x10000000, // is not normally transparent in Vanilla Doom - RF_ZDOOMADD = 0x20000000, // is not normally additive in Vanilla Hexen/Heretic/Strife }; // This translucency value produces the closest match to Heretic's TINTTAB. diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index f6fecf0b1..8d053e81c 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -1004,13 +1004,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) RenderStyle.SrcAlpha = STYLEALPHA_One; RenderStyle.DestAlpha = STYLEALPHA_Zero; } - if (thing->renderflags & RF_ZDOOMADD) - { - RenderStyle.BlendOp = STYLEOP_Add; - RenderStyle.SrcAlpha = STYLEALPHA_Src; - RenderStyle.DestAlpha = STYLEALPHA_InvSrc; - } - } if (trans >= 1.f - FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 398f37e7b..ba91f005b 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -148,8 +148,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetClipPlane(clipPlane); if ((thing->renderflags & RF_ZDOOMTRANS) && r_vanillatrans) args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); - else if ((thing->renderflags & RF_ZDOOMADD) && r_vanillatrans) - args.SetStyle(LegacyRenderStyles[STYLE_Translucent], thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); args.SetSubsectorDepthTest(true); diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index e53a7d48a..b63fd4eca 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -347,7 +347,6 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(RF, DONTINTERPOLATE, AActor, renderflags), DEFINE_FLAG(RF, SPRITEFLIP, AActor, renderflags), DEFINE_FLAG(RF, ZDOOMTRANS, AActor, renderflags), - DEFINE_FLAG(RF, ZDOOMADD, AActor, renderflags), // Bounce flags DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 7dcab13ec..d067b9007 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -217,8 +217,6 @@ namespace swrenderer { if (thing->renderflags & RF_ZDOOMTRANS) vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; - if (thing->renderflags & RF_ZDOOMADD) - vis->RenderStyle = LegacyRenderStyles[STYLE_Translucent]; } vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table diff --git a/wadsrc/static/zscript/heretic/beast.txt b/wadsrc/static/zscript/heretic/beast.txt index 9e004f5c1..e5f30d25b 100644 --- a/wadsrc/static/zscript/heretic/beast.txt +++ b/wadsrc/static/zscript/heretic/beast.txt @@ -75,7 +75,7 @@ class BeastBall : Actor -NOBLOCKMAP +WINDTHRUST +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "beast/attack"; } @@ -105,7 +105,7 @@ class Puffy : Actor +MISSILE +NOTELEPORT +DONTSPLASH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/heretic/dsparil.txt b/wadsrc/static/zscript/heretic/dsparil.txt index bc2054f70..70e3c33db 100644 --- a/wadsrc/static/zscript/heretic/dsparil.txt +++ b/wadsrc/static/zscript/heretic/dsparil.txt @@ -192,7 +192,7 @@ class SorcererFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -411,7 +411,7 @@ class Sorcerer2FX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -459,7 +459,7 @@ class Sorcerer2FXSpark : Actor +NOGRAVITY +NOTELEPORT +CANNOTPUSH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -484,7 +484,7 @@ class Sorcerer2FX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/heretic/hereticimp.txt b/wadsrc/static/zscript/heretic/hereticimp.txt index be3e2e7df..11430712a 100644 --- a/wadsrc/static/zscript/heretic/hereticimp.txt +++ b/wadsrc/static/zscript/heretic/hereticimp.txt @@ -228,7 +228,7 @@ class HereticImpBall : Actor +SPAWNSOUNDSOURCE -ACTIVATEPCROSS -ACTIVATEIMPACT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/heretic/hereticmisc.txt b/wadsrc/static/zscript/heretic/hereticmisc.txt index 895c04ed2..fde9ec582 100644 --- a/wadsrc/static/zscript/heretic/hereticmisc.txt +++ b/wadsrc/static/zscript/heretic/hereticmisc.txt @@ -205,7 +205,7 @@ class TeleGlitter1 : Actor { Default { - +NOBLOCKMAP +NOGRAVITY +MISSILE +ZDOOMADD + +NOBLOCKMAP +NOGRAVITY +MISSILE +ZDOOMTRANS RenderStyle "Add"; Damage 0; } diff --git a/wadsrc/static/zscript/heretic/ironlich.txt b/wadsrc/static/zscript/heretic/ironlich.txt index 52fddc6f7..c3497a7e2 100644 --- a/wadsrc/static/zscript/heretic/ironlich.txt +++ b/wadsrc/static/zscript/heretic/ironlich.txt @@ -144,7 +144,7 @@ class HeadFX1 : Actor -ACTIVATEIMPACT -ACTIVATEPCROSS +THRUGHOST - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -196,7 +196,7 @@ class HeadFX2 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -225,7 +225,7 @@ class HeadFX3 : Actor Damage 5; Projectile; +WINDTHRUST - +ZDOOMADD + +ZDOOMTRANS -ACTIVATEIMPACT -ACTIVATEPCROSS -NOBLOCKMAP diff --git a/wadsrc/static/zscript/heretic/mummy.txt b/wadsrc/static/zscript/heretic/mummy.txt index 453c6e83c..5ccedc9e4 100644 --- a/wadsrc/static/zscript/heretic/mummy.txt +++ b/wadsrc/static/zscript/heretic/mummy.txt @@ -135,7 +135,7 @@ class MummyFX1 : Actor -ACTIVATEPCROSS -ACTIVATEIMPACT +SEEKERMISSILE - +ZDOOMADD + +ZDOOMTRANS } States { diff --git a/wadsrc/static/zscript/heretic/snake.txt b/wadsrc/static/zscript/heretic/snake.txt index bc0d8344a..e2f5b381f 100644 --- a/wadsrc/static/zscript/heretic/snake.txt +++ b/wadsrc/static/zscript/heretic/snake.txt @@ -64,7 +64,7 @@ class SnakeProjA : Actor -ACTIVATEPCROSS +WINDTHRUST +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "snake/attack"; } diff --git a/wadsrc/static/zscript/heretic/weaponblaster.txt b/wadsrc/static/zscript/heretic/weaponblaster.txt index 38c30ee14..7a5d60981 100644 --- a/wadsrc/static/zscript/heretic/weaponblaster.txt +++ b/wadsrc/static/zscript/heretic/weaponblaster.txt @@ -244,7 +244,7 @@ class BlasterPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "weapons/blasterhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponcrossbow.txt b/wadsrc/static/zscript/heretic/weaponcrossbow.txt index 69fd108be..011e57947 100644 --- a/wadsrc/static/zscript/heretic/weaponcrossbow.txt +++ b/wadsrc/static/zscript/heretic/weaponcrossbow.txt @@ -129,7 +129,7 @@ class CrossbowFX1 : Actor SeeSound "weapons/bowshoot"; DeathSound "weapons/bowhit"; Obituary "$OB_MPCROSSBOW"; - +ZDOOMADD + +ZDOOMTRANS } States diff --git a/wadsrc/static/zscript/heretic/weaponphoenix.txt b/wadsrc/static/zscript/heretic/weaponphoenix.txt index a44bb4c13..162184f6e 100644 --- a/wadsrc/static/zscript/heretic/weaponphoenix.txt +++ b/wadsrc/static/zscript/heretic/weaponphoenix.txt @@ -292,7 +292,7 @@ class PhoenixFX2 : Actor DamageType "Fire"; Projectile; RenderStyle "Add"; - +ZDOOMADD + +ZDOOMTRANS Obituary "$OB_MPPPHOENIXROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponskullrod.txt b/wadsrc/static/zscript/heretic/weaponskullrod.txt index 0e651807e..edfda93ff 100644 --- a/wadsrc/static/zscript/heretic/weaponskullrod.txt +++ b/wadsrc/static/zscript/heretic/weaponskullrod.txt @@ -143,7 +143,7 @@ class HornRodFX1 : Actor Damage 3; Projectile; +WINDTHRUST - +ZDOOMADD + +ZDOOMTRANS -NOBLOCKMAP RenderStyle "Add"; SeeSound "weapons/hornrodshoot"; @@ -178,7 +178,7 @@ class HornRodFX2 : Actor Health 140; Projectile; RenderStyle "Add"; - +ZDOOMADD + +ZDOOMTRANS SeeSound "weapons/hornrodpowshoot"; DeathSound "weapons/hornrodpowhit"; Obituary "$OB_MPPSKULLROD"; @@ -366,7 +366,7 @@ class RainPillar : Actor Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPPSKULLROD"; } diff --git a/wadsrc/static/zscript/heretic/weaponstaff.txt b/wadsrc/static/zscript/heretic/weaponstaff.txt index 1e1237780..ff57db620 100644 --- a/wadsrc/static/zscript/heretic/weaponstaff.txt +++ b/wadsrc/static/zscript/heretic/weaponstaff.txt @@ -132,7 +132,7 @@ class StaffPuff2 : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS AttackSound "weapons/staffpowerhit"; } diff --git a/wadsrc/static/zscript/heretic/weaponwand.txt b/wadsrc/static/zscript/heretic/weaponwand.txt index 38cd9e2de..62d46a240 100644 --- a/wadsrc/static/zscript/heretic/weaponwand.txt +++ b/wadsrc/static/zscript/heretic/weaponwand.txt @@ -142,7 +142,7 @@ class GoldWandFX1 : Actor Damage 2; Projectile; RenderStyle "Add"; - +ZDOOMADD + +ZDOOMTRANS DeathSound "weapons/wandhit"; Obituary "$OB_MPPGOLDWAND"; } diff --git a/wadsrc/static/zscript/heretic/wizard.txt b/wadsrc/static/zscript/heretic/wizard.txt index a3772573c..a1ce5a98b 100644 --- a/wadsrc/static/zscript/heretic/wizard.txt +++ b/wadsrc/static/zscript/heretic/wizard.txt @@ -145,7 +145,7 @@ class WizardFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/bishop.txt b/wadsrc/static/zscript/hexen/bishop.txt index 8f4b2bd22..352839e27 100644 --- a/wadsrc/static/zscript/hexen/bishop.txt +++ b/wadsrc/static/zscript/hexen/bishop.txt @@ -290,7 +290,7 @@ class BishopFX : Actor Projectile; +SEEKERMISSILE -ACTIVATEIMPACT -ACTIVATEPCROSS - +STRIFEDAMAGE +ZDOOMADD + +STRIFEDAMAGE +ZDOOMTRANS RenderStyle "Add"; DeathSound "BishopMissileExplode"; } diff --git a/wadsrc/static/zscript/hexen/centaur.txt b/wadsrc/static/zscript/hexen/centaur.txt index 960e79557..8cd5639a2 100644 --- a/wadsrc/static/zscript/hexen/centaur.txt +++ b/wadsrc/static/zscript/hexen/centaur.txt @@ -154,7 +154,7 @@ class CentaurFX : Actor Damage 4; Projectile; +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "CentaurLeaderAttack"; DeathSound "CentaurMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/clericflame.txt b/wadsrc/static/zscript/hexen/clericflame.txt index a61891452..660abf538 100644 --- a/wadsrc/static/zscript/hexen/clericflame.txt +++ b/wadsrc/static/zscript/hexen/clericflame.txt @@ -72,7 +72,7 @@ class CFlameFloor : Actor { Default { - +NOBLOCKMAP +NOGRAVITY +ZDOOMADD + +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; } States @@ -93,7 +93,7 @@ class FlamePuff : Actor { Radius 1; Height 1; - +NOBLOCKMAP +NOGRAVITY +ZDOOMADD + +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; SeeSound "ClericFlameExplode"; AttackSound "ClericFlameExplode"; @@ -159,7 +159,7 @@ class CircleFlame : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "ClericFlameCircle"; Obituary "$OB_MPCWEAPFLAME"; @@ -217,7 +217,7 @@ class CFlameMissile : FastProjectile Damage 8; DamageType "Fire"; +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPCWEAPFLAME"; } diff --git a/wadsrc/static/zscript/hexen/demons.txt b/wadsrc/static/zscript/hexen/demons.txt index 6bdbbe9f1..778bb957e 100644 --- a/wadsrc/static/zscript/hexen/demons.txt +++ b/wadsrc/static/zscript/hexen/demons.txt @@ -205,7 +205,7 @@ class Demon1FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; @@ -393,7 +393,7 @@ class Demon2FX1 : Actor DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; diff --git a/wadsrc/static/zscript/hexen/dragon.txt b/wadsrc/static/zscript/hexen/dragon.txt index 231055186..dceedd55d 100644 --- a/wadsrc/static/zscript/hexen/dragon.txt +++ b/wadsrc/static/zscript/hexen/dragon.txt @@ -311,7 +311,7 @@ class DragonFireball : Actor DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "DragonFireballExplode"; } @@ -365,7 +365,7 @@ class DragonExplosion : Actor +NOBLOCKMAP +NOTELEPORT +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "DragonFireballExplode"; } diff --git a/wadsrc/static/zscript/hexen/fighteraxe.txt b/wadsrc/static/zscript/hexen/fighteraxe.txt index d20a5fc35..61e509744 100644 --- a/wadsrc/static/zscript/hexen/fighteraxe.txt +++ b/wadsrc/static/zscript/hexen/fighteraxe.txt @@ -307,7 +307,7 @@ class AxePuffGlow : AxePuff Default { +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Alpha 1; } diff --git a/wadsrc/static/zscript/hexen/fighterquietus.txt b/wadsrc/static/zscript/hexen/fighterquietus.txt index c3e5f9b2d..b935f8e11 100644 --- a/wadsrc/static/zscript/hexen/fighterquietus.txt +++ b/wadsrc/static/zscript/hexen/fighterquietus.txt @@ -168,7 +168,7 @@ class FSwordMissile : Actor Damage 8; Projectile; +EXTREMEDEATH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "FighterSwordExplode"; Obituary "$OB_MPFWEAPQUIETUS"; diff --git a/wadsrc/static/zscript/hexen/firedemon.txt b/wadsrc/static/zscript/hexen/firedemon.txt index 65dff9544..e10156402 100644 --- a/wadsrc/static/zscript/hexen/firedemon.txt +++ b/wadsrc/static/zscript/hexen/firedemon.txt @@ -436,7 +436,7 @@ class FireDemonMissile : Actor Projectile; RenderStyle "Add"; DeathSound "FireDemonMissileHit"; - +ZDOOMADD + +ZDOOMTRANS } States { diff --git a/wadsrc/static/zscript/hexen/flame.txt b/wadsrc/static/zscript/hexen/flame.txt index b4574031b..b11e5c2d5 100644 --- a/wadsrc/static/zscript/hexen/flame.txt +++ b/wadsrc/static/zscript/hexen/flame.txt @@ -5,7 +5,7 @@ class FlameSmallTemp : Actor Default { +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -29,7 +29,7 @@ class FlameLargeTemp : Actor Default { +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -64,7 +64,7 @@ class FlameSmall : SwitchableDecoration { +NOTELEPORT +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS Radius 15; RenderStyle "Add"; } @@ -98,7 +98,7 @@ class FlameLarge : SwitchableDecoration { +NOTELEPORT +INVISIBLE - +ZDOOMADD + +ZDOOMTRANS Radius 15; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/hexen/heresiarch.txt b/wadsrc/static/zscript/hexen/heresiarch.txt index fd9176a61..ffb26b136 100644 --- a/wadsrc/static/zscript/hexen/heresiarch.txt +++ b/wadsrc/static/zscript/hexen/heresiarch.txt @@ -1125,7 +1125,7 @@ class SorcSpark1 : Actor +NOBLOCKMAP +DROPOFF +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/hexen/magelightning.txt b/wadsrc/static/zscript/hexen/magelightning.txt index a70eeb8e1..a4b23706b 100644 --- a/wadsrc/static/zscript/hexen/magelightning.txt +++ b/wadsrc/static/zscript/hexen/magelightning.txt @@ -165,7 +165,7 @@ class LightningCeiling : Lightning Damage 8; Projectile; +CEILINGHUGGER - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -320,7 +320,7 @@ class LightningFloor : LightningCeiling { -CEILINGHUGGER +FLOORHUGGER - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } @@ -376,7 +376,7 @@ class LightningZap : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPMWEAPLIGHTNING"; } diff --git a/wadsrc/static/zscript/hexen/scriptprojectiles.txt b/wadsrc/static/zscript/hexen/scriptprojectiles.txt index eebb89b54..819e38e26 100644 --- a/wadsrc/static/zscript/hexen/scriptprojectiles.txt +++ b/wadsrc/static/zscript/hexen/scriptprojectiles.txt @@ -11,7 +11,7 @@ class FireBall : Actor DamageType "Fire"; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "Fireball"; } diff --git a/wadsrc/static/zscript/hexen/serpent.txt b/wadsrc/static/zscript/hexen/serpent.txt index 11bb01fb9..fa1b53d6c 100644 --- a/wadsrc/static/zscript/hexen/serpent.txt +++ b/wadsrc/static/zscript/hexen/serpent.txt @@ -317,7 +317,7 @@ class SerpentFX : Actor Damage 4; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DeathSound "SerpentFXHit"; } diff --git a/wadsrc/static/zscript/raven/minotaur.txt b/wadsrc/static/zscript/raven/minotaur.txt index 14d18a19a..b44684cb6 100644 --- a/wadsrc/static/zscript/raven/minotaur.txt +++ b/wadsrc/static/zscript/raven/minotaur.txt @@ -655,7 +655,7 @@ class MinotaurFX1 : Actor Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/sentinel.txt b/wadsrc/static/zscript/strife/sentinel.txt index 268cd47da..190111be7 100644 --- a/wadsrc/static/zscript/strife/sentinel.txt +++ b/wadsrc/static/zscript/strife/sentinel.txt @@ -97,7 +97,7 @@ class SentinelFX1 : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; } diff --git a/wadsrc/static/zscript/strife/spectral.txt b/wadsrc/static/zscript/strife/spectral.txt index 8fa4cc44a..bc7f11f3b 100644 --- a/wadsrc/static/zscript/strife/spectral.txt +++ b/wadsrc/static/zscript/strife/spectral.txt @@ -112,7 +112,7 @@ class SpectralLightningBase : Actor +ACTIVATEIMPACT +ACTIVATEPCROSS +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/sigil"; @@ -258,7 +258,7 @@ class SpectralLightningHTail : Actor +NOBLOCKMAP +NOGRAVITY +DROPOFF - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/strifestuff.txt b/wadsrc/static/zscript/strife/strifestuff.txt index 04f364c75..a26e5b697 100644 --- a/wadsrc/static/zscript/strife/strifestuff.txt +++ b/wadsrc/static/zscript/strife/strifestuff.txt @@ -632,7 +632,7 @@ class TeleportSwirl : Actor Default { +NOBLOCKMAP - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Alpha 0.25; } diff --git a/wadsrc/static/zscript/strife/strifeweapons.txt b/wadsrc/static/zscript/strife/strifeweapons.txt index e0d5f8f13..15f5dea4a 100644 --- a/wadsrc/static/zscript/strife/strifeweapons.txt +++ b/wadsrc/static/zscript/strife/strifeweapons.txt @@ -40,7 +40,7 @@ class StrifeSpark : StrifePuff { Default { - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; } States diff --git a/wadsrc/static/zscript/strife/thingstoblowup.txt b/wadsrc/static/zscript/strife/thingstoblowup.txt index abc032093..f18e783f7 100644 --- a/wadsrc/static/zscript/strife/thingstoblowup.txt +++ b/wadsrc/static/zscript/strife/thingstoblowup.txt @@ -49,7 +49,7 @@ class Bang4Cloud : Actor { +NOBLOCKMAP +NOGRAVITY - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; VSpeed 1; } diff --git a/wadsrc/static/zscript/strife/weaponflamer.txt b/wadsrc/static/zscript/strife/weaponflamer.txt index 521cbc0c5..1c7a0873a 100644 --- a/wadsrc/static/zscript/strife/weaponflamer.txt +++ b/wadsrc/static/zscript/strife/weaponflamer.txt @@ -85,7 +85,7 @@ class FlameMissile : Actor Projectile; -NOGRAVITY +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/flamethrower"; diff --git a/wadsrc/static/zscript/strife/weapongrenade.txt b/wadsrc/static/zscript/strife/weapongrenade.txt index eebf028db..8d6a12b2d 100644 --- a/wadsrc/static/zscript/strife/weapongrenade.txt +++ b/wadsrc/static/zscript/strife/weapongrenade.txt @@ -217,7 +217,7 @@ class PhosphorousFire : Actor +NOTELEPORT +NODAMAGETHRUST +DONTSPLASH - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPPHOSPHOROUSGRENADE"; } diff --git a/wadsrc/static/zscript/strife/weaponmauler.txt b/wadsrc/static/zscript/strife/weaponmauler.txt index 4ee9e1baf..cc4e7c30c 100644 --- a/wadsrc/static/zscript/strife/weaponmauler.txt +++ b/wadsrc/static/zscript/strife/weaponmauler.txt @@ -181,7 +181,7 @@ class MaulerPuff : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS - +ZDOOMADD + +ZDOOMTRANS RenderStyle "Add"; DamageType "Disintegrate"; } @@ -207,7 +207,7 @@ class MaulerTorpedo : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/mauler2fire"; @@ -270,7 +270,7 @@ class MaulerTorpedoWave : Actor DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE - +ZDOOMADD + +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; Obituary "$OB_MPMAULER"; From ede15da98c6100ebd0cdcf7cb0912295883cc299 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 1 Jun 2017 14:17:49 -0400 Subject: [PATCH 43/82] - fixed: missed the golden wand puff for the +ZDOOMTRANS flag --- wadsrc/static/zscript/heretic/weaponwand.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/heretic/weaponwand.txt b/wadsrc/static/zscript/heretic/weaponwand.txt index 62d46a240..aa08f5c66 100644 --- a/wadsrc/static/zscript/heretic/weaponwand.txt +++ b/wadsrc/static/zscript/heretic/weaponwand.txt @@ -186,6 +186,7 @@ class GoldWandPuff1 : Actor +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS + +ZDOOMTRANS RenderStyle "Add"; } From 579febb6f85307db838eb77ddd81482fc2dffe60 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 2 Jun 2017 12:36:29 -0400 Subject: [PATCH 44/82] - added menu option for r_vanillatrans --- wadsrc/static/language.enu | 2 ++ wadsrc/static/menudef.txt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index f12fab551..09bc6580f 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1815,6 +1815,7 @@ DSPLYMNU_SKYMODE = "Sky render mode"; DSPLYMNU_LINEARSKY = "Linear skies"; DSPLYMNU_GZDFULLBRIGHT = "Fullbright overrides sector color"; DSPLYMNU_DRAWFUZZ = "Use fuzz effect"; +DSPLYMNU_OLDTRANS = "Classic Transparency"; DSPLYMNU_TRANSSOUL = "Lost Soul translucency"; DSPLYMNU_FAKECONTRAST = "Use fake contrast"; DSPLYMNU_ROCKETTRAILS = "Rocket Trails"; @@ -2367,6 +2368,7 @@ OPTVAL_HWPOLY = "OpenGL-Accelerated"; OPTVAL_SWDOOM = "Doom Software Renderer"; OPTVAL_DEDICATED = "High-Performance"; OPTVAL_INTEGRATED = "Power-Saving"; +OPTVAL_VANILLA = "Vanilla"; // Colors C_BRICK = "\cabrick"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index e27c98a29..b1a602665 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -690,6 +690,12 @@ OptionValue Fuzziness 2.0, "$OPTVAL_SHADOW" } +OptionValue VanillaTrans +{ + 0.0, "$OPTVAL_ZDOOM" + 1.0, "$OPTVAL_VANILLA" +} + OptionValue GPUSwitch { 0.0, "$OPTVAL_DEFAULT" @@ -750,6 +756,7 @@ OptionMenu "VideoOptions" } Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness" + Option "$DSPLYMNU_OLDTRANS", "r_vanillatrans", "VanillaTrans" Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2 Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast" Option "$DSPLYMNU_ROCKETTRAILS", "cl_rockettrails", "RocketTrailTypes" From 9abf866241411c3320eaae938842d53c5e5d4018 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 2 Jun 2017 12:36:29 -0400 Subject: [PATCH 45/82] - added menu option for r_vanillatrans --- wadsrc/static/language.enu | 2 ++ wadsrc/static/menudef.txt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 4ab1de2ba..dcc7c4068 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1815,6 +1815,7 @@ DSPLYMNU_SKYMODE = "Sky render mode"; DSPLYMNU_LINEARSKY = "Linear skies"; DSPLYMNU_GZDFULLBRIGHT = "Fullbright overrides sector color"; DSPLYMNU_DRAWFUZZ = "Use fuzz effect"; +DSPLYMNU_OLDTRANS = "Classic Transparency"; DSPLYMNU_TRANSSOUL = "Lost Soul translucency"; DSPLYMNU_FAKECONTRAST = "Use fake contrast"; DSPLYMNU_ROCKETTRAILS = "Rocket Trails"; @@ -2367,6 +2368,7 @@ OPTVAL_HWPOLY = "OpenGL-Accelerated"; OPTVAL_SWDOOM = "Doom Software Renderer"; OPTVAL_DEDICATED = "High-Performance"; OPTVAL_INTEGRATED = "Power-Saving"; +OPTVAL_VANILLA = "Vanilla"; // Colors C_BRICK = "\cabrick"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 4666a0176..c6b610a5d 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -690,6 +690,12 @@ OptionValue Fuzziness 2.0, "$OPTVAL_SHADOW" } +OptionValue VanillaTrans +{ + 0.0, "$OPTVAL_ZDOOM" + 1.0, "$OPTVAL_VANILLA" +} + OptionValue GPUSwitch { 0.0, "$OPTVAL_DEFAULT" @@ -750,6 +756,7 @@ OptionMenu "VideoOptions" } Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness" + Option "$DSPLYMNU_OLDTRANS", "r_vanillatrans", "VanillaTrans" Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2 Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast" Option "$DSPLYMNU_ROCKETTRAILS", "cl_rockettrails", "RocketTrailTypes" From 9871117f56a4b6afb2eef0601f696598d5c660df Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 2 Jun 2017 12:41:03 -0400 Subject: [PATCH 46/82] - fixed: missed the teleport fog --- wadsrc/static/zscript/shared/teleport.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/shared/teleport.txt b/wadsrc/static/zscript/shared/teleport.txt index dd43bb1fa..f558b46a6 100644 --- a/wadsrc/static/zscript/shared/teleport.txt +++ b/wadsrc/static/zscript/shared/teleport.txt @@ -6,6 +6,7 @@ class TeleportFog : Actor +NOBLOCKMAP +NOTELEPORT +NOGRAVITY + +ZDOOMTRANS RenderStyle "Add"; } States From 9b3d11ae19fe45e5edd5a20f839fdb56a75f0e3d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 2 Jun 2017 12:41:03 -0400 Subject: [PATCH 47/82] - fixed: missed the teleport fog --- wadsrc/static/zscript/shared/teleport.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/shared/teleport.txt b/wadsrc/static/zscript/shared/teleport.txt index dd43bb1fa..f558b46a6 100644 --- a/wadsrc/static/zscript/shared/teleport.txt +++ b/wadsrc/static/zscript/shared/teleport.txt @@ -6,6 +6,7 @@ class TeleportFog : Actor +NOBLOCKMAP +NOTELEPORT +NOGRAVITY + +ZDOOMTRANS RenderStyle "Add"; } States From 28821e5eca718e3e1c9f632adbf93b335f897965 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Fri, 2 Jun 2017 16:57:37 -0400 Subject: [PATCH 48/82] - condense all of unloved/2.pk3's compatibility entries together since they are all the same --- wadsrc/static/compatibility.txt | 36 --------------------------------- 1 file changed, 36 deletions(-) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index 2e9a7f1f4..8863326e1 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -649,50 +649,14 @@ B68EB7CFB4CC481796E2919B9C16DFBD // Moc11.wad e1m6 } 1ED329858AB154C55878DA1C11A4F100 // unloved.pk3:unlovedmaps.wad map01 -{ - clipmidtex -} - FA23E72FA955E66EC68609F72C0BA71E // unloved.pk3:unlovedmaps.wad map02 -{ - clipmidtex -} - 41BEC1F643CFEEC997AF98276A05EC88 // unloved.pk3:unlovedmaps.wad map03 -{ - clipmidtex -} - AF9A6370BE562584BC11165ECF364713 // unloved.pk3:unlovedmaps.wad map04 -{ - clipmidtex -} - DC96228097DD004C40CCB1DB14A91EAA // unloved.pk3:unlovedmaps.wad map05 -{ - clipmidtex -} - 261E64897A572C8DB8DC041E64BE27AD // unloved2beta1.pk3:u2_new2maps2.wad map06 -{ - clipmidtex -} - 04800B1F35E8C036EBABC8C616402927 // unloved2beta1.pk3:u2_new2maps2.wad map07 -{ - clipmidtex -} - 9E54F70648A77BBD090FF78A3AA05367 // unloved2beta1.pk3:u2_new2maps2.wad map08 -{ - clipmidtex -} - 72E9E0F41F691B7F956E62F35B4A617F // unloved2beta1.pk3:u2_new2maps2.wad map09 -{ - clipmidtex -} - 3D3FE412E87AD8B2316DAEC9E25F2E5D // unloved2beta1.pk3:u2_new2maps2.wad map10 { clipmidtex From 9af370f51ec04f9c780dc79e5339b7ee5b43eade Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 3 Jun 2017 20:00:53 -0400 Subject: [PATCH 49/82] - Added auto-detection scheme for r_vanillatrans It now works the following way: (0) - Force off (ZDoom defaults) (1) - Force on (Doom defaults) (2) - Auto off (Prefer ZDoom defaults - if DEHACKED is detected with no ZSCRIPT it will turn on) (default) (3) - Auto on (Prefer Doom defaults - if DECORATE is detected with no ZSCRIPT it will turn off) --- src/CMakeLists.txt | 1 + src/d_main.cpp | 4 ++ src/gl/scene/gl_sprite.cpp | 4 +- src/polyrenderer/scene/poly_sprite.cpp | 4 +- src/r_data/r_vanillatrans.cpp | 67 ++++++++++++++++++++++++++ src/r_data/r_vanillatrans.h | 3 ++ src/r_data/renderstyle.cpp | 1 - src/swrenderer/things/r_sprite.cpp | 4 +- wadsrc/static/language.enu | 4 ++ wadsrc/static/menudef.txt | 6 ++- 10 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 src/r_data/r_vanillatrans.cpp create mode 100644 src/r_data/r_vanillatrans.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a9b2aa87..10fe6e84d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1071,6 +1071,7 @@ set (PCH_SOURCES r_data/voxels.cpp r_data/renderstyle.cpp r_data/r_interpolate.cpp + r_data/r_vanillatrans.cpp scripting/symbols.cpp scripting/types.cpp scripting/thingdef.cpp diff --git a/src/d_main.cpp b/src/d_main.cpp index 650d99ae8..b4b6947a6 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -116,6 +116,7 @@ #include "r_utility.h" #include "vm.h" #include "types.h" +#include "r_data/r_vanillatrans.h" EXTERN_CVAR(Bool, hud_althud) void DrawHUD(); @@ -2606,6 +2607,9 @@ void D_DoomMain (void) D_CheckNetGame (); } + // [SP] Force vanilla transparency auto-detection to re-detect our game lumps now + UpdateVanillaTransparency(); + // [RH] Lock any cvars that should be locked now that we're // about to begin the game. FBaseCVar::EnableNoSet (); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 8d053e81c..d50c5722e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -39,6 +39,7 @@ #include "g_levellocals.h" #include "events.h" #include "actorinlines.h" +#include "r_data/r_vanillatrans.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -75,7 +76,6 @@ CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) } EXTERN_CVAR (Float, transsouls) -EXTERN_CVAR (Bool, r_vanillatrans) extern TArray sprites; extern TArray SpriteFrames; @@ -993,7 +993,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { trans = 1.f; } - if (r_vanillatrans) + if (UseVanillaTransparency()) { // [SP] "canonical transparency" - with the flip of a CVar, disable transparency for Doom objects, // and disable 'additive' translucency for certain objects from other games. diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index ba91f005b..10d6772af 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -28,10 +28,10 @@ #include "poly_sprite.h" #include "polyrenderer/poly_renderer.h" #include "polyrenderer/scene/poly_light.h" +#include "r_data/r_vanillatrans.h" EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, r_drawfuzz) -EXTERN_CVAR (Bool, r_vanillatrans) bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) { @@ -146,7 +146,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetClipPlane(clipPlane); - if ((thing->renderflags & RF_ZDOOMTRANS) && r_vanillatrans) + if ((thing->renderflags & RF_ZDOOMTRANS) && UseVanillaTransparency()) args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite); else args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite); diff --git a/src/r_data/r_vanillatrans.cpp b/src/r_data/r_vanillatrans.cpp new file mode 100644 index 000000000..3c40e9dea --- /dev/null +++ b/src/r_data/r_vanillatrans.cpp @@ -0,0 +1,67 @@ + +#include "templates.h" +#include "c_cvars.h" +#include "w_wad.h" +#ifdef _DEBUG +#include "c_dispatch.h" +#endif + +CVAR (Int, r_vanillatrans, 2, CVAR_ARCHIVE) + +namespace +{ + bool firstTime = true; + bool foundDehacked = false; + bool foundDecorate = false; + bool foundZScript = false; +} +#ifdef _DEBUG +CCMD (debug_checklumps) +{ + Printf("firstTime: %d\n", firstTime); + Printf("foundDehacked: %d\n", foundDehacked); + Printf("foundDecorate: %d\n", foundDecorate); + Printf("foundZScript: %d\n", foundZScript); +} +#endif + +void UpdateVanillaTransparency() +{ + firstTime = true; +} + +bool UseVanillaTransparency() +{ + if (firstTime) + { + int lastlump = 0; + Wads.FindLump("ZSCRIPT", &lastlump); // ignore first ZScript + if (Wads.FindLump("ZSCRIPT", &lastlump) == -1) // no loaded ZScript + { + lastlump = 0; + foundDehacked = Wads.FindLump("DEHACKED", &lastlump) != -1; + lastlump = 0; + foundDecorate = Wads.FindLump("DECORATE", &lastlump) != -1; + foundZScript = false; + } + else + { + foundZScript = true; + foundDehacked = false; + foundDecorate = false; + } + firstTime = false; + } + + switch (r_vanillatrans) + { + case 0: return false; + case 1: return true; + default: + if (foundDehacked) + return true; + if (foundDecorate) + return false; + return r_vanillatrans == 3; + } +} diff --git a/src/r_data/r_vanillatrans.h b/src/r_data/r_vanillatrans.h new file mode 100644 index 000000000..61d988074 --- /dev/null +++ b/src/r_data/r_vanillatrans.h @@ -0,0 +1,3 @@ + +void UpdateVanillaTransparency(); +bool UseVanillaTransparency(); \ No newline at end of file diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index fc1905f91..987de82b9 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -38,7 +38,6 @@ #include "serializer.h" CVAR (Bool, r_drawtrans, true, 0) -CVAR (Bool, r_vanillatrans, false, CVAR_ARCHIVE) CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) // Convert legacy render styles to flexible render styles. diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index d067b9007..f28cff787 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -65,10 +65,10 @@ #include "swrenderer/r_memory.h" #include "swrenderer/r_renderthread.h" #include "a_dynlight.h" +#include "r_data/r_vanillatrans.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) EXTERN_CVAR(Bool, gl_light_sprites) -EXTERN_CVAR (Bool, r_vanillatrans) namespace swrenderer { @@ -213,7 +213,7 @@ namespace swrenderer if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->RenderStyle = thing->RenderStyle; - if (r_vanillatrans) + if (UseVanillaTransparency()) { if (thing->renderflags & RF_ZDOOMTRANS) vis->RenderStyle = LegacyRenderStyles[STYLE_Normal]; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 09bc6580f..fd9ef8969 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2369,6 +2369,10 @@ OPTVAL_SWDOOM = "Doom Software Renderer"; OPTVAL_DEDICATED = "High-Performance"; OPTVAL_INTEGRATED = "Power-Saving"; OPTVAL_VANILLA = "Vanilla"; +OPTVAL_VTFZDOOM = "ZDoom (Forced)"; +OPTVAL_VTFVANILLA = "Vanilla (Forced)"; +OPTVAL_VTAZDOOM = "Auto (Vanilla Preferred)"; +OPTVAL_VTAVANILLA = "Auto (ZDoom Preferred)"; // Colors C_BRICK = "\cabrick"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b1a602665..68763a552 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -692,8 +692,10 @@ OptionValue Fuzziness OptionValue VanillaTrans { - 0.0, "$OPTVAL_ZDOOM" - 1.0, "$OPTVAL_VANILLA" + 0.0, "$OPTVAL_VTFZDOOM" + 1.0, "$OPTVAL_VTFVANILLA" + 0.0, "$OPTVAL_VTAZDOOM" + 1.0, "$OPTVAL_VTAVANILLA" } OptionValue GPUSwitch From c3808bbc2d142d2350db231f34c8127995d15ff9 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 3 Jun 2017 20:17:44 -0400 Subject: [PATCH 50/82] - Add licenses to r_vanillatrans files --- src/r_data/r_vanillatrans.cpp | 26 ++++++++++++++++++++++++++ src/r_data/r_vanillatrans.h | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/r_data/r_vanillatrans.cpp b/src/r_data/r_vanillatrans.cpp index 3c40e9dea..01d996d49 100644 --- a/src/r_data/r_vanillatrans.cpp +++ b/src/r_data/r_vanillatrans.cpp @@ -1,3 +1,29 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2017 Rachael Alexanderson +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// +/* +** r_vanillatrans.cpp +** Figures out whether to turn off transparency for certain native game objects +** +**/ #include "templates.h" #include "c_cvars.h" diff --git a/src/r_data/r_vanillatrans.h b/src/r_data/r_vanillatrans.h index 61d988074..5bf1892c7 100644 --- a/src/r_data/r_vanillatrans.h +++ b/src/r_data/r_vanillatrans.h @@ -1,3 +1,25 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2017 Rachael Alexanderson +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + void UpdateVanillaTransparency(); bool UseVanillaTransparency(); \ No newline at end of file From e5eb173165ff85e993298be88bef77f17ab2498e Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 4 Jun 2017 04:56:16 -0400 Subject: [PATCH 51/82] - fixed minor menudef mistake --- wadsrc/static/menudef.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 3f9307382..1641982d9 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -694,8 +694,8 @@ OptionValue VanillaTrans { 0.0, "$OPTVAL_VTFZDOOM" 1.0, "$OPTVAL_VTFVANILLA" - 0.0, "$OPTVAL_VTAZDOOM" - 1.0, "$OPTVAL_VTAVANILLA" + 2.0, "$OPTVAL_VTAZDOOM" + 3.0, "$OPTVAL_VTAVANILLA" } OptionValue GPUSwitch From 291b36f7b52bdd3152fea44b628042c4150dc5b8 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 4 Jun 2017 08:01:02 -0400 Subject: [PATCH 52/82] - Fix startup errors --- src/r_data/renderstyle.cpp | 1 - src/version.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index fc1905f91..987de82b9 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -38,7 +38,6 @@ #include "serializer.h" CVAR (Bool, r_drawtrans, true, 0) -CVAR (Bool, r_vanillatrans, false, CVAR_ARCHIVE) CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) // Convert legacy render styles to flexible render styles. diff --git a/src/version.h b/src/version.h index 27d5894ac..ccfa1fb7b 100644 --- a/src/version.h +++ b/src/version.h @@ -52,8 +52,8 @@ const char *GetVersionString(); #endif // The version as seen in the Windows resource -#define RC_FILEVERSION 1,3,9999,0 -#define RC_PRODUCTVERSION 1,3,9999,0 +#define RC_FILEVERSION 1,4,9999,0 +#define RC_PRODUCTVERSION 1,4,9999,0 #define RC_PRODUCTVERSION2 VERSIONSTR // These are for content versioning. The current state is '3.2'. #define VER_MAJOR 3 From 17fc58f71248d019cc07882c2916774cff87222c Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sun, 4 Jun 2017 09:59:37 -0500 Subject: [PATCH 53/82] Added PSPF_MIRROR to software renderer. --- src/swrenderer/things/r_playersprite.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index 9fd4a44e2..e67f5d761 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -240,7 +240,7 @@ namespace swrenderer if (pspr->Flags & PSPF_ADDBOB) { - sx += bobx; + sx += (pspr->Flags & PSPF_MIRROR) ? -bobx : bobx; sy += boby; } @@ -256,17 +256,18 @@ namespace swrenderer double pspriteyscale = pspritexscale * viewport->YaspectMul; double pspritexiscale = 1 / pspritexscale; - // calculate edges of the shape - tx = sx - BASEXCENTER; + int tleft = tex->GetScaledLeftOffset(); + int twidth = tex->GetScaledWidth(); - tx -= tex->GetScaledLeftOffset(); + // calculate edges of the shape + tx = (pspr->Flags & PSPF_MIRROR) ? ((BASEXCENTER - twidth) - (sx - tleft)) : ((sx - BASEXCENTER) - tleft); x1 = xs_RoundToInt(viewport->CenterX + tx * pspritexscale); // off the right side if (x1 > viewwidth) return; - tx += tex->GetScaledWidth(); + tx += twidth; x2 = xs_RoundToInt(viewport->CenterX + tx * pspritexscale); // off the left side From b86aed5b01bc942d3a0e83673d0f1e7467200a45 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Mon, 5 Jun 2017 09:10:48 -0500 Subject: [PATCH 54/82] Added polysoft render support for PSPF_MIRROR. --- src/polyrenderer/scene/poly_playersprite.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/polyrenderer/scene/poly_playersprite.cpp b/src/polyrenderer/scene/poly_playersprite.cpp index ac8af89ce..e3563976c 100644 --- a/src/polyrenderer/scene/poly_playersprite.cpp +++ b/src/polyrenderer/scene/poly_playersprite.cpp @@ -232,7 +232,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float if (pspr->Flags & PSPF_ADDBOB) { - sx += bobx; + sx += (pspr->Flags & PSPF_MIRROR) ? -bobx : bobx; sy += boby; } @@ -248,17 +248,20 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float double pspriteyscale = pspritexscale * yaspectMul; double pspritexiscale = 1 / pspritexscale; - // calculate edges of the shape - tx = sx - BASEXCENTER; + int tleft = tex->GetScaledLeftOffset(); + int twidth = tex->GetScaledWidth(); + + // calculate edges of the shape + //tx = sx - BASEXCENTER; + tx = (pspr->Flags & PSPF_MIRROR) ? ((BASEXCENTER - twidth) - (sx - tleft)) : ((sx - BASEXCENTER) - tleft); - tx -= tex->GetScaledLeftOffset(); x1 = xs_RoundToInt(viewwindow.centerx + tx * pspritexscale); // off the right side if (x1 > viewwidth) return; - tx += tex->GetScaledWidth(); + tx += twidth; x2 = xs_RoundToInt(viewwindow.centerx + tx * pspritexscale); // off the left side From aa2a39da19c9f8452418a2e082b0362c7e5f7ad1 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 2 Jul 2017 16:35:40 -0400 Subject: [PATCH 55/82] Revert "- Remove r_sprite_distance_cull" This reverts commit 44546ce16a0e2d59a4141571f0f936295bc0d950. --- src/swrenderer/scene/r_opaque_pass.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 7d6d6b461..bebb9580f 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -72,6 +72,20 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); EXTERN_CVAR(Bool, r_drawvoxels); +namespace { double sprite_distance_cull = 1e16; } + +CUSTOM_CVAR(Float, r_sprite_distance_cull, 5000.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (r_sprite_distance_cull > 0.0) + { + sprite_distance_cull = r_sprite_distance_cull * r_sprite_distance_cull; + } + else + { + sprite_distance_cull = 1e16; + } +} + namespace swrenderer { RenderOpaquePass::RenderOpaquePass(RenderThread *thread) : renderline(thread) @@ -936,6 +950,10 @@ namespace swrenderer if (!renderportal->CurrentPortalInSkybox && renderportal->CurrentPortal && !!P_PointOnLineSidePrecise(thing->Pos(), renderportal->CurrentPortal->dst)) return false; + double distanceSquared = (thing->Pos() - Thread->Viewport->viewpoint.Pos).LengthSquared(); + if (distanceSquared > sprite_distance_cull) + return false; + return true; } From 63da6e70c0d4f2bbd05186cd14e781c6def9d208 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 25 Jun 2017 19:33:07 -0400 Subject: [PATCH 56/82] - added a vid_saturation control - works in postprocessing, only. --- src/gl/renderer/gl_postprocess.cpp | 3 +++ src/gl/shaders/gl_presentshader.cpp | 1 + src/gl/shaders/gl_presentshader.h | 1 + src/gl/stereo3d/gl_interleaved3d.cpp | 2 ++ src/gl/system/gl_menu.cpp | 8 ++++++++ wadsrc/static/shaders/glsl/present.fp | 4 +++- 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index acc0a08b4..92dd0bc80 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -149,6 +149,7 @@ CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) +EXTERN_CVAR(Float, vid_saturation) void FGLRenderer::RenderScreenQuad() @@ -858,12 +859,14 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma) mPresentShader->InvGamma.Set(1.0f); mPresentShader->Contrast.Set(1.0f); mPresentShader->Brightness.Set(0.0f); + mPresentShader->Saturation.Set(1.0f); } else { mPresentShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + mPresentShader->Saturation.Set(clamp(vid_saturation, -3.0f, 3.f)); } mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); RenderScreenQuad(); diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 5fe040db9..8fdf623d9 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -46,6 +46,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program InvGamma.Init(mShader, "InvGamma"); Contrast.Init(mShader, "Contrast"); Brightness.Init(mShader, "Brightness"); + Saturation.Init(mShader, "Saturation"); Scale.Init(mShader, "UVScale"); } diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h index dcf42cdf8..acb3f50eb 100644 --- a/src/gl/shaders/gl_presentshader.h +++ b/src/gl/shaders/gl_presentshader.h @@ -12,6 +12,7 @@ public: FBufferedUniform1f InvGamma; FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; + FBufferedUniform1f Saturation; FBufferedUniform2f Scale; protected: diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 40aed85a9..686802e6a 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -41,6 +41,7 @@ #include "gl/system/gl_framebuffer.h" #include "gl/shaders/gl_present3dRowshader.h" +EXTERN_CVAR(Float, vid_saturation) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Bool, fullscreen) @@ -106,6 +107,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader) shader.InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); shader.Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); shader.Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + shader.Saturation.Set(clamp(vid_saturation, -3.0f, 3.0f)); } shader.Scale.Set( GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 8dffbc4f2..5813613b4 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -73,6 +73,14 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) } } +CUSTOM_CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (screen != NULL) + { + screen->SetGamma(Gamma); //SetContrast (self); + } +} + // Do some tinkering with the menus so that certain options only appear // when they are actually valid. diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index 31c1217cb..3683d6bd1 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -6,10 +6,12 @@ uniform sampler2D InputTexture; uniform float InvGamma; uniform float Contrast; uniform float Brightness; +uniform float Saturation; vec4 ApplyGamma(vec4 c) { - vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; + vec3 valgray = (0.3 * c.r + 0.59 * c.g + 0.11 * c.b) * (1 - Saturation) + c.rgb * Saturation; + vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5; val += Brightness * 0.5; val = pow(max(val, vec3(0.0)), vec3(InvGamma)); return vec4(val, c.a); From bd02893ce727c12494a07a4ef5c62fe46b8d5448 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 26 Jun 2017 03:50:49 -0400 Subject: [PATCH 57/82] - expanded hard limits for saturation to -15.0/15.0 - added menu option for saturation - tried to get the new saturation shader to consume less GPU power by turning it off when it is 1.0 --- src/gl/renderer/gl_postprocess.cpp | 2 +- src/gl/stereo3d/gl_interleaved3d.cpp | 2 +- wadsrc/static/language.enu | 3 ++- wadsrc/static/menudef.txt | 9 +++++---- wadsrc/static/shaders/glsl/present.fp | 6 +++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 92dd0bc80..efc9e1911 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -866,7 +866,7 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma) mPresentShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); - mPresentShader->Saturation.Set(clamp(vid_saturation, -3.0f, 3.f)); + mPresentShader->Saturation.Set(clamp(vid_saturation, -15.0f, 15.f)); } mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); RenderScreenQuad(); diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index 686802e6a..a499f6e0e 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -107,7 +107,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader) shader.InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); shader.Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); shader.Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); - shader.Saturation.Set(clamp(vid_saturation, -3.0f, 3.0f)); + shader.Saturation.Set(clamp(vid_saturation, -15.0f, 15.0f)); } shader.Scale.Set( GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index e07f4bf7d..bb428fa60 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2657,7 +2657,8 @@ MUSIC_DM2INT = "dm2int"; DSPLYMNU_GLOPT = "OpenGL Renderer"; DSPLYMNU_SWOPT = "Software Renderer"; DSPLYMNU_GAMMA = "Gamma correction"; -DSPLYMNU_CONTRAST ="Contrast"; +DSPLYMNU_CONTRAST = "Contrast"; +DSPLYMNU_SATURATION = "Saturation"; DSPLYMNU_HWGAMMA = "Hardware Gamma"; // OpenGL Options diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index a7e6cc4e9..e6183c15c 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -734,14 +734,15 @@ OptionMenu "VideoOptions" protected Submenu "$DSPLYMNU_GLOPT", "OpenGLOptions" Submenu "$DSPLYMNU_SWOPT", "SWROptions" - Submenu "$GLMNU_DYNLIGHT", "GLLightOptions" + Submenu "$GLMNU_DYNLIGHT", "GLLightOptions" Submenu "$DSPLYMNU_SCOREBOARD", "ScoreboardOptions" 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", "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_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 + Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25 Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes" Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index 3683d6bd1..9a53e0eb5 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -10,7 +10,11 @@ uniform float Saturation; vec4 ApplyGamma(vec4 c) { - vec3 valgray = (0.3 * c.r + 0.59 * c.g + 0.11 * c.b) * (1 - Saturation) + c.rgb * Saturation; + vec3 valgray; + if (Saturation != 1.0) // attempt to cool things a bit, this calculation makes the GPU run really hot + valgray = (0.3 * c.r + 0.59 * c.g + 0.11 * c.b) * (1 - Saturation) + c.rgb * Saturation; + else + valgray = c.rgb; vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5; val += Brightness * 0.5; val = pow(max(val, vec3(0.0)), vec3(InvGamma)); From a2c9cb81568f43fcce6fad9d444d901cd40548bc Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 26 Jun 2017 04:08:22 -0400 Subject: [PATCH 58/82] - increased menu readability --- wadsrc/static/menudef.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index e6183c15c..f633e150e 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -742,9 +742,9 @@ OptionMenu "VideoOptions" protected Slider "$DSPLYMNU_GAMMA", "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 + Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25, 2 Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes" - + StaticText " " Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" Slider "$DSPLYMNU_BLOODFADE", "blood_fade_scalar", 0.0, 1.0, 0.05, 2 From 0d8b7c55ef1d1a4f6688f770461840c104f7dabb Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 26 Jun 2017 06:33:59 -0400 Subject: [PATCH 59/82] - added a grayscale formula selector --- src/gl/renderer/gl_postprocess.cpp | 2 ++ src/gl/shaders/gl_presentshader.cpp | 1 + src/gl/shaders/gl_presentshader.h | 1 + src/gl/stereo3d/gl_interleaved3d.cpp | 3 +++ src/gl/system/gl_menu.cpp | 10 +++++++++- wadsrc/static/shaders/glsl/present.fp | 6 +++++- 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index efc9e1911..21eaf874d 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -150,6 +150,7 @@ CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Float, vid_saturation) +EXTERN_CVAR(Int, gl_satformula) void FGLRenderer::RenderScreenQuad() @@ -867,6 +868,7 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma) mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); mPresentShader->Saturation.Set(clamp(vid_saturation, -15.0f, 15.f)); + mPresentShader->GrayFormula.Set(static_cast(gl_satformula)); } mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); RenderScreenQuad(); diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp index 8fdf623d9..06056f539 100644 --- a/src/gl/shaders/gl_presentshader.cpp +++ b/src/gl/shaders/gl_presentshader.cpp @@ -47,6 +47,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program Contrast.Init(mShader, "Contrast"); Brightness.Init(mShader, "Brightness"); Saturation.Init(mShader, "Saturation"); + GrayFormula.Init(mShader, "GrayFormula"); Scale.Init(mShader, "UVScale"); } diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h index acb3f50eb..377a6a4f2 100644 --- a/src/gl/shaders/gl_presentshader.h +++ b/src/gl/shaders/gl_presentshader.h @@ -13,6 +13,7 @@ public: FBufferedUniform1f Contrast; FBufferedUniform1f Brightness; FBufferedUniform1f Saturation; + FBufferedUniform1i GrayFormula; FBufferedUniform2f Scale; protected: diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index a499f6e0e..4729fbf77 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -44,6 +44,7 @@ EXTERN_CVAR(Float, vid_saturation) EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) +EXTERN_CVAR(Int, gl_satformula) EXTERN_CVAR(Bool, fullscreen) EXTERN_CVAR(Int, win_x) // screen pixel position of left of display window EXTERN_CVAR(Int, win_y) // screen pixel position of top of display window @@ -101,6 +102,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader) shader.InvGamma.Set(1.0f); shader.Contrast.Set(1.0f); shader.Brightness.Set(0.0f); + shader.Saturation.Set(1.0f); } else { @@ -108,6 +110,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader) shader.Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); shader.Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); shader.Saturation.Set(clamp(vid_saturation, -15.0f, 15.0f)); + shader.GrayFormula.Set(static_cast(gl_satformula)); } shader.Scale.Set( GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 5813613b4..489ad4a9d 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -77,7 +77,15 @@ CUSTOM_CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { if (screen != NULL) { - screen->SetGamma(Gamma); //SetContrast (self); + screen->SetGamma(Gamma); + } +} + +CUSTOM_CVAR(Int, gl_satformula, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (screen != NULL) + { + screen->SetGamma(Gamma); } } diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index 9a53e0eb5..eff874ed2 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -7,12 +7,16 @@ uniform float InvGamma; uniform float Contrast; uniform float Brightness; uniform float Saturation; +uniform int GrayFormula; vec4 ApplyGamma(vec4 c) { vec3 valgray; if (Saturation != 1.0) // attempt to cool things a bit, this calculation makes the GPU run really hot - valgray = (0.3 * c.r + 0.59 * c.g + 0.11 * c.b) * (1 - Saturation) + c.rgb * Saturation; + if (GrayFormula == 0) + valgray = vec3(c.r + c.g + c.b) * (1 - Saturation) / 3 + c.rgb * Saturation; + else + valgray = vec3(0.3 * c.r + 0.56 * c.g + 0.14 * c.b) * (1 - Saturation) + c.rgb * Saturation; else valgray = c.rgb; vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5; From b4915d624d8daaeaf8bf03c008a5b3f0c9fb6e37 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 2 Jul 2017 16:59:15 -0400 Subject: [PATCH 60/82] - removed 'cooling' component of the shader since it technically wasn't really functional (guess we have to use a separate shader to do that) - changed the math to use the 'mix' formula --- wadsrc/static/shaders/glsl/present.fp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp index eff874ed2..4690895c2 100644 --- a/wadsrc/static/shaders/glsl/present.fp +++ b/wadsrc/static/shaders/glsl/present.fp @@ -12,13 +12,10 @@ uniform int GrayFormula; vec4 ApplyGamma(vec4 c) { vec3 valgray; - if (Saturation != 1.0) // attempt to cool things a bit, this calculation makes the GPU run really hot - if (GrayFormula == 0) - valgray = vec3(c.r + c.g + c.b) * (1 - Saturation) / 3 + c.rgb * Saturation; - else - valgray = vec3(0.3 * c.r + 0.56 * c.g + 0.14 * c.b) * (1 - Saturation) + c.rgb * Saturation; + if (GrayFormula == 0) + valgray = vec3(c.r + c.g + c.b) * (1 - Saturation) / 3 + c.rgb * Saturation; else - valgray = c.rgb; + valgray = mix(vec3(dot(c.rgb, vec3(0.3,0.56,0.14))), c.rgb, Saturation); vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5; val += Brightness * 0.5; val = pow(max(val, vec3(0.0)), vec3(InvGamma)); From 72517244be12bf4b3d0ec054dec325af0e360bea Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 2 Jul 2017 17:08:01 -0400 Subject: [PATCH 61/82] - set bluramount to 0 by default --- wadsrc/static/mapinfo/chex.txt | 2 +- wadsrc/static/mapinfo/doomcommon.txt | 2 +- wadsrc/static/mapinfo/heretic.txt | 2 +- wadsrc/static/mapinfo/hexen.txt | 2 +- wadsrc/static/mapinfo/strife.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/mapinfo/chex.txt b/wadsrc/static/mapinfo/chex.txt index 4d234b351..87ecf5aa4 100644 --- a/wadsrc/static/mapinfo/chex.txt +++ b/wadsrc/static/mapinfo/chex.txt @@ -38,7 +38,7 @@ gameinfo weaponslot = 7, "LAZDevice" dimcolor = "ff d7 00" dimamount = 0.2 - bluramount = 0.5 + bluramount = 0.0 definventorymaxamount = 25 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/doomcommon.txt b/wadsrc/static/mapinfo/doomcommon.txt index bca27b527..f38d699dc 100644 --- a/wadsrc/static/mapinfo/doomcommon.txt +++ b/wadsrc/static/mapinfo/doomcommon.txt @@ -39,7 +39,7 @@ gameinfo weaponslot = 7, "BFG9000" dimcolor = "ff d7 00" dimamount = 0.2 - bluramount = 0.5 + bluramount = 0.0 definventorymaxamount = 25 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/heretic.txt b/wadsrc/static/mapinfo/heretic.txt index ebb538afd..3481f82af 100644 --- a/wadsrc/static/mapinfo/heretic.txt +++ b/wadsrc/static/mapinfo/heretic.txt @@ -38,7 +38,7 @@ gameinfo weaponslot = 7, "Mace" dimcolor = "00 00 ff" dimamount = 0.2 - bluramount = 0.5 + bluramount = 0 definventorymaxamount = 16 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/hexen.txt b/wadsrc/static/mapinfo/hexen.txt index 7fd6dbba2..64cf3b4f7 100644 --- a/wadsrc/static/mapinfo/hexen.txt +++ b/wadsrc/static/mapinfo/hexen.txt @@ -37,7 +37,7 @@ gameinfo weaponslot = 4, "FWeapQuietus", "CWeapWraithverge", "MWeapBloodscourge" dimcolor = "00 00 ff" dimamount = 0.2 - bluramount = 0.5 + bluramount = 0.0 definventorymaxamount = 25 defaultrespawntime = 12 defaultdropstyle = 1 diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index 0c6d12cca..5d320dd26 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -38,7 +38,7 @@ gameinfo weaponslot = 8, "Sigil" dimcolor = "ff d7 00" dimamount = 0.2 - bluramount = 0.5 + bluramount = 0 definventorymaxamount = 25 defaultrespawntime = 16 defaultdropstyle = 2 From ee6d7cf17e41a153cf2969dd7ff39ac98dedab3b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 3 Jul 2017 01:26:02 +0200 Subject: [PATCH 62/82] - Add initial postprocess shader support to GLDEFS file --- src/gl/renderer/gl_postprocess.cpp | 69 +++++++++++++++ src/gl/renderer/gl_renderer.h | 13 +++ src/gl/shaders/gl_shader.cpp | 131 ++++++++++++++++++----------- 3 files changed, 165 insertions(+), 48 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 06ae5d86b..5fb40b2af 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -149,6 +149,14 @@ CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITC EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) +class PostProcessShaderInstance +{ +public: + FShaderProgram Program; + FBufferedUniformSampler InputTexture; + FBufferedUniformSampler CustomTexture; + FHardwareTexture *HWTexture = nullptr; +}; void FGLRenderer::RenderScreenQuad() { @@ -166,6 +174,67 @@ void FGLRenderer::PostProcessScene(int fixedcm) ColormapScene(fixedcm); LensDistortScene(); ApplyFXAA(); + RunCustomPostProcessShaders("screen"); +} + +void FGLRenderer::RunCustomPostProcessShaders(FString target) +{ + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + + if (shader.Target != target) + continue; + + if (!shader.Instance) + { + shader.Instance = std::make_shared(); + shader.Instance->Program.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); // Hmm, should this use shader.shaderversion? + shader.Instance->Program.Compile(FShaderProgram::Fragment, shader.ShaderLumpName.GetChars(), "", shader.ShaderVersion); + shader.Instance->Program.SetFragDataLocation(0, "FragColor"); + shader.Instance->Program.Link(shader.ShaderLumpName.GetChars()); + shader.Instance->Program.SetAttribLocation(0, "PositionInProjection"); + shader.Instance->InputTexture.Init(shader.Instance->Program, "InputTexture"); + shader.Instance->CustomTexture.Init(shader.Instance->Program, "CustomTexture"); + + if (shader.Texture) + shader.Instance->HWTexture = new FHardwareTexture(shader.Texture->GetWidth(), shader.Texture->GetHeight(), false); + } + + FGLDebug::PushGroup(shader.ShaderLumpName.GetChars()); + + FGLPostProcessState savedState; + savedState.SaveTextureBindings(2); + + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + shader.Instance->Program.Bind(); + + shader.Instance->InputTexture.Set(0); + + if (shader.Instance->HWTexture) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, shader.Instance->HWTexture->GetTextureHandle(0)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glActiveTexture(GL_TEXTURE0); + + shader.Instance->CustomTexture.Set(1); + } + RenderScreenQuad(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mBuffers->NextTexture(); + + FGLDebug::PopGroup(); + } } //----------------------------------------------------------------------------- diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 63168ff24..ce4d749a7 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -42,6 +42,7 @@ class FPresent3DRowShader; class F2DDrawer; class FHardwareTexture; class FShadowMapShader; +class PostProcessShaderInstance; inline float DEG2RAD(float deg) { @@ -85,6 +86,17 @@ enum DM_SKYPORTAL }; +struct PostProcessShader +{ + FString Target; + FString ShaderLumpName; + int ShaderVersion = 0; + FTexture *Texture = nullptr; + std::shared_ptr Instance; +}; + +extern TArray PostProcessShaders; + class FGLRenderer { public: @@ -171,6 +183,7 @@ public: void RenderScreenQuad(); void PostProcessScene(int fixedcm); + void RunCustomPostProcessShaders(FString target); void AmbientOccludeScene(); void UpdateCameraExposure(); void BloomScene(int fixedcm); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 2fdf9fbf3..022cec7d9 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -669,63 +669,98 @@ void gl_DestroyUserShaders() // //========================================================================== +TArray PostProcessShaders; + void gl_ParseHardwareShader(FScanner &sc, int deflump) { - int type = FTexture::TEX_Any; - bool disable_fullbright=false; - bool thiswad = false; - bool iwad = false; - int maplump = -1; - FString maplumpname; - float speed = 1.f; - sc.MustGetString(); - if (sc.Compare("texture")) type = FTexture::TEX_Wall; - else if (sc.Compare("flat")) type = FTexture::TEX_Flat; - else if (sc.Compare("sprite")) type = FTexture::TEX_Sprite; - else sc.UnGet(); - - sc.MustGetString(); - FTextureID no = TexMan.CheckForTexture(sc.String, type); - FTexture *tex = TexMan[no]; - - sc.MustGetToken('{'); - while (!sc.CheckToken('}')) + if (sc.Compare("postprocess")) { sc.MustGetString(); - if (sc.Compare("shader")) + + PostProcessShader shaderdesc; + shaderdesc.Target = sc.String; + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) { sc.MustGetString(); - maplumpname = sc.String; - } - else if (sc.Compare("speed")) - { - sc.MustGetFloat(); - speed = float(sc.Float); - } - } - if (!tex) - { - return; - } - - if (maplumpname.IsNotEmpty()) - { - if (tex->bWarped != 0) - { - Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars()); - return; - } - tex->gl_info.shaderspeed = speed; - for(unsigned i=0;igl_info.shaderindex = i + FIRST_USER_SHADER; - return; + sc.MustGetString(); + shaderdesc.ShaderLumpName = sc.String; + + sc.MustGetNumber(); + shaderdesc.ShaderVersion = sc.Number; + } + else if (sc.Compare("texture")) + { + sc.MustGetString(); + FTextureID no = TexMan.CheckForTexture(sc.String, FTexture::TEX_Wall); + shaderdesc.Texture = TexMan[no]; } } - tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER; - } + + PostProcessShaders.Push(shaderdesc); + } + else + { + int type = FTexture::TEX_Any; + + if (sc.Compare("texture")) type = FTexture::TEX_Wall; + else if (sc.Compare("flat")) type = FTexture::TEX_Flat; + else if (sc.Compare("sprite")) type = FTexture::TEX_Sprite; + else sc.UnGet(); + + bool disable_fullbright = false; + bool thiswad = false; + bool iwad = false; + int maplump = -1; + FString maplumpname; + float speed = 1.f; + + sc.MustGetString(); + FTextureID no = TexMan.CheckForTexture(sc.String, type); + FTexture *tex = TexMan[no]; + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("shader")) + { + sc.MustGetString(); + maplumpname = sc.String; + } + else if (sc.Compare("speed")) + { + sc.MustGetFloat(); + speed = float(sc.Float); + } + } + if (!tex) + { + return; + } + + if (maplumpname.IsNotEmpty()) + { + if (tex->bWarped != 0) + { + Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars()); + return; + } + tex->gl_info.shaderspeed = speed; + for (unsigned i = 0; i < usershaders.Size(); i++) + { + if (!usershaders[i].CompareNoCase(maplumpname)) + { + tex->gl_info.shaderindex = i + FIRST_USER_SHADER; + return; + } + } + tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER; + } + } } From befe081683ca0f3a7718a634acfe46a459f5467d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 3 Jul 2017 01:29:03 +0200 Subject: [PATCH 63/82] - Upload custom texture --- src/gl/renderer/gl_postprocess.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 5fb40b2af..2a5c1b829 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -198,7 +198,10 @@ void FGLRenderer::RunCustomPostProcessShaders(FString target) shader.Instance->CustomTexture.Init(shader.Instance->Program, "CustomTexture"); if (shader.Texture) + { shader.Instance->HWTexture = new FHardwareTexture(shader.Texture->GetWidth(), shader.Texture->GetHeight(), false); + shader.Instance->HWTexture->CreateTexture((unsigned char*)shader.Texture->GetPixelsBgra(), shader.Texture->GetWidth(), shader.Texture->GetHeight(), 0, false, 0, "CustomTexture"); + } } FGLDebug::PushGroup(shader.ShaderLumpName.GetChars()); From 1b5f3da9c59e0b59aefb6c8b5c0e2cc74d005b2c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 3 Jul 2017 01:50:51 +0200 Subject: [PATCH 64/82] - Fix lump lookup --- src/gl/renderer/gl_postprocess.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 2a5c1b829..570a43ffc 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -42,6 +42,7 @@ #include "r_utility.h" #include "p_local.h" #include "colormatcher.h" +#include "w_wad.h" #include "gl/gl_functions.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -188,9 +189,14 @@ void FGLRenderer::RunCustomPostProcessShaders(FString target) if (!shader.Instance) { + const char *lumpName = shader.ShaderLumpName.GetChars(); + int lump = Wads.CheckNumForFullName(lumpName); + if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); + FString code = Wads.ReadLump(lump).GetString().GetChars(); + shader.Instance = std::make_shared(); shader.Instance->Program.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); // Hmm, should this use shader.shaderversion? - shader.Instance->Program.Compile(FShaderProgram::Fragment, shader.ShaderLumpName.GetChars(), "", shader.ShaderVersion); + shader.Instance->Program.Compile(FShaderProgram::Fragment, lumpName, code, "", shader.ShaderVersion); shader.Instance->Program.SetFragDataLocation(0, "FragColor"); shader.Instance->Program.Link(shader.ShaderLumpName.GetChars()); shader.Instance->Program.SetAttribLocation(0, "PositionInProjection"); From 5c87cdd786791b2ed091a8a6b5a12cb8471b34e0 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 2 Jul 2017 21:04:22 -0400 Subject: [PATCH 65/82] - Add new "scene" target for custom postprocess shaders - Add "gl_custompost" cvar to turn off custom postprocess shaders completely - Made "scene" affect the screen before 2D drawing, made "screen" affect the entire screen after 2D drawing --- src/gl/renderer/gl_postprocess.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index db17bccb1..2c9ccdcde 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -148,6 +148,8 @@ CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITC CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE) +CVAR(Bool, gl_custompost, true, 0) + EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Float, vid_saturation) @@ -178,11 +180,14 @@ void FGLRenderer::PostProcessScene(int fixedcm) ColormapScene(fixedcm); LensDistortScene(); ApplyFXAA(); - RunCustomPostProcessShaders("screen"); + RunCustomPostProcessShaders("scene"); } void FGLRenderer::RunCustomPostProcessShaders(FString target) { + if (!gl_custompost) + return; + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) { PostProcessShader &shader = PostProcessShaders[i]; @@ -895,6 +900,8 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) m2DDrawer->Draw(); // draw all pending 2D stuff before copying the buffer m2DDrawer->Clear(); + RunCustomPostProcessShaders("screen"); + FGLDebug::PushGroup("CopyToBackbuffer"); if (FGLRenderBuffers::IsEnabled()) { From e161bba14678350de09d763658ec784f759919a8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 3 Jul 2017 22:30:49 +0200 Subject: [PATCH 66/82] - Specify shader uniforms from ZScript --- src/gl/renderer/gl_postprocess.cpp | 52 ++++++++++++++++++++++++++++++ src/gl/renderer/gl_renderer.h | 5 +++ src/gl/shaders/gl_shader.cpp | 5 +++ wadsrc/static/zscript/base.txt | 5 +++ 4 files changed, 67 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 570a43ffc..89a18395f 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -178,6 +178,40 @@ void FGLRenderer::PostProcessScene(int fixedcm) RunCustomPostProcessShaders("screen"); } +#include "vm.h" + +DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) +{ + PARAM_PROLOGUE; + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_FLOAT_DEF(value); + + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + shader.Uniform1f[uniformName] = value; + } + return 0; +} + +DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i) +{ + PARAM_PROLOGUE; + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_INT_DEF(value); + + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + shader.Uniform1i[uniformName] = value; + } + return 0; +} + void FGLRenderer::RunCustomPostProcessShaders(FString target) { for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) @@ -222,6 +256,24 @@ void FGLRenderer::RunCustomPostProcessShaders(FString target) shader.Instance->Program.Bind(); + TMap::Iterator it1f(shader.Uniform1f); + TMap::Pair *pair1f; + while (it1f.NextPair(pair1f)) + { + int location = glGetUniformLocation(shader.Instance->Program, pair1f->Key.GetChars()); + if (location != -1) + glUniform1f(location, pair1f->Value); + } + + TMap::Iterator it1i(shader.Uniform1i); + TMap::Pair *pair1i; + while (it1i.NextPair(pair1i)) + { + int location = glGetUniformLocation(shader.Instance->Program, pair1i->Key.GetChars()); + if (location != -1) + glUniform1i(location, pair1i->Value); + } + shader.Instance->InputTexture.Set(0); if (shader.Instance->HWTexture) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index ce4d749a7..9e75e13fc 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -92,6 +92,11 @@ struct PostProcessShader FString ShaderLumpName; int ShaderVersion = 0; FTexture *Texture = nullptr; + + FString Name; + TMap Uniform1i; + TMap Uniform1f; + std::shared_ptr Instance; }; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 022cec7d9..ba4c2874c 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -693,6 +693,11 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) sc.MustGetNumber(); shaderdesc.ShaderVersion = sc.Number; } + else if (sc.Compare("name")) + { + sc.MustGetString(); + shaderdesc.Name = sc.String; + } else if (sc.Compare("texture")) { sc.MustGetString(); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 726e46fcc..c215768d1 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -775,3 +775,8 @@ class Lighting : SectorEffect native { } +struct Shader native +{ + native static void SetUniform1f(string shaderName, string uniformName, float value); + native static void SetUniform1i(string shaderName, string uniformName, int value); +} From 1cfaae78d9888b4826f06d803ef8277eee56773b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 2 Jul 2017 21:04:22 -0400 Subject: [PATCH 67/82] - Add new "scene" target for custom postprocess shaders - Add "gl_custompost" cvar to turn off custom postprocess shaders completely - Made "scene" affect the screen before 2D drawing, made "screen" affect the entire screen after 2D drawing --- src/gl/renderer/gl_postprocess.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 89a18395f..0565bbbce 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -147,6 +147,8 @@ CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITC } +CVAR(Bool, gl_custompost, true, 0) + EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) @@ -175,7 +177,7 @@ void FGLRenderer::PostProcessScene(int fixedcm) ColormapScene(fixedcm); LensDistortScene(); ApplyFXAA(); - RunCustomPostProcessShaders("screen"); + RunCustomPostProcessShaders("scene"); } #include "vm.h" @@ -214,6 +216,9 @@ DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i) void FGLRenderer::RunCustomPostProcessShaders(FString target) { + if (!gl_custompost) + return; + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) { PostProcessShader &shader = PostProcessShaders[i]; @@ -864,6 +869,8 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) m2DDrawer->Draw(); // draw all pending 2D stuff before copying the buffer m2DDrawer->Clear(); + RunCustomPostProcessShaders("screen"); + FGLDebug::PushGroup("CopyToBackbuffer"); if (FGLRenderBuffers::IsEnabled()) { From 8a0e801cb5a8e540763dad74a193dc2f429060ce Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 6 Jul 2017 05:36:01 +0200 Subject: [PATCH 68/82] - Move custom postprocess shader to its own file --- src/CMakeLists.txt | 1 + src/gl/renderer/gl_postprocess.cpp | 140 +---------------------- src/gl/renderer/gl_renderer.cpp | 4 + src/gl/renderer/gl_renderer.h | 20 +--- src/gl/shaders/gl_postprocessshader.cpp | 145 ++++++++++++++++++++++++ src/gl/shaders/gl_postprocessshader.h | 48 ++++++++ src/gl/shaders/gl_shader.cpp | 35 +++++- 7 files changed, 237 insertions(+), 156 deletions(-) create mode 100644 src/gl/shaders/gl_postprocessshader.cpp create mode 100644 src/gl/shaders/gl_postprocessshader.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c862d27e5..61b1d9530 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -979,6 +979,7 @@ set (PCH_SOURCES gl/shaders/gl_shader.cpp gl/shaders/gl_texshader.cpp gl/shaders/gl_shaderprogram.cpp + gl/shaders/gl_postprocessshader.cpp gl/shaders/gl_shadowmapshader.cpp gl/shaders/gl_presentshader.cpp gl/shaders/gl_present3dRowshader.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 0565bbbce..da0370883 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -42,7 +42,6 @@ #include "r_utility.h" #include "p_local.h" #include "colormatcher.h" -#include "w_wad.h" #include "gl/gl_functions.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" @@ -63,6 +62,7 @@ #include "gl/shaders/gl_lensshader.h" #include "gl/shaders/gl_fxaashader.h" #include "gl/shaders/gl_presentshader.h" +#include "gl/shaders/gl_postprocessshader.h" #include "gl/renderer/gl_2ddrawer.h" #include "gl/stereo3d/gl_stereo3d.h" @@ -147,20 +147,9 @@ CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITC } -CVAR(Bool, gl_custompost, true, 0) - EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) -class PostProcessShaderInstance -{ -public: - FShaderProgram Program; - FBufferedUniformSampler InputTexture; - FBufferedUniformSampler CustomTexture; - FHardwareTexture *HWTexture = nullptr; -}; - void FGLRenderer::RenderScreenQuad() { mVBO->BindVBO(); @@ -172,136 +161,15 @@ void FGLRenderer::PostProcessScene(int fixedcm) { mBuffers->BlitSceneToTexture(); UpdateCameraExposure(); + mCustomPostProcessShaders->Run("beforebloom"); BloomScene(fixedcm); TonemapScene(); ColormapScene(fixedcm); LensDistortScene(); ApplyFXAA(); - RunCustomPostProcessShaders("scene"); + mCustomPostProcessShaders->Run("scene"); } -#include "vm.h" - -DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) -{ - PARAM_PROLOGUE; - PARAM_STRING(shaderName); - PARAM_STRING(uniformName); - PARAM_FLOAT_DEF(value); - - for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) - { - PostProcessShader &shader = PostProcessShaders[i]; - if (shader.Name == shaderName) - shader.Uniform1f[uniformName] = value; - } - return 0; -} - -DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i) -{ - PARAM_PROLOGUE; - PARAM_STRING(shaderName); - PARAM_STRING(uniformName); - PARAM_INT_DEF(value); - - for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) - { - PostProcessShader &shader = PostProcessShaders[i]; - if (shader.Name == shaderName) - shader.Uniform1i[uniformName] = value; - } - return 0; -} - -void FGLRenderer::RunCustomPostProcessShaders(FString target) -{ - if (!gl_custompost) - return; - - for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) - { - PostProcessShader &shader = PostProcessShaders[i]; - - if (shader.Target != target) - continue; - - if (!shader.Instance) - { - const char *lumpName = shader.ShaderLumpName.GetChars(); - int lump = Wads.CheckNumForFullName(lumpName); - if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); - FString code = Wads.ReadLump(lump).GetString().GetChars(); - - shader.Instance = std::make_shared(); - shader.Instance->Program.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); // Hmm, should this use shader.shaderversion? - shader.Instance->Program.Compile(FShaderProgram::Fragment, lumpName, code, "", shader.ShaderVersion); - shader.Instance->Program.SetFragDataLocation(0, "FragColor"); - shader.Instance->Program.Link(shader.ShaderLumpName.GetChars()); - shader.Instance->Program.SetAttribLocation(0, "PositionInProjection"); - shader.Instance->InputTexture.Init(shader.Instance->Program, "InputTexture"); - shader.Instance->CustomTexture.Init(shader.Instance->Program, "CustomTexture"); - - if (shader.Texture) - { - shader.Instance->HWTexture = new FHardwareTexture(shader.Texture->GetWidth(), shader.Texture->GetHeight(), false); - shader.Instance->HWTexture->CreateTexture((unsigned char*)shader.Texture->GetPixelsBgra(), shader.Texture->GetWidth(), shader.Texture->GetHeight(), 0, false, 0, "CustomTexture"); - } - } - - FGLDebug::PushGroup(shader.ShaderLumpName.GetChars()); - - FGLPostProcessState savedState; - savedState.SaveTextureBindings(2); - - mBuffers->BindNextFB(); - mBuffers->BindCurrentTexture(0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - shader.Instance->Program.Bind(); - - TMap::Iterator it1f(shader.Uniform1f); - TMap::Pair *pair1f; - while (it1f.NextPair(pair1f)) - { - int location = glGetUniformLocation(shader.Instance->Program, pair1f->Key.GetChars()); - if (location != -1) - glUniform1f(location, pair1f->Value); - } - - TMap::Iterator it1i(shader.Uniform1i); - TMap::Pair *pair1i; - while (it1i.NextPair(pair1i)) - { - int location = glGetUniformLocation(shader.Instance->Program, pair1i->Key.GetChars()); - if (location != -1) - glUniform1i(location, pair1i->Value); - } - - shader.Instance->InputTexture.Set(0); - - if (shader.Instance->HWTexture) - { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, shader.Instance->HWTexture->GetTextureHandle(0)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glActiveTexture(GL_TEXTURE0); - - shader.Instance->CustomTexture.Set(1); - } - RenderScreenQuad(); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - mBuffers->NextTexture(); - - FGLDebug::PopGroup(); - } -} //----------------------------------------------------------------------------- // @@ -869,7 +737,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) m2DDrawer->Draw(); // draw all pending 2D stuff before copying the buffer m2DDrawer->Clear(); - RunCustomPostProcessShaders("screen"); + mCustomPostProcessShaders->Run("screen"); FGLDebug::PushGroup("CopyToBackbuffer"); if (FGLRenderBuffers::IsEnabled()) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 77d8d6bc3..bac55edb8 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -62,6 +62,7 @@ #include "gl/shaders/gl_presentshader.h" #include "gl/shaders/gl_present3dRowshader.h" #include "gl/shaders/gl_shadowmapshader.h" +#include "gl/shaders/gl_postprocessshader.h" #include "gl/stereo3d/gl_stereo3d.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_translate.h" @@ -128,6 +129,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mFXAAShader = nullptr; mFXAALumaShader = nullptr; mShadowMapShader = nullptr; + mCustomPostProcessShaders = nullptr; } void gl_LoadModels(); @@ -157,6 +159,7 @@ void FGLRenderer::Initialize(int width, int height) mPresent3dColumnShader = new FPresent3DColumnShader(); mPresent3dRowShader = new FPresent3DRowShader(); mShadowMapShader = new FShadowMapShader(); + mCustomPostProcessShaders = new FCustomPostProcessShaders(); m2DDrawer = new F2DDrawer; // needed for the core profile, because someone decided it was a good idea to remove the default VAO. @@ -232,6 +235,7 @@ FGLRenderer::~FGLRenderer() if (mColormapShader) delete mColormapShader; if (mLensShader) delete mLensShader; if (mShadowMapShader) delete mShadowMapShader; + delete mCustomPostProcessShaders; delete mFXAAShader; delete mFXAALumaShader; } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 9e75e13fc..0021c4f97 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -42,7 +42,7 @@ class FPresent3DRowShader; class F2DDrawer; class FHardwareTexture; class FShadowMapShader; -class PostProcessShaderInstance; +class FCustomPostProcessShaders; inline float DEG2RAD(float deg) { @@ -86,22 +86,6 @@ enum DM_SKYPORTAL }; -struct PostProcessShader -{ - FString Target; - FString ShaderLumpName; - int ShaderVersion = 0; - FTexture *Texture = nullptr; - - FString Name; - TMap Uniform1i; - TMap Uniform1f; - - std::shared_ptr Instance; -}; - -extern TArray PostProcessShaders; - class FGLRenderer { public: @@ -143,6 +127,7 @@ public: FPresent3DColumnShader *mPresent3dColumnShader; FPresent3DRowShader *mPresent3dRowShader; FShadowMapShader *mShadowMapShader; + FCustomPostProcessShaders *mCustomPostProcessShaders; FShadowMap mShadowMap; @@ -188,7 +173,6 @@ public: void RenderScreenQuad(); void PostProcessScene(int fixedcm); - void RunCustomPostProcessShaders(FString target); void AmbientOccludeScene(); void UpdateCameraExposure(); void BloomScene(int fixedcm); diff --git a/src/gl/shaders/gl_postprocessshader.cpp b/src/gl/shaders/gl_postprocessshader.cpp new file mode 100644 index 000000000..1bd7bc394 --- /dev/null +++ b/src/gl/shaders/gl_postprocessshader.cpp @@ -0,0 +1,145 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2017 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + +#include "gl/system/gl_system.h" +#include "m_swap.h" +#include "v_video.h" +#include "gl/gl_functions.h" +#include "vectors.h" +#include "w_wad.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_debug.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_postprocessstate.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "gl/shaders/gl_postprocessshader.h" + +CVAR(Bool, gl_custompost, true, 0) + +TArray PostProcessShaders; + +FCustomPostProcessShaders::FCustomPostProcessShaders() +{ + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + mShaders.push_back(std::unique_ptr(new PostProcessShaderInstance(&PostProcessShaders[i]))); + } +} + +FCustomPostProcessShaders::~FCustomPostProcessShaders() +{ +} + +void FCustomPostProcessShaders::Run(FString target) +{ + if (!gl_custompost) + return; + + for (auto &shader : mShaders) + { + if (shader->Desc->Target == target) + { + shader->Run(); + } + } +} + +///////////////////////////////////////////////////////////////////////////// + +void PostProcessShaderInstance::Run() +{ + if (!Program) + { + const char *lumpName = Desc->ShaderLumpName.GetChars(); + int lump = Wads.CheckNumForFullName(lumpName); + if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); + FString code = Wads.ReadLump(lump).GetString().GetChars(); + + Program.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); // Hmm, should this use shader.shaderversion? + Program.Compile(FShaderProgram::Fragment, lumpName, code, "", Desc->ShaderVersion); + Program.SetFragDataLocation(0, "FragColor"); + Program.Link(Desc->ShaderLumpName.GetChars()); + Program.SetAttribLocation(0, "PositionInProjection"); + InputTexture.Init(Program, "InputTexture"); + CustomTexture.Init(Program, "CustomTexture"); + + if (Desc->Texture) + { + HWTexture = new FHardwareTexture(Desc->Texture->GetWidth(), Desc->Texture->GetHeight(), false); + HWTexture->CreateTexture((unsigned char*)Desc->Texture->GetPixelsBgra(), Desc->Texture->GetWidth(), Desc->Texture->GetHeight(), 0, false, 0, "CustomTexture"); + } + } + + FGLDebug::PushGroup(Desc->ShaderLumpName.GetChars()); + + FGLPostProcessState savedState; + savedState.SaveTextureBindings(2); + + GLRenderer->mBuffers->BindNextFB(); + GLRenderer->mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + Program.Bind(); + + TMap::Iterator it1f(Desc->Uniform1f); + TMap::Pair *pair1f; + while (it1f.NextPair(pair1f)) + { + int location = glGetUniformLocation(Program, pair1f->Key.GetChars()); + if (location != -1) + glUniform1f(location, pair1f->Value); + } + + TMap::Iterator it1i(Desc->Uniform1i); + TMap::Pair *pair1i; + while (it1i.NextPair(pair1i)) + { + int location = glGetUniformLocation(Program, pair1i->Key.GetChars()); + if (location != -1) + glUniform1i(location, pair1i->Value); + } + + InputTexture.Set(0); + + if (HWTexture) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, HWTexture->GetTextureHandle(0)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glActiveTexture(GL_TEXTURE0); + + CustomTexture.Set(1); + } + GLRenderer->RenderScreenQuad(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + GLRenderer->mBuffers->NextTexture(); + + FGLDebug::PopGroup(); +} diff --git a/src/gl/shaders/gl_postprocessshader.h b/src/gl/shaders/gl_postprocessshader.h new file mode 100644 index 000000000..171b43945 --- /dev/null +++ b/src/gl/shaders/gl_postprocessshader.h @@ -0,0 +1,48 @@ +#pragma once + +#include "gl_shaderprogram.h" + +class PostProcessShaderInstance; + +struct PostProcessShader +{ + FString Target; + FString ShaderLumpName; + int ShaderVersion = 0; + FTexture *Texture = nullptr; + + FString Name; + TMap Uniform1i; + TMap Uniform1f; +}; + +extern TArray PostProcessShaders; + +class PostProcessShaderInstance +{ +public: + PostProcessShaderInstance(PostProcessShader *desc) : Desc(desc) { } + + void Run(); + + PostProcessShader *Desc; + FShaderProgram Program; + FBufferedUniformSampler InputTexture; + FBufferedUniformSampler CustomTexture; + FHardwareTexture *HWTexture = nullptr; +}; + +class FCustomPostProcessShaders +{ +public: + FCustomPostProcessShaders(); + ~FCustomPostProcessShaders(); + + void Run(FString target); + +private: + std::vector> mShaders; + + FCustomPostProcessShaders(const FCustomPostProcessShaders &) = delete; + FCustomPostProcessShaders &operator=(const FCustomPostProcessShaders &) = delete; +}; diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ba4c2874c..e153dc653 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -36,6 +36,7 @@ #include "v_palette.h" #include "sc_man.h" #include "cmdlib.h" +#include "vm.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_debug.h" @@ -46,6 +47,7 @@ #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_shaderprogram.h" +#include "gl/shaders/gl_postprocessshader.h" #include "gl/textures/gl_material.h" #include "gl/dynlights/gl_lightbuffer.h" @@ -669,8 +671,6 @@ void gl_DestroyUserShaders() // //========================================================================== -TArray PostProcessShaders; - void gl_ParseHardwareShader(FScanner &sc, int deflump) { sc.MustGetString(); @@ -769,3 +769,34 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) } } +DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) +{ + PARAM_PROLOGUE; + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_FLOAT_DEF(value); + + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + shader.Uniform1f[uniformName] = value; + } + return 0; +} + +DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i) +{ + PARAM_PROLOGUE; + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_INT_DEF(value); + + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + shader.Uniform1i[uniformName] = value; + } + return 0; +} From a4b96f767397d01616092b1cfeb24d888d55da84 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 6 Jul 2017 18:02:27 +0200 Subject: [PATCH 69/82] - Fix linker error --- src/gl/renderer/gl_postprocess.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 2659b41f8..7ca6d7898 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -148,8 +148,6 @@ CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITC CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE) -CVAR(Bool, gl_custompost, true, 0) - EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Float, vid_saturation) From a38de996e7ed2895f098f04cac618c90120ef79a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 8 Jul 2017 14:44:07 +0200 Subject: [PATCH 70/82] - Move uniform declarations to the GLDEFS lump to make it Vulkan safe (a vulkan implementation can then declare them in an uniform block) - Change SetUniform functions to be clearscope as they can be safely called from both play and ui - Add PlayerInfo argument to SetUniform functions to force the modder to take network play into account - Add enabled flag on custom postprocess shaders - Removed custom texture support until a more clean implementation is written --- src/gl/shaders/gl_postprocessshader.cpp | 151 ++++++++++++++++-------- src/gl/shaders/gl_postprocessshader.h | 33 ++++-- src/gl/shaders/gl_shader.cpp | 142 ++++++++++++++++++++-- wadsrc/static/zscript/base.txt | 7 +- 4 files changed, 262 insertions(+), 71 deletions(-) diff --git a/src/gl/shaders/gl_postprocessshader.cpp b/src/gl/shaders/gl_postprocessshader.cpp index 1bd7bc394..0baf06531 100644 --- a/src/gl/shaders/gl_postprocessshader.cpp +++ b/src/gl/shaders/gl_postprocessshader.cpp @@ -69,72 +69,29 @@ void FCustomPostProcessShaders::Run(FString target) void PostProcessShaderInstance::Run() { - if (!Program) - { - const char *lumpName = Desc->ShaderLumpName.GetChars(); - int lump = Wads.CheckNumForFullName(lumpName); - if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); - FString code = Wads.ReadLump(lump).GetString().GetChars(); + if (!IsShaderSupported()) + return; - Program.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); // Hmm, should this use shader.shaderversion? - Program.Compile(FShaderProgram::Fragment, lumpName, code, "", Desc->ShaderVersion); - Program.SetFragDataLocation(0, "FragColor"); - Program.Link(Desc->ShaderLumpName.GetChars()); - Program.SetAttribLocation(0, "PositionInProjection"); - InputTexture.Init(Program, "InputTexture"); - CustomTexture.Init(Program, "CustomTexture"); + CompileShader(); - if (Desc->Texture) - { - HWTexture = new FHardwareTexture(Desc->Texture->GetWidth(), Desc->Texture->GetHeight(), false); - HWTexture->CreateTexture((unsigned char*)Desc->Texture->GetPixelsBgra(), Desc->Texture->GetWidth(), Desc->Texture->GetHeight(), 0, false, 0, "CustomTexture"); - } - } + if (!Desc->Enabled) + return; FGLDebug::PushGroup(Desc->ShaderLumpName.GetChars()); FGLPostProcessState savedState; - savedState.SaveTextureBindings(2); GLRenderer->mBuffers->BindNextFB(); GLRenderer->mBuffers->BindCurrentTexture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - Program.Bind(); + mProgram.Bind(); - TMap::Iterator it1f(Desc->Uniform1f); - TMap::Pair *pair1f; - while (it1f.NextPair(pair1f)) - { - int location = glGetUniformLocation(Program, pair1f->Key.GetChars()); - if (location != -1) - glUniform1f(location, pair1f->Value); - } + UpdateUniforms(); - TMap::Iterator it1i(Desc->Uniform1i); - TMap::Pair *pair1i; - while (it1i.NextPair(pair1i)) - { - int location = glGetUniformLocation(Program, pair1i->Key.GetChars()); - if (location != -1) - glUniform1i(location, pair1i->Value); - } + mInputTexture.Set(0); - InputTexture.Set(0); - - if (HWTexture) - { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, HWTexture->GetTextureHandle(0)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glActiveTexture(GL_TEXTURE0); - - CustomTexture.Set(1); - } GLRenderer->RenderScreenQuad(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -143,3 +100,95 @@ void PostProcessShaderInstance::Run() FGLDebug::PopGroup(); } + +bool PostProcessShaderInstance::IsShaderSupported() +{ + int activeShaderVersion = (int)round(gl.glslversion * 10) * 10; + return activeShaderVersion >= Desc->ShaderVersion; +} + +void PostProcessShaderInstance::CompileShader() +{ + if (mProgram) + return; + + // Get the custom shader + const char *lumpName = Desc->ShaderLumpName.GetChars(); + int lump = Wads.CheckNumForFullName(lumpName); + if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); + FString code = Wads.ReadLump(lump).GetString().GetChars(); + + // Build an uniform block to use be used as input + // (this is technically not an uniform block, but it could be changed into that for Vulkan GLSL support) + FString uniformBlock; + TMap::Iterator it(Desc->Uniforms); + TMap::Pair *pair; + while (it.NextPair(pair)) + { + FString type; + FString name = pair->Key; + + switch (pair->Value.Type) + { + case PostProcessUniformType::Float: type = "float"; break; + case PostProcessUniformType::Int: type = "int"; break; + case PostProcessUniformType::Vec2: type = "vec2"; break; + case PostProcessUniformType::Vec3: type = "vec3"; break; + default: break; + } + + if (!type.IsEmpty()) + uniformBlock.AppendFormat("uniform %s %s;\n", type.GetChars(), name.GetChars()); + } + + // Build the input textures + FString uniformTextures; + uniformTextures += "uniform sampler2D InputTexture;\n"; + + // Setup pipeline + FString pipelineInOut; + pipelineInOut += "in vec2 TexCoord;\n"; + pipelineInOut += "out vec4 FragColor;\n"; + + FString prolog; + prolog += uniformBlock; + prolog += uniformTextures; + prolog += pipelineInOut; + + mProgram.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", Desc->ShaderVersion); + mProgram.Compile(FShaderProgram::Fragment, lumpName, code, prolog.GetChars(), Desc->ShaderVersion); + mProgram.SetFragDataLocation(0, "FragColor"); + mProgram.Link(Desc->ShaderLumpName.GetChars()); + mProgram.SetAttribLocation(0, "PositionInProjection"); + mInputTexture.Init(mProgram, "InputTexture"); +} + +void PostProcessShaderInstance::UpdateUniforms() +{ + TMap::Iterator it(Desc->Uniforms); + TMap::Pair *pair; + while (it.NextPair(pair)) + { + int location = glGetUniformLocation(mProgram, pair->Key.GetChars()); + if (location != -1) + { + switch (pair->Value.Type) + { + case PostProcessUniformType::Float: + glUniform1f(location, (float)pair->Value.Values[0]); + break; + case PostProcessUniformType::Int: + glUniform1i(location, (int)pair->Value.Values[0]); + break; + case PostProcessUniformType::Vec2: + glUniform2f(location, (float)pair->Value.Values[0], (float)pair->Value.Values[1]); + break; + case PostProcessUniformType::Vec3: + glUniform3f(location, (float)pair->Value.Values[0], (float)pair->Value.Values[1], (float)pair->Value.Values[2]); + break; + default: + break; + } + } + } +} diff --git a/src/gl/shaders/gl_postprocessshader.h b/src/gl/shaders/gl_postprocessshader.h index 171b43945..876cb9f56 100644 --- a/src/gl/shaders/gl_postprocessshader.h +++ b/src/gl/shaders/gl_postprocessshader.h @@ -4,16 +4,31 @@ class PostProcessShaderInstance; +enum class PostProcessUniformType +{ + Undefined, + Int, + Float, + Vec2, + Vec3 +}; + +struct PostProcessUniformValue +{ + PostProcessUniformType Type = PostProcessUniformType::Undefined; + double Values[4] = { 0.0, 0.0, 0.0, 0.0 }; +}; + struct PostProcessShader { FString Target; FString ShaderLumpName; int ShaderVersion = 0; - FTexture *Texture = nullptr; FString Name; - TMap Uniform1i; - TMap Uniform1f; + bool Enabled = false; + + TMap Uniforms; }; extern TArray PostProcessShaders; @@ -26,10 +41,14 @@ public: void Run(); PostProcessShader *Desc; - FShaderProgram Program; - FBufferedUniformSampler InputTexture; - FBufferedUniformSampler CustomTexture; - FHardwareTexture *HWTexture = nullptr; + +private: + bool IsShaderSupported(); + void CompileShader(); + void UpdateUniforms(); + + FShaderProgram mProgram; + FBufferedUniformSampler mInputTexture; }; class FCustomPostProcessShaders diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index e153dc653..758f85435 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -37,6 +37,7 @@ #include "sc_man.h" #include "cmdlib.h" #include "vm.h" +#include "d_player.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_debug.h" @@ -698,11 +699,28 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) sc.MustGetString(); shaderdesc.Name = sc.String; } - else if (sc.Compare("texture")) + else if (sc.Compare("uniform")) { sc.MustGetString(); - FTextureID no = TexMan.CheckForTexture(sc.String, FTexture::TEX_Wall); - shaderdesc.Texture = TexMan[no]; + FString uniformType = sc.String; + uniformType.ToLower(); + + sc.MustGetString(); + FString uniformName = sc.String; + + PostProcessUniformType parsedType = PostProcessUniformType::Undefined; + + if (uniformType.Compare("int") == 0) + parsedType = PostProcessUniformType::Int; + else if (uniformType.Compare("float") == 0) + parsedType = PostProcessUniformType::Float; + else if (uniformType.Compare("vec2") == 0) + parsedType = PostProcessUniformType::Vec2; + else if (uniformType.Compare("vec3") == 0) + parsedType = PostProcessUniformType::Vec3; + + if (parsedType != PostProcessUniformType::Undefined) + shaderdesc.Uniforms[uniformName].Type = parsedType; } } @@ -769,18 +787,110 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) } } +static bool IsConsolePlayer(player_t *player) +{ + AActor *activator = player ? player->mo : nullptr; + if (activator == nullptr || activator->player == nullptr) + return false; + return int(activator->player - players) == consoleplayer; +} + +DEFINE_ACTION_FUNCTION(_Shader, SetEnabled) +{ + PARAM_PROLOGUE; + PARAM_POINTER_DEF(player, player_t); + PARAM_STRING(shaderName); + PARAM_BOOL_DEF(value); + + if (IsConsolePlayer(player)) + { + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + shader.Enabled = value; + } + } + return 0; +} + DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) { PARAM_PROLOGUE; + PARAM_POINTER_DEF(player, player_t); PARAM_STRING(shaderName); PARAM_STRING(uniformName); PARAM_FLOAT_DEF(value); - for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + if (IsConsolePlayer(player)) { - PostProcessShader &shader = PostProcessShaders[i]; - if (shader.Name == shaderName) - shader.Uniform1f[uniformName] = value; + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + { + double *vec4 = shader.Uniforms[uniformName].Values; + vec4[0] = value; + vec4[1] = 0.0; + vec4[2] = 0.0; + vec4[3] = 1.0; + } + } + } + return 0; +} + +DEFINE_ACTION_FUNCTION(_Shader, SetUniform2f) +{ + PARAM_PROLOGUE; + PARAM_POINTER_DEF(player, player_t); + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_FLOAT_DEF(x); + PARAM_FLOAT_DEF(y); + + if (IsConsolePlayer(player)) + { + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + { + double *vec4 = shader.Uniforms[uniformName].Values; + vec4[0] = x; + vec4[1] = y; + vec4[2] = 0.0; + vec4[3] = 1.0; + } + } + } + return 0; +} + +DEFINE_ACTION_FUNCTION(_Shader, SetUniform3f) +{ + PARAM_PROLOGUE; + PARAM_POINTER_DEF(player, player_t); + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_FLOAT_DEF(x); + PARAM_FLOAT_DEF(y); + PARAM_FLOAT_DEF(z); + + if (IsConsolePlayer(player)) + { + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + { + double *vec4 = shader.Uniforms[uniformName].Values; + vec4[0] = x; + vec4[1] = y; + vec4[2] = z; + vec4[3] = 1.0; + } + } } return 0; } @@ -788,15 +898,25 @@ DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i) { PARAM_PROLOGUE; + PARAM_POINTER_DEF(player, player_t); PARAM_STRING(shaderName); PARAM_STRING(uniformName); PARAM_INT_DEF(value); - for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + if (IsConsolePlayer(player)) { - PostProcessShader &shader = PostProcessShaders[i]; - if (shader.Name == shaderName) - shader.Uniform1i[uniformName] = value; + for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) + { + PostProcessShader &shader = PostProcessShaders[i]; + if (shader.Name == shaderName) + { + double *vec4 = shader.Uniforms[uniformName].Values; + vec4[0] = (double)value; + vec4[1] = 0.0; + vec4[2] = 0.0; + vec4[3] = 1.0; + } + } } return 0; } diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index c215768d1..f35e39993 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -777,6 +777,9 @@ class Lighting : SectorEffect native struct Shader native { - native static void SetUniform1f(string shaderName, string uniformName, float value); - native static void SetUniform1i(string shaderName, string uniformName, int value); + native clearscope static void SetEnabled(PlayerInfo player, string shaderName, bool enable); + native clearscope static void SetUniform1f(PlayerInfo player, string shaderName, string uniformName, float value); + native clearscope static void SetUniform2f(PlayerInfo player, string shaderName, string uniformName, vector2 value); + native clearscope static void SetUniform3f(PlayerInfo player, string shaderName, string uniformName, vector3 value); + native clearscope static void SetUniform1i(PlayerInfo player, string shaderName, string uniformName, int value); } From 04b11631888325fca754ba38f943585d5d47bef3 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 10 Jul 2017 11:25:38 -0400 Subject: [PATCH 71/82] Revert "Add a comment" This reverts commit d2f4dd41f89e5d2fbcf1079171e778b73d41b279. --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index adc49495b..2f64d6166 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -480,7 +480,6 @@ if (GZDOOM_USE_OPENVR) option( GZDOOM_OPENVR_STATIC "Statically link OpenVR API" ON ) if(GZDOOM_OPENVR_STATIC) # Incorporate the whole openvr API into zdoom, using a few rules lifted from the OpenVR CMakeLists.txt files - # This branch avoids the need to ship openvr_api.dll add_definitions( -DVR_API_PUBLIC ) include_directories(${OPENVR_SDK_PATH}/src ${OPENVR_SDK_PATH}/src/vrcommon) file(GLOB OPENVR_SOURCES "${OPENVR_SDK_PATH}/src/*.cpp" "${OPENVR_SDK_PATH}/src/vrcommon/*.cpp") From 8c0706e56f5a9c454940cbe2d5cebc56b7a16e05 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 10 Jul 2017 11:26:41 -0400 Subject: [PATCH 72/82] Revert "Merge commit 'refs/pull/338/head' of https://github.com/coelckers/gzdoom" This reverts commit 56806e3243289e9429f3ffcc7afa87e48f5b7072, reversing changes made to e1a2de4989a6da935986fab92fd47677e57c2ae1. --- src/CMakeLists.txt | 55 +++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f64d6166..064878a36 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -477,39 +477,31 @@ if (GZDOOM_USE_OPENVR) ${OPENVR_SDK_PATH}/headers ) include_directories("${OPENVR_INCLUDE_DIRECTORY}") - option( GZDOOM_OPENVR_STATIC "Statically link OpenVR API" ON ) - if(GZDOOM_OPENVR_STATIC) - # Incorporate the whole openvr API into zdoom, using a few rules lifted from the OpenVR CMakeLists.txt files - add_definitions( -DVR_API_PUBLIC ) - include_directories(${OPENVR_SDK_PATH}/src ${OPENVR_SDK_PATH}/src/vrcommon) - file(GLOB OPENVR_SOURCES "${OPENVR_SDK_PATH}/src/*.cpp" "${OPENVR_SDK_PATH}/src/vrcommon/*.cpp") - else() # link to shared OpenVR library - # Link to correct library for this platform - if(WIN32) - set(OPENVR_PLAT "win") - elseif( APPLE ) - set(OPENVR_PLAT "osx") - else() - set(OPENVR_PLAT "linux") - endif() - if(X64) - set(OPENVR_PLAT ${OPENVR_PLAT}64) - else() - set(OPENVR_PLAT ${OPENVR_PLAT}32) - endif() - find_library(OPENVR_LIBRARY - NAMES openvr_api - HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/" - ) - list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) - # Find shared library file needed for package distribution - find_program(OPENVR_SHARED_LIBRARY - NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll - PATHS "${OPENVR_SDK_PATH}/bin/${OPENVR_PLAT}/" - NO_DEFAULT_PATH - ) + # Link to correct library for this platform + if(WIN32) + set(OPENVR_PLAT "win") + elseif( APPLE ) + set(OPENVR_PLAT "osx") + else() + set(OPENVR_PLAT "linux") endif() + if(X64) + set(OPENVR_PLAT ${OPENVR_PLAT}64) + else() + set(OPENVR_PLAT ${OPENVR_PLAT}32) + endif() + find_library(OPENVR_LIBRARY + NAMES openvr_api + HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/" + ) + list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) add_definitions("-DUSE_OPENVR") + # Find shared library file needed for package distribution + find_program(OPENVR_SHARED_LIBRARY + NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll + PATHS "${OPENVR_SDK_PATH}/bin/${OPENVR_PLAT}/" + NO_DEFAULT_PATH + ) endif() # Start defining source files for ZDoom @@ -1199,7 +1191,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE ${X86_SOURCES} ${FASTMATH_SOURCES} ${PCH_SOURCES} - ${OPENVR_SOURCES} x86.cpp strnatcmp.c zstring.cpp From 26355ece82795d4781a73c85d8168b15e7434bda Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 10 Jul 2017 11:29:30 -0400 Subject: [PATCH 73/82] Revert "Merge commit 'refs/pull/338/head' of https://github.com/coelckers/gzdoom" This reverts commit 035c036eb29d5f03e48345bfd320fc64965e4160, reversing changes made to 61660bf1471cc88c3a60833b87f01de2e52df2b4. --- src/CMakeLists.txt | 27 ++---------------- src/gl/stereo3d/LSMatrix.h | 52 +++++++++++++++++++++-------------- src/gl/stereo3d/gl_openvr.cpp | 49 +++++++++++++++++++-------------- src/gl/stereo3d/gl_openvr.h | 51 ++++++++++++++++++++-------------- 4 files changed, 91 insertions(+), 88 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 064878a36..dbb1ce097 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -477,31 +477,13 @@ if (GZDOOM_USE_OPENVR) ${OPENVR_SDK_PATH}/headers ) include_directories("${OPENVR_INCLUDE_DIRECTORY}") - # Link to correct library for this platform - if(WIN32) - set(OPENVR_PLAT "win") - elseif( APPLE ) - set(OPENVR_PLAT "osx") - else() - set(OPENVR_PLAT "linux") - endif() - if(X64) - set(OPENVR_PLAT ${OPENVR_PLAT}64) - else() - set(OPENVR_PLAT ${OPENVR_PLAT}32) - endif() find_library(OPENVR_LIBRARY NAMES openvr_api - HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/" + # TODO: Generalize for Mac and Linux and 64-bit Windows + HINTS "${OPENVR_SDK_PATH}/lib/win32/" ) list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) add_definitions("-DUSE_OPENVR") - # Find shared library file needed for package distribution - find_program(OPENVR_SHARED_LIBRARY - NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll - PATHS "${OPENVR_SDK_PATH}/bin/${OPENVR_PLAT}/" - NO_DEFAULT_PATH - ) endif() # Start defining source files for ZDoom @@ -1328,11 +1310,6 @@ endif() install(TARGETS zdoom DESTINATION ${INSTALL_PATH} COMPONENT "Game executable") -if(OPENVR_SHARED_LIBRARY) - install(PROGRAMS ${OPENVR_SHARED_LIBRARY} - DESTINATION ${INSTALL_PATH} - COMPONENT "Shared libraries") -endif() source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+") source_group("Audio Files\\OPL Synth" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/oplsynth/.+") diff --git a/src/gl/stereo3d/LSMatrix.h b/src/gl/stereo3d/LSMatrix.h index 926e4a606..a0e401838 100644 --- a/src/gl/stereo3d/LSMatrix.h +++ b/src/gl/stereo3d/LSMatrix.h @@ -1,29 +1,39 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2016-2017 Christopher Bruns -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* ** LSMatrix.h ** less-simple matrix class +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** */ + #ifndef VR_LS_MATRIX_H_ #define VR_LS_MATRIX_H_ diff --git a/src/gl/stereo3d/gl_openvr.cpp b/src/gl/stereo3d/gl_openvr.cpp index bd872dfa1..181f0bee7 100644 --- a/src/gl/stereo3d/gl_openvr.cpp +++ b/src/gl/stereo3d/gl_openvr.cpp @@ -1,28 +1,35 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2016-2017 Christopher Bruns -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* ** gl_openvr.cpp ** Stereoscopic virtual reality mode for the HTC Vive headset ** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** */ #ifdef USE_OPENVR diff --git a/src/gl/stereo3d/gl_openvr.h b/src/gl/stereo3d/gl_openvr.h index e3091c630..9fc905207 100644 --- a/src/gl/stereo3d/gl_openvr.h +++ b/src/gl/stereo3d/gl_openvr.h @@ -1,27 +1,36 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2016-2017 Christopher Bruns -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// /* ** gl_openvr.h ** Stereoscopic virtual reality mode for the HTC Vive headset +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** */ #ifndef GL_OPENVR_H_ From d2c8a5c33dd08c921deb7bd5e008d4b7d743868f Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 10 Jul 2017 11:29:58 -0400 Subject: [PATCH 74/82] Revert "Merge commit 'refs/pull/338/head' of https://github.com/coelckers/gzdoom" This reverts commit 65bb8a518515a4c4bb262ae99f491d71b131da3f, reversing changes made to 619281de649df38e382bfb2d376f16d01a065c18. --- CMakeLists.txt | 2 - src/CMakeLists.txt | 26 -- src/gl/data/gl_matrix.h | 2 +- src/gl/stereo3d/LSMatrix.h | 162 -------- src/gl/stereo3d/gl_openvr.cpp | 492 ------------------------ src/gl/stereo3d/gl_openvr.h | 110 ------ src/gl/stereo3d/gl_stereo_cvars.cpp | 18 +- src/gl/stereo3d/scoped_view_shifter.cpp | 2 +- src/gl/stereo3d/scoped_view_shifter.h | 2 +- wadsrc/static/language.enu | 1 - wadsrc/static/menudef.txt | 1 - 11 files changed, 9 insertions(+), 809 deletions(-) delete mode 100644 src/gl/stereo3d/LSMatrix.h delete mode 100644 src/gl/stereo3d/gl_openvr.cpp delete mode 100644 src/gl/stereo3d/gl_openvr.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f32d0a43c..277fec59c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,8 +300,6 @@ endif() set( LZMA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lzma/C" ) -option( GZDOOM_USE_OPENVR "Support OpenVR API for virtual reality head mounted displays" OFF ) - if( NOT CMAKE_CROSSCOMPILING ) if( NOT CROSS_EXPORTS ) set( CROSS_EXPORTS "" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dbb1ce097..61b1d9530 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -461,31 +461,6 @@ if( NOT DYN_FLUIDSYNTH ) endif() endif() -if (GZDOOM_USE_OPENVR) - find_path(OPENVR_SDK_PATH - NAMES - headers/openvr.h - HINTS - ENV OPENVR_DIR ENV PROGRAMFILES ENV HOME ENV USERPROFILE - PATH_SUFFIXES - openvr git/openvr - ) - find_path(OPENVR_INCLUDE_DIRECTORY - NAMES - openvr.h - HINTS - ${OPENVR_SDK_PATH}/headers - ) - include_directories("${OPENVR_INCLUDE_DIRECTORY}") - find_library(OPENVR_LIBRARY - NAMES openvr_api - # TODO: Generalize for Mac and Linux and 64-bit Windows - HINTS "${OPENVR_SDK_PATH}/lib/win32/" - ) - list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) - add_definitions("-DUSE_OPENVR") -endif() - # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES sound/mididevices/music_win_mididevice.cpp @@ -1020,7 +995,6 @@ set (PCH_SOURCES gl/stereo3d/gl_stereo_leftright.cpp gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp - gl/stereo3d/gl_openvr.cpp gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_sidebyside3d.cpp gl/stereo3d/gl_interleaved3d.cpp diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h index 12ef2f12b..3ec1f5ff4 100644 --- a/src/gl/data/gl_matrix.h +++ b/src/gl/data/gl_matrix.h @@ -62,7 +62,7 @@ class VSMatrix { void perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp); void ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp=-1.0f, FLOATTYPE farp=1.0f); void frustum(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp, FLOATTYPE farp); - void copy(FLOATTYPE * pDest) const + void copy(FLOATTYPE * pDest) { memcpy(pDest, mMatrix, 16 * sizeof(FLOATTYPE)); } diff --git a/src/gl/stereo3d/LSMatrix.h b/src/gl/stereo3d/LSMatrix.h deleted file mode 100644 index a0e401838..000000000 --- a/src/gl/stereo3d/LSMatrix.h +++ /dev/null @@ -1,162 +0,0 @@ -/* -** LSMatrix.h -** less-simple matrix class -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** -*/ - - -#ifndef VR_LS_MATRIX_H_ -#define VR_LS_MATRIX_H_ - -#include "gl/data/gl_matrix.h" -#include "openvr.h" - -namespace vr { - HmdMatrix34_t; -} - -class LSVec3 -{ -public: - LSVec3(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w=1.0f) - : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) - { - mVec[0] = x; - mVec[1] = y; - mVec[2] = z; - mVec[3] = w; - } - - LSVec3(const LSVec3& rhs) - : x(mVec[0]), y(mVec[1]), z(mVec[2]), w(mVec[3]) - { - *this = rhs; - } - - LSVec3& operator=(const LSVec3& rhs) { - LSVec3& lhs = *this; - for (int i = 0; i < 4; ++i) - lhs[i] = rhs[i]; - return *this; - } - - const FLOATTYPE& operator[](int i) const {return mVec[i];} - FLOATTYPE& operator[](int i) { return mVec[i]; } - - LSVec3 operator-(const LSVec3& rhs) const { - const LSVec3& lhs = *this; - LSVec3 result = *this; - for (int i = 0; i < 4; ++i) - result[i] -= rhs[i]; - return result; - } - - FLOATTYPE mVec[4]; - FLOATTYPE& x; - FLOATTYPE& y; - FLOATTYPE& z; - FLOATTYPE& w; -}; - -LSVec3 operator*(FLOATTYPE s, const LSVec3& rhs) { - LSVec3 result = rhs; - for (int i = 0; i < 4; ++i) - result[i] *= s; - return result; -} - -class LSMatrix44 : public VSMatrix -{ -public: - LSMatrix44() - { - loadIdentity(); - } - - LSMatrix44(const vr::HmdMatrix34_t& m) { - loadIdentity(); - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 4; ++j) { - (*this)[i][j] = m.m[i][j]; - } - } - } - - LSMatrix44(const VSMatrix& m) { - m.copy(mMatrix); - } - - // overload bracket operator to return one row of the matrix, so you can invoke, say, m[2][3] - FLOATTYPE* operator[](int i) {return &mMatrix[i*4];} - const FLOATTYPE* operator[](int i) const { return &mMatrix[i * 4]; } - - LSMatrix44 operator*(const VSMatrix& rhs) const { - LSMatrix44 result(*this); - result.multMatrix(rhs); - return result; - } - - LSVec3 operator*(const LSVec3& rhs) const { - const LSMatrix44& lhs = *this; - LSVec3 result(0, 0, 0, 0); - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - result[i] += lhs[i][j] * rhs[j]; - } - } - return result; - } - - LSMatrix44 getWithoutTranslation() const { - LSMatrix44 m = *this; - // Remove translation component - m[3][3] = 1.0f; - m[3][2] = m[3][1] = m[3][0] = 0.0f; - m[2][3] = m[1][3] = m[0][3] = 0.0f; - return m; - } - - LSMatrix44 transpose() const { - LSMatrix44 result; - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 4; ++j) { - result[i][j] = (*this)[j][i]; - } - } - return result; - } - -}; - -#endif // VR_LS_MATRIX_H_ - - diff --git a/src/gl/stereo3d/gl_openvr.cpp b/src/gl/stereo3d/gl_openvr.cpp deleted file mode 100644 index 181f0bee7..000000000 --- a/src/gl/stereo3d/gl_openvr.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* -** gl_openvr.cpp -** Stereoscopic virtual reality mode for the HTC Vive headset -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#ifdef USE_OPENVR - -#include "gl_openvr.h" -#include "openvr.h" -#include -#include "gl/system/gl_system.h" -#include "doomtype.h" // Printf -#include "d_player.h" -#include "g_game.h" // G_Add... -#include "p_local.h" // P_TryMove -#include "r_utility.h" // viewpitch -#include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderbuffers.h" -#include "g_levellocals.h" // pixelstretch -#include "math/cmath.h" -#include "c_cvars.h" -#include "LSMatrix.h" - -// For conversion between real-world and doom units -#define VERTICAL_DOOM_UNITS_PER_METER 27.0f - -EXTERN_CVAR(Int, screenblocks); - -using namespace vr; - -// feature toggles, for testing and debugging -static const bool doTrackHmdYaw = true; -static const bool doTrackHmdPitch = true; -static const bool doTrackHmdRoll = true; -static const bool doLateScheduledRotationTracking = true; -static const bool doStereoscopicViewpointOffset = true; -static const bool doRenderToDesktop = true; // mirroring to the desktop is very helpful for debugging -static const bool doRenderToHmd = true; -static const bool doTrackHmdVerticalPosition = false; // todo: -static const bool doTrackHmdHorizontalPostion = false; // todo: -static const bool doTrackVrControllerPosition = false; // todo: - -namespace s3d -{ - -/* static */ -const Stereo3DMode& OpenVRMode::getInstance() -{ - static OpenVRMode instance; - if (! instance.hmdWasFound) - return MonoView::getInstance(); - return instance; -} - -static HmdVector3d_t eulerAnglesFromQuat(HmdQuaternion_t quat) { - double q0 = quat.w; - // permute axes to make "Y" up/yaw - double q2 = quat.x; - double q3 = quat.y; - double q1 = quat.z; - - // http://stackoverflow.com/questions/18433801/converting-a-3x3-matrix-to-euler-tait-bryan-angles-pitch-yaw-roll - double roll = atan2(2 * (q0*q1 + q2*q3), 1 - 2 * (q1*q1 + q2*q2)); - double pitch = asin(2 * (q0*q2 - q3*q1)); - double yaw = atan2(2 * (q0*q3 + q1*q2), 1 - 2 * (q2*q2 + q3*q3)); - - return HmdVector3d_t{ yaw, pitch, roll }; -} - -static HmdQuaternion_t quatFromMatrix(HmdMatrix34_t matrix) { - HmdQuaternion_t q; - typedef float f34[3][4]; - f34& a = matrix.m; - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ - float trace = a[0][0] + a[1][1] + a[2][2]; // I removed + 1.0f; see discussion with Ethan - if (trace > 0) {// I changed M_EPSILON to 0 - float s = 0.5f / sqrtf(trace + 1.0f); - q.w = 0.25f / s; - q.x = (a[2][1] - a[1][2]) * s; - q.y = (a[0][2] - a[2][0]) * s; - q.z = (a[1][0] - a[0][1]) * s; - } - else { - if (a[0][0] > a[1][1] && a[0][0] > a[2][2]) { - float s = 2.0f * sqrtf(1.0f + a[0][0] - a[1][1] - a[2][2]); - q.w = (a[2][1] - a[1][2]) / s; - q.x = 0.25f * s; - q.y = (a[0][1] + a[1][0]) / s; - q.z = (a[0][2] + a[2][0]) / s; - } - else if (a[1][1] > a[2][2]) { - float s = 2.0f * sqrtf(1.0f + a[1][1] - a[0][0] - a[2][2]); - q.w = (a[0][2] - a[2][0]) / s; - q.x = (a[0][1] + a[1][0]) / s; - q.y = 0.25f * s; - q.z = (a[1][2] + a[2][1]) / s; - } - else { - float s = 2.0f * sqrtf(1.0f + a[2][2] - a[0][0] - a[1][1]); - q.w = (a[1][0] - a[0][1]) / s; - q.x = (a[0][2] + a[2][0]) / s; - q.y = (a[1][2] + a[2][1]) / s; - q.z = 0.25f * s; - } - } - - return q; -} - -static HmdVector3d_t eulerAnglesFromMatrix(HmdMatrix34_t mat) { - return eulerAnglesFromQuat(quatFromMatrix(mat)); -} - -OpenVREyePose::OpenVREyePose(int eye) - : ShiftedEyePose( 0.0f ) - , eye(eye) - , eyeTexture(nullptr) - , verticalDoomUnitsPerMeter(VERTICAL_DOOM_UNITS_PER_METER) - , currentPose(nullptr) -{ -} - - -/* virtual */ -OpenVREyePose::~OpenVREyePose() -{ - dispose(); -} - -static void vSMatrixFromHmdMatrix34(VSMatrix& m1, const vr::HmdMatrix34_t& m2) -{ - float tmp[16]; - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 4; ++j) { - tmp[4 * i + j] = m2.m[i][j]; - } - } - int i = 3; - for (int j = 0; j < 4; ++j) { - tmp[4 * i + j] = 0; - } - tmp[15] = 1; - m1.loadMatrix(&tmp[0]); -} - - -/* virtual */ -void OpenVREyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const -{ - outViewShift[0] = outViewShift[1] = outViewShift[2] = 0; - - if (currentPose == nullptr) - return; - const vr::TrackedDevicePose_t& hmd = *currentPose; - if (! hmd.bDeviceIsConnected) - return; - if (! hmd.bPoseIsValid) - return; - - if (! doStereoscopicViewpointOffset) - return; - - const vr::HmdMatrix34_t& hmdPose = hmd.mDeviceToAbsoluteTracking; - - // Pitch and Roll are identical between OpenVR and Doom worlds. - // But yaw can differ, depending on starting state, and controller movement. - float doomYawDegrees = yaw; - float openVrYawDegrees = RAD2DEG(-eulerAnglesFromMatrix(hmdPose).v[0]); - float deltaYawDegrees = doomYawDegrees - openVrYawDegrees; - while (deltaYawDegrees > 180) - deltaYawDegrees -= 360; - while (deltaYawDegrees < -180) - deltaYawDegrees += 360; - - // extract rotation component from hmd transform - LSMatrix44 openvr_X_hmd(hmdPose); - LSMatrix44 hmdRot = openvr_X_hmd.getWithoutTranslation(); // .transpose(); - - /// In these eye methods, just get local inter-eye stereoscopic shift, not full position shift /// - - // compute local eye shift - LSMatrix44 eyeShift2; - eyeShift2.loadIdentity(); - eyeShift2 = eyeShift2 * eyeToHeadTransform; // eye to head - eyeShift2 = eyeShift2 * hmdRot; // head to openvr - - LSVec3 eye_EyePos = LSVec3(0, 0, 0); // eye position in eye frame - LSVec3 hmd_EyePos = LSMatrix44(eyeToHeadTransform) * eye_EyePos; - LSVec3 hmd_HmdPos = LSVec3(0, 0, 0); // hmd position in hmd frame - LSVec3 openvr_EyePos = openvr_X_hmd * hmd_EyePos; - LSVec3 openvr_HmdPos = openvr_X_hmd * hmd_HmdPos; - LSVec3 hmd_OtherEyePos = LSMatrix44(otherEyeToHeadTransform) * eye_EyePos; - LSVec3 openvr_OtherEyePos = openvr_X_hmd * hmd_OtherEyePos; - LSVec3 openvr_EyeOffset = openvr_EyePos - openvr_HmdPos; - - VSMatrix doomInOpenVR = VSMatrix(); - doomInOpenVR.loadIdentity(); - // permute axes - float permute[] = { // Convert from OpenVR to Doom axis convention, including mirror inversion - -1, 0, 0, 0, // X-right in OpenVR -> X-left in Doom - 0, 0, 1, 0, // Z-backward in OpenVR -> Y-backward in Doom - 0, 1, 0, 0, // Y-up in OpenVR -> Z-up in Doom - 0, 0, 0, 1}; - doomInOpenVR.multMatrix(permute); - doomInOpenVR.scale(verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter, verticalDoomUnitsPerMeter); // Doom units are not meters - doomInOpenVR.scale(level.info->pixelstretch, level.info->pixelstretch, 1.0); // Doom universe is scaled by 1990s pixel aspect ratio - doomInOpenVR.rotate(deltaYawDegrees, 0, 0, 1); - - LSVec3 doom_EyeOffset = LSMatrix44(doomInOpenVR) * openvr_EyeOffset; - outViewShift[0] = doom_EyeOffset[0]; - outViewShift[1] = doom_EyeOffset[1]; - outViewShift[2] = doom_EyeOffset[2]; -} - -/* virtual */ -VSMatrix OpenVREyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const -{ - // Ignore those arguments and get the projection from the SDK - VSMatrix vs1 = ShiftedEyePose::GetProjection(fov, aspectRatio, fovRatio); - return projectionMatrix; -} - -void OpenVREyePose::initialize(vr::IVRSystem& vrsystem) -{ - float zNear = 5.0; - float zFar = 65536.0; - vr::HmdMatrix44_t projection = vrsystem.GetProjectionMatrix( - vr::EVREye(eye), zNear, zFar); - vr::HmdMatrix44_t proj_transpose; - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - proj_transpose.m[i][j] = projection.m[j][i]; - } - } - projectionMatrix.loadIdentity(); - projectionMatrix.multMatrix(&proj_transpose.m[0][0]); - - vr::HmdMatrix34_t eyeToHead = vrsystem.GetEyeToHeadTransform(vr::EVREye(eye)); - vSMatrixFromHmdMatrix34(eyeToHeadTransform, eyeToHead); - vr::HmdMatrix34_t otherEyeToHead = vrsystem.GetEyeToHeadTransform(eye == Eye_Left ? Eye_Right : Eye_Left); - vSMatrixFromHmdMatrix34(otherEyeToHeadTransform, otherEyeToHead); - - if (eyeTexture == nullptr) - eyeTexture = new vr::Texture_t(); - eyeTexture->handle = nullptr; // TODO: populate this at resolve time - eyeTexture->eType = vr::TextureType_OpenGL; - eyeTexture->eColorSpace = vr::ColorSpace_Linear; -} - -void OpenVREyePose::dispose() -{ - if (eyeTexture) { - delete eyeTexture; - eyeTexture = nullptr; - } -} - -bool OpenVREyePose::submitFrame() const -{ - if (eyeTexture == nullptr) - return false; - if (vr::VRCompositor() == nullptr) - return false; - // Copy HDR framebuffer into 24-bit RGB texture - GLRenderer->mBuffers->BindEyeFB(eye, true); - if (eyeTexture->handle == nullptr) { - GLuint handle; - glGenTextures(1, &handle); - eyeTexture->handle = (void *)handle; - glBindTexture(GL_TEXTURE_2D, handle); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, GLRenderer->mSceneViewport.width, - GLRenderer->mSceneViewport.height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); - } - glBindTexture(GL_TEXTURE_2D, (GLuint)eyeTexture->handle); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 0, 0, - GLRenderer->mSceneViewport.width, - GLRenderer->mSceneViewport.height, 0); - vr::VRCompositor()->Submit(vr::EVREye(eye), eyeTexture); - return true; -} - - -OpenVRMode::OpenVRMode() - : vrSystem(nullptr) - , leftEyeView(vr::Eye_Left) - , rightEyeView(vr::Eye_Right) - , hmdWasFound(false) - , sceneWidth(0), sceneHeight(0) -{ - eye_ptrs.Push(&leftEyeView); // default behavior to Mono non-stereo rendering - - EVRInitError eError; - if (VR_IsHmdPresent()) - { - vrSystem = VR_Init(&eError, VRApplication_Scene); - if (eError != vr::VRInitError_None) { - std::string errMsg = VR_GetVRInitErrorAsEnglishDescription(eError); - vrSystem = nullptr; - return; - // TODO: report error - } - vrSystem->GetRecommendedRenderTargetSize(&sceneWidth, &sceneHeight); - - // OK - leftEyeView.initialize(*vrSystem); - rightEyeView.initialize(*vrSystem); - - if (!vr::VRCompositor()) - return; - - eye_ptrs.Push(&rightEyeView); // NOW we render to two eyes - hmdWasFound = true; - } -} - -/* virtual */ -// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...) -void OpenVRMode::AdjustViewports() const -{ - // Draw the 3D scene into the entire framebuffer - GLRenderer->mSceneViewport.width = sceneWidth; - GLRenderer->mSceneViewport.height = sceneHeight; - GLRenderer->mSceneViewport.left = 0; - GLRenderer->mSceneViewport.top = 0; - - GLRenderer->mScreenViewport.width = sceneWidth; - GLRenderer->mScreenViewport.height = sceneHeight; -} - -/* virtual */ -void OpenVRMode::Present() const { - // TODO: For performance, don't render to the desktop screen here - if (doRenderToDesktop) { - GLRenderer->mBuffers->BindOutputFB(); - GLRenderer->ClearBorders(); - - // Compute screen regions to use for left and right eye views - int leftWidth = GLRenderer->mOutputLetterbox.width / 2; - int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; - GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; - leftHalfScreen.width = leftWidth; - GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; - rightHalfScreen.width = rightWidth; - rightHalfScreen.left += leftWidth; - - GLRenderer->mBuffers->BindEyeTexture(0, 0); - GLRenderer->DrawPresentTexture(leftHalfScreen, true); - GLRenderer->mBuffers->BindEyeTexture(1, 0); - GLRenderer->DrawPresentTexture(rightHalfScreen, true); - } - - if (doRenderToHmd) - { - leftEyeView.submitFrame(); - rightEyeView.submitFrame(); - } -} - -static int mAngleFromRadians(double radians) -{ - double m = std::round(65535.0 * radians / (2.0 * M_PI)); - return int(m); -} - -void OpenVRMode::updateHmdPose( - double hmdYawRadians, - double hmdPitchRadians, - double hmdRollRadians) const -{ - double hmdyaw = hmdYawRadians; - double hmdpitch = hmdPitchRadians; - double hmdroll = hmdRollRadians; - - double dYaw = 0; - if (doTrackHmdYaw) { - // Set HMD angle game state parameters for NEXT frame - static double previousYaw = 0; - static bool havePreviousYaw = false; - if (!havePreviousYaw) { - previousYaw = hmdyaw; - havePreviousYaw = true; - } - dYaw = hmdyaw - previousYaw; - G_AddViewAngle(mAngleFromRadians(-dYaw)); - previousYaw = hmdyaw; - } - - /* */ - // Pitch - if (doTrackHmdPitch) { - double hmdPitchInDoom = -atan(tan(hmdpitch) / level.info->pixelstretch); - double viewPitchInDoom = GLRenderer->mAngles.Pitch.Radians(); - double dPitch = hmdPitchInDoom - viewPitchInDoom; - G_AddViewPitch(mAngleFromRadians(-dPitch)); - } - - // Roll can be local, because it doesn't affect gameplay. - if (doTrackHmdRoll) - GLRenderer->mAngles.Roll = RAD2DEG(-hmdroll); - - // Late-schedule update to renderer angles directly, too - if (doLateScheduledRotationTracking) { - if (doTrackHmdPitch) - GLRenderer->mAngles.Pitch = RAD2DEG(-hmdpitch); - if (doTrackHmdYaw) - GLRenderer->mAngles.Yaw += RAD2DEG(dYaw); // "plus" is the correct direction - } -} - -/* virtual */ -void OpenVRMode::SetUp() const -{ - super::SetUp(); - - cachedScreenBlocks = screenblocks; - screenblocks = 12; // always be full-screen during 3D scene render - - if (vr::VRCompositor() == nullptr) - return; - - static vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]; - vr::VRCompositor()->WaitGetPoses( - poses, vr::k_unMaxTrackedDeviceCount, // current pose - nullptr, 0 // future pose? - ); - - TrackedDevicePose_t& hmdPose0 = poses[vr::k_unTrackedDeviceIndex_Hmd]; - - if (hmdPose0.bPoseIsValid) { - const vr::HmdMatrix34_t& hmdPose = hmdPose0.mDeviceToAbsoluteTracking; - HmdVector3d_t eulerAngles = eulerAnglesFromMatrix(hmdPose); - // Printf("%.1f %.1f %.1f\n", eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); - updateHmdPose(eulerAngles.v[0], eulerAngles.v[1], eulerAngles.v[2]); - leftEyeView.setCurrentHmdPose(&hmdPose0); - rightEyeView.setCurrentHmdPose(&hmdPose0); - // TODO: position tracking - } -} - -/* virtual */ -void OpenVRMode::TearDown() const -{ - screenblocks = cachedScreenBlocks; - super::TearDown(); -} - -/* virtual */ -OpenVRMode::~OpenVRMode() -{ - if (vrSystem != nullptr) { - VR_Shutdown(); - vrSystem = nullptr; - leftEyeView.dispose(); - rightEyeView.dispose(); - } -} - -} /* namespace s3d */ - -#endif - diff --git a/src/gl/stereo3d/gl_openvr.h b/src/gl/stereo3d/gl_openvr.h deleted file mode 100644 index 9fc905207..000000000 --- a/src/gl/stereo3d/gl_openvr.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -** gl_openvr.h -** Stereoscopic virtual reality mode for the HTC Vive headset -** -**--------------------------------------------------------------------------- -** Copyright 2016 Christopher Bruns -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** -*/ - -#ifndef GL_OPENVR_H_ -#define GL_OPENVR_H_ - -#include "gl_stereo3d.h" -#include "gl_stereo_leftright.h" - -// forward declaration from openvr.h -namespace vr { - class IVRSystem; - struct HmdMatrix44_t; - struct Texture_t; - struct TrackedDevicePose_t; -} - -/* stereoscopic 3D API */ -namespace s3d { - -class OpenVREyePose : public ShiftedEyePose -{ -public: - OpenVREyePose(int eye); - virtual ~OpenVREyePose() override; - virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const override; - virtual void GetViewShift(float yaw, float outViewShift[3]) const override; - - void initialize(vr::IVRSystem& vrsystem); - void dispose(); - void setCurrentHmdPose(const vr::TrackedDevicePose_t * pose) const {currentPose = pose;} - bool submitFrame() const; - -protected: - VSMatrix projectionMatrix; - VSMatrix eyeToHeadTransform; - VSMatrix otherEyeToHeadTransform; - vr::Texture_t* eyeTexture; - int eye; - - // TODO: adjust doomUnitsPerMeter according to player height - float verticalDoomUnitsPerMeter; - - mutable const vr::TrackedDevicePose_t * currentPose; -}; - -class OpenVRMode : public Stereo3DMode -{ -public: - static const Stereo3DMode& getInstance(); // Might return Mono mode, if no HMD available - - virtual ~OpenVRMode() override; - virtual void SetUp() const override; // called immediately before rendering a scene frame - virtual void TearDown() const override; // called immediately after rendering a scene frame - virtual void Present() const override; - virtual void AdjustViewports() const override; - -protected: - OpenVRMode(); - // void updateDoomViewDirection() const; - void updateHmdPose(double hmdYawRadians, double hmdPitchRadians, double hmdRollRadians) const; - - OpenVREyePose leftEyeView; - OpenVREyePose rightEyeView; - - vr::IVRSystem* vrSystem; - mutable int cachedScreenBlocks; - -private: - typedef Stereo3DMode super; - bool hmdWasFound; - uint32_t sceneWidth, sceneHeight; -}; - -} /* namespace st3d */ - - -#endif /* GL_OPENVR_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index 7c87290e4..201e33590 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -25,12 +25,10 @@ ** */ -#include "gl_stereo3d.h" -#include "gl_stereo_leftright.h" -#include "gl_anaglyph.h" -#include "gl_openvr.h" -#include "gl_quadstereo.h" -#include "gl_sidebyside3d.h" +#include "gl/stereo3d/gl_stereo3d.h" +#include "gl/stereo3d/gl_stereo_leftright.h" +#include "gl/stereo3d/gl_anaglyph.h" +#include "gl/stereo3d/gl_quadstereo.h" #include "gl/stereo3d/gl_sidebyside3d.h" #include "gl/stereo3d/gl_interleaved3d.h" #include "gl/system/gl_cvars.h" @@ -103,12 +101,8 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() // TODO: 8: Oculus Rift case 9: setCurrentMode(AmberBlue::getInstance(vr_ipd)); - break; -#ifdef USE_OPENVR - case 10: - setCurrentMode(OpenVRMode::getInstance()); - break; -#endif + break; + // TODO: 10: HTC Vive/OpenVR case 11: setCurrentMode(TopBottom3D::getInstance(vr_ipd)); break; diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp index 5aa1ed08d..ac2b89a27 100644 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -31,7 +31,7 @@ namespace s3d { -ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in doom units +ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters { // save original values cachedView = r_viewpoint.Pos; diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index 1306adec1..bac7f2dac 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -40,7 +40,7 @@ namespace s3d { class ScopedViewShifter { public: - ScopedViewShifter(float dxyz[3]); // in doom units + ScopedViewShifter(float dxyz[3]); // in meters ~ScopedViewShifter(); private: diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index bb428fa60..01d316c24 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2797,7 +2797,6 @@ OPTVAL_ROWINTERLEAVED = "Row Interleaved"; OPTVAL_COLUMNINTERLEAVED = "Column Interleaved"; OPTVAL_CHECKERBOARD = "Checkerboard"; OPTVAL_QUADBUFFERED = "Quad-buffered"; -OPTVAL_OPENVR = "OpenVR-Vive"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; OPTVAL_REINHARD = "Reinhard"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index f633e150e..148238c9c 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2108,7 +2108,6 @@ OptionValue VRMode 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED" - 10, "$OPTVAL_OPENVR" } OptionMenu "GLTextureGLOptions" protected From 28950b8a5d9fe4de8d3544944e49a2ddafe11474 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 10 Jul 2017 13:15:52 -0400 Subject: [PATCH 75/82] - q2.1pre version --- src/version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/version.h b/src/version.h index e939eecd2..461b821ab 100644 --- a/src/version.h +++ b/src/version.h @@ -48,12 +48,12 @@ const char *GetVersionString(); #ifdef GIT_DESCRIPTION #define VERSIONSTR GIT_DESCRIPTION #else -#define VERSIONSTR "1.4pre" +#define VERSIONSTR "2.1pre" #endif // The version as seen in the Windows resource -#define RC_FILEVERSION 1,4,9999,0 -#define RC_PRODUCTVERSION 1,4,9999,0 +#define RC_FILEVERSION 2,1,9999,0 +#define RC_PRODUCTVERSION 2,1,9999,0 #define RC_PRODUCTVERSION2 VERSIONSTR // These are for content versioning. The current state is '3.2'. #define VER_MAJOR 3 From 7d1de667befd80ef1f64082d358e1c813f453511 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 12 Jul 2017 06:56:34 +0200 Subject: [PATCH 76/82] - Added r_line_distance_cull cvar that culls lines beyond the specified distance --- src/CMakeLists.txt | 1 + src/swrenderer/line/r_farclip_line.cpp | 190 +++++++++++++++++++++++++ src/swrenderer/line/r_farclip_line.h | 60 ++++++++ src/swrenderer/r_all.cpp | 1 + src/swrenderer/scene/r_opaque_pass.cpp | 26 +++- 5 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 src/swrenderer/line/r_farclip_line.cpp create mode 100644 src/swrenderer/line/r_farclip_line.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c862d27e5..d44a60b8e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -691,6 +691,7 @@ set ( SWRENDER_SOURCES swrenderer/viewport/r_viewport.cpp swrenderer/viewport/r_walldrawer.cpp swrenderer/line/r_line.cpp + swrenderer/line/r_farclip_line.cpp swrenderer/line/r_walldraw.cpp swrenderer/line/r_wallsetup.cpp swrenderer/line/r_fogboundary.cpp diff --git a/src/swrenderer/line/r_farclip_line.cpp b/src/swrenderer/line/r_farclip_line.cpp new file mode 100644 index 000000000..95e559a24 --- /dev/null +++ b/src/swrenderer/line/r_farclip_line.cpp @@ -0,0 +1,190 @@ +//----------------------------------------------------------------------------- +// +// Copyright 2016 Magnus Norddahl +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//----------------------------------------------------------------------------- +// + +#include +#include +#include "templates.h" +#include "i_system.h" +#include "doomdef.h" +#include "doomstat.h" +#include "doomdata.h" +#include "p_lnspec.h" +#include "p_setup.h" +#include "r_sky.h" +#include "v_video.h" +#include "m_swap.h" +#include "w_wad.h" +#include "stats.h" +#include "a_sharedglobal.h" +#include "d_net.h" +#include "g_level.h" +#include "g_levellocals.h" +#include "r_wallsetup.h" +#include "v_palette.h" +#include "r_utility.h" +#include "r_data/colormaps.h" +#include "swrenderer/r_memory.h" +#include "swrenderer/scene/r_opaque_pass.h" +#include "swrenderer/scene/r_3dfloors.h" +#include "swrenderer/scene/r_portal.h" +#include "swrenderer/scene/r_light.h" +#include "swrenderer/scene/r_scene.h" +#include "swrenderer/viewport/r_viewport.h" +#include "swrenderer/line/r_farclip_line.h" +#include "swrenderer/line/r_walldraw.h" +#include "swrenderer/line/r_wallsetup.h" +#include "swrenderer/drawers/r_draw.h" +#include "swrenderer/segments/r_clipsegment.h" +#include "swrenderer/segments/r_drawsegment.h" +#include "swrenderer/plane/r_visibleplane.h" +#include "swrenderer/plane/r_visibleplanelist.h" +#include "swrenderer/viewport/r_skydrawer.h" +#include "swrenderer/r_renderthread.h" + +namespace swrenderer +{ + FarClipLine::FarClipLine(RenderThread *thread) + { + Thread = thread; + } + + void FarClipLine::Render(seg_t *line, subsector_t *subsector, VisiblePlane *linefloorplane, VisiblePlane *lineceilingplane) + { + mSubsector = subsector; + mFrontSector = mSubsector->sector; + mLineSegment = line; + mFloorPlane = linefloorplane; + mCeilingPlane = lineceilingplane; + + DVector2 pt1 = line->v1->fPos() - Thread->Viewport->viewpoint.Pos; + DVector2 pt2 = line->v2->fPos() - Thread->Viewport->viewpoint.Pos; + + // Reject lines not facing viewer + if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0) + return; + + if (WallC.Init(Thread, pt1, pt2, 32.0 / (1 << 12))) + return; + + RenderPortal *renderportal = Thread->Portal.get(); + if (WallC.sx1 >= renderportal->WindowRight || WallC.sx2 <= renderportal->WindowLeft) + return; + + if (line->linedef == nullptr) + return; + + // reject lines that aren't seen from the portal (if any) + // [ZZ] 10.01.2016: lines inside a skybox shouldn't be clipped, although this imposes some limitations on portals in skyboxes. + if (!renderportal->CurrentPortalInSkybox && renderportal->CurrentPortal && P_ClipLineToPortal(line->linedef, renderportal->CurrentPortal->dst, Thread->Viewport->viewpoint.Pos)) + return; + + mFrontCeilingZ1 = mFrontSector->ceilingplane.ZatPoint(line->v1); + mFrontFloorZ1 = mFrontSector->floorplane.ZatPoint(line->v1); + mFrontCeilingZ2 = mFrontSector->ceilingplane.ZatPoint(line->v2); + mFrontFloorZ2 = mFrontSector->floorplane.ZatPoint(line->v2); + + mPrepped = false; + + Thread->ClipSegments->Clip(WallC.sx1, WallC.sx2, true, this); + } + + bool FarClipLine::RenderWallSegment(int x1, int x2) + { + if (!mPrepped) + { + mPrepped = true; + + //walltop.Project(Thread->Viewport.get(), mFrontSector->ceilingplane, &WallC, mLineSegment, Thread->Portal->MirrorFlags & RF_XFLIP); + wallbottom.Project(Thread->Viewport.get(), mFrontSector->floorplane, &WallC, mLineSegment, Thread->Portal->MirrorFlags & RF_XFLIP); + memcpy(walltop.ScreenY, wallbottom.ScreenY, sizeof(short) * MAXWIDTH); + } + + ClipSegmentTopBottom(x1, x2); + MarkCeilingPlane(x1, x2); + MarkFloorPlane(x1, x2); + + return true; + } + + void FarClipLine::ClipSegmentTopBottom(int x1, int x2) + { + // clip wall to the floor and ceiling + auto ceilingclip = Thread->OpaquePass->ceilingclip; + auto floorclip = Thread->OpaquePass->floorclip; + for (int x = x1; x < x2; ++x) + { + if (walltop.ScreenY[x] < ceilingclip[x]) + { + walltop.ScreenY[x] = ceilingclip[x]; + } + if (wallbottom.ScreenY[x] > floorclip[x]) + { + wallbottom.ScreenY[x] = floorclip[x]; + } + } + } + + void FarClipLine::MarkCeilingPlane(int x1, int x2) + { + if (mCeilingPlane) + { + mCeilingPlane = Thread->PlaneList->GetRange(mCeilingPlane, x1, x2); + + auto ceilingclip = Thread->OpaquePass->ceilingclip; + auto floorclip = Thread->OpaquePass->floorclip; + Clip3DFloors *clip3d = Thread->Clip3D.get(); + + for (int x = x1; x < x2; ++x) + { + short top = (clip3d->fakeFloor && clip3d->fake3D & FAKE3D_FAKECEILING) ? clip3d->fakeFloor->ceilingclip[x] : ceilingclip[x]; + short bottom = MIN(walltop.ScreenY[x], floorclip[x]); + if (top < bottom) + { + mCeilingPlane->top[x] = top; + mCeilingPlane->bottom[x] = bottom; + } + } + } + } + + void FarClipLine::MarkFloorPlane(int x1, int x2) + { + if (mFloorPlane) + { + mFloorPlane = Thread->PlaneList->GetRange(mFloorPlane, x1, x2); + + auto ceilingclip = Thread->OpaquePass->ceilingclip; + auto floorclip = Thread->OpaquePass->floorclip; + Clip3DFloors *clip3d = Thread->Clip3D.get(); + + for (int x = x1; x < x2; ++x) + { + short top = MAX(wallbottom.ScreenY[x], ceilingclip[x]); + short bottom = (clip3d->fakeFloor && clip3d->fake3D & FAKE3D_FAKEFLOOR) ? clip3d->fakeFloor->floorclip[x] : floorclip[x]; + if (top < bottom) + { + assert(bottom <= viewheight); + mFloorPlane->top[x] = top; + mFloorPlane->bottom[x] = bottom; + } + } + } + } +} diff --git a/src/swrenderer/line/r_farclip_line.h b/src/swrenderer/line/r_farclip_line.h new file mode 100644 index 000000000..c450a6383 --- /dev/null +++ b/src/swrenderer/line/r_farclip_line.h @@ -0,0 +1,60 @@ +//----------------------------------------------------------------------------- +// +// Copyright 2016 Magnus Norddahl +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//----------------------------------------------------------------------------- +// + +#pragma once + +#include "r_line.h" + +namespace swrenderer +{ + class FarClipLine : VisibleSegmentRenderer + { + public: + FarClipLine(RenderThread *thread); + void Render(seg_t *line, subsector_t *subsector, VisiblePlane *linefloorplane, VisiblePlane *lineceilingplane); + + RenderThread *Thread = nullptr; + + private: + bool RenderWallSegment(int x1, int x2) override; + + void ClipSegmentTopBottom(int x1, int x2); + void MarkCeilingPlane(int x1, int x2); + void MarkFloorPlane(int x1, int x2); + + subsector_t *mSubsector; + sector_t *mFrontSector; + seg_t *mLineSegment; + VisiblePlane *mFloorPlane; + VisiblePlane *mCeilingPlane; + + double mFrontCeilingZ1; + double mFrontCeilingZ2; + double mFrontFloorZ1; + double mFrontFloorZ2; + + FWallCoords WallC; + + bool mPrepped; + + ProjectedWallLine walltop; + ProjectedWallLine wallbottom; + }; +} diff --git a/src/swrenderer/r_all.cpp b/src/swrenderer/r_all.cpp index 20a9f4ee8..296fc04cf 100644 --- a/src/swrenderer/r_all.cpp +++ b/src/swrenderer/r_all.cpp @@ -9,6 +9,7 @@ #include "drawers/r_thread.cpp" #include "line/r_fogboundary.cpp" #include "line/r_line.cpp" +#include "line/r_farclip_line.cpp" #include "line/r_renderdrawsegment.cpp" #include "line/r_walldraw.cpp" #include "line/r_wallsetup.cpp" diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index da820d7d2..1c190d7df 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -47,6 +47,7 @@ #include "swrenderer/things/r_particle.h" #include "swrenderer/segments/r_clipsegment.h" #include "swrenderer/line/r_wallsetup.h" +#include "swrenderer/line/r_farclip_line.h" #include "swrenderer/scene/r_scene.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/viewport/r_viewport.h" @@ -72,6 +73,20 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); EXTERN_CVAR(Bool, r_drawvoxels); +namespace { double line_distance_cull = 1e16; } + +CUSTOM_CVAR(Float, r_line_distance_cull, 8000.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (r_line_distance_cull > 0.0) + { + line_distance_cull = r_line_distance_cull * r_line_distance_cull; + } + else + { + line_distance_cull = 1e16; + } +} + namespace swrenderer { RenderOpaquePass::RenderOpaquePass(RenderThread *thread) : renderline(thread) @@ -730,10 +745,19 @@ namespace swrenderer count = sub->numlines; line = sub->firstline; + DVector2 viewpointPos = Thread->Viewport->viewpoint.Pos.XY(); + basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]); while (count--) { - if (!outersubsector || line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) + double dist1 = (line->v1->fPos() - viewpointPos).LengthSquared(); + double dist2 = (line->v2->fPos() - viewpointPos).LengthSquared(); + if (dist1 > line_distance_cull && dist2 > line_distance_cull) + { + FarClipLine farclip(Thread); + farclip.Render(line, InSubsector, floorplane, ceilingplane); + } + else if (!outersubsector || line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ)) { // kg3D - fake planes bounding calculation if (r_3dfloors && line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size()) From 7728875a7f9fb39344af23da43837158d9f64032 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 13 Jul 2017 05:57:12 -0400 Subject: [PATCH 77/82] - Added 'enabled' property for PP shaders, to automatically enable them without ZScript --- src/gl/shaders/gl_shader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index c944f27c5..b0b3ea32b 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -723,6 +723,10 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump) if (parsedType != PostProcessUniformType::Undefined) shaderdesc.Uniforms[uniformName].Type = parsedType; } + else if (sc.Compare("enabled")) + { + shaderdesc.Enabled = true; + } } PostProcessShaders.Push(shaderdesc); From 9eb0b64ab09937d39464d9e6e2910285a674200d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 15 Jul 2017 03:38:10 -0400 Subject: [PATCH 78/82] - Added new "sv_damagefactor*" variables. sv_damagefactorplayer: Scales damage for player sv_damagefactorfriendly: Scales damage for all other +FRIENDLY objects sv_damagefactormobj: Scales damage for everything else (incl. monsters and decorations) --- src/p_interaction.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index f9c027c35..8329faea0 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -79,6 +79,9 @@ CVAR (Bool, cl_showsprees, true, CVAR_ARCHIVE) CVAR (Bool, cl_showmultikills, true, CVAR_ARCHIVE) EXTERN_CVAR (Bool, show_obituaries) +CVAR (Float, sv_damagefactormobj, 1.0, CVAR_SERVERINFO|CVAR_NOSAVE) +CVAR (Float, sv_damagefactorfriendly, 1.0, CVAR_SERVERINFO|CVAR_NOSAVE) +CVAR (Float, sv_damagefactorplayer, 1.0, CVAR_SERVERINFO|CVAR_NOSAVE) FName MeansOfDeath; @@ -1036,7 +1039,17 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da if (player && damage > 1) { // Take half damage in trainer mode - damage = int(damage * G_SkillProperty(SKILLP_DamageFactor)); + damage = int(damage * G_SkillProperty(SKILLP_DamageFactor) * sv_damagefactorplayer); + } + else if (!player && damage > 1 && !(target->flags & MF_FRIENDLY)) + { + // inflict scaled damage to non-players + damage = int(damage * sv_damagefactormobj); + } + else if (!player && damage > 1 && (target->flags & MF_FRIENDLY)) + { + // inflict scaled damage to non-player friends + damage = int(damage * sv_damagefactorfriendly); } // Special damage types if (inflictor) @@ -1865,7 +1878,7 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPain return; } // Take half damage in trainer mode - damage = int(damage * G_SkillProperty(SKILLP_DamageFactor)); + damage = int(damage * G_SkillProperty(SKILLP_DamageFactor) * sv_damagefactorplayer); // Handle passive damage modifiers (e.g. PowerProtection) damage = target->GetModifiedDamage(player->poisontype, damage, true); // Modify with damage factors From 1f6d15c741c59488f1717187066f2a4cd0a3878d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 19 Jul 2017 06:11:29 -0400 Subject: [PATCH 79/82] - Rename QZDoom back to GZDoom again for merge. --- CMakeLists.txt | 4 ++-- src/posix/cocoa/i_video.mm | 2 +- src/posix/sdl/hardware.cpp | 2 +- src/version.h | 20 ++++++++++---------- src/win32/hardware.cpp | 2 +- src/win32/zdoom.rc | 20 ++++++++++---------- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 277fec59c..d4b402326 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8.7 ) -project(QZDoom) +project(GZDoom) if( COMMAND cmake_policy ) if( POLICY CMP0011 ) @@ -122,7 +122,7 @@ IF( NOT CMAKE_BUILD_TYPE ) ENDIF() set( ZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where zdoom.pk3 and the executable will be created." ) -set( ZDOOM_EXE_NAME "qzdoom" CACHE FILEPATH "Name of the executable to create" ) +set( ZDOOM_EXE_NAME "gzdoom" CACHE FILEPATH "Name of the executable to create" ) if( MSVC ) # Allow the user to use ZDOOM_OUTPUT_DIR as a single release point. # Use zdoom, zdoomd, zdoom64, and zdoomd64 for the binary names diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index fe0912057..d15a20737 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -162,7 +162,7 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ Printf("You must restart " GAMENAME " to apply graphics switching mode\n"); } -CUSTOM_CVAR(Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 3fb408c1c..20ff59325 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -65,7 +65,7 @@ void I_RestartRenderer(); int currentrenderer; // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/version.h b/src/version.h index 461b821ab..11158099d 100644 --- a/src/version.h +++ b/src/version.h @@ -48,14 +48,14 @@ const char *GetVersionString(); #ifdef GIT_DESCRIPTION #define VERSIONSTR GIT_DESCRIPTION #else -#define VERSIONSTR "2.1pre" +#define VERSIONSTR "3.2pre" #endif // The version as seen in the Windows resource -#define RC_FILEVERSION 2,1,9999,0 -#define RC_PRODUCTVERSION 2,1,9999,0 +#define RC_FILEVERSION 3,1,9999,0 +#define RC_PRODUCTVERSION 3,1,9999,0 #define RC_PRODUCTVERSION2 VERSIONSTR -// These are for content versioning. The current state is '3.2'. +// These are for content versioning. The current state is '2.4'. #define VER_MAJOR 3 #define VER_MINOR 2 #define VER_REVISION 0 @@ -94,15 +94,15 @@ const char *GetVersionString(); #define SAVEVER 4552 // This is so that derivates can use the same savegame versions without worrying about engine compatibility -#define GAMESIG "QZDOOM" -#define BASEWAD "qzdoom.pk3" +#define GAMESIG "GZDOOM" +#define BASEWAD "gzdoom.pk3" #define BASESF "gzdoom.sf2" // More stuff that needs to be different for derivatives. -#define GAMENAME "QZDoom" -#define GAMENAMELOWERCASE "qzdoom" -#define FORUM_URL "http://forum.drdteam.org/viewforum.php?f=196" -#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=197" +#define GAMENAME "GZDoom" +#define GAMENAMELOWERCASE "gzdoom" +#define FORUM_URL "http://forum.drdteam.org" +#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24" #if defined(__APPLE__) || defined(_WIN32) #define GAME_DIR GAMENAME diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 2c5987726..599fe00a5 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -107,7 +107,7 @@ CUSTOM_CVAR(Bool, vid_glswfb, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOI } // [ZDoomGL] -CUSTOM_CVAR (Int, vid_renderer, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index cede1e894..0d21faae5 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -72,13 +72,13 @@ BEGIN " BEGIN\r\n" " VALUE ""Comments"", ""Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg.""\r\n" " VALUE ""CompanyName"", "" ""\r\n" - " VALUE ""FileDescription"", ""QZDoom""\r\n" + " VALUE ""FileDescription"", ""GZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" - " VALUE ""InternalName"", ""QZDoom""\r\n" + " VALUE ""InternalName"", ""GZDoom""\r\n" " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" - " VALUE ""OriginalFilename"", ""qzdoom.exe""\r\n" - " VALUE ""ProductName"", ""QZDoom""\r\n" + " VALUE ""OriginalFilename"", ""gzdoom.exe""\r\n" + " VALUE ""ProductName"", ""GZDoom""\r\n" " VALUE ""ProductVersion"", RC_PRODUCTVERSION2\r\n" " END\r\n" " END\r\n" @@ -228,7 +228,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US FONT 8, "MS Shell Dlg" { CONTROL 101, IDC_STATIC, STATIC, SS_ICON | WS_CHILD | WS_VISIBLE, 7, 7, 21, 20 - CONTROL "Welcome to QZDoom!", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 8, 180, 8 + CONTROL "Welcome to GZDoom!", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 8, 180, 8 CONTROL "", IDC_WELCOME_VERSION, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 42, 18, 180, 8 CONTROL "IWAD selection", IDC_STATIC, BUTTON, BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 8, 32, 208, 117 CONTROL "Select which game file (IWAD) to run.", IDC_STATIC, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 12, 44, 190, 8 @@ -242,7 +242,7 @@ FONT 8, "MS Shell Dlg" CONTROL "Load lights", IDC_WELCOME_LIGHTS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 180, 51, 10 CONTROL "Load brightmaps", IDC_WELCOME_BRIGHTMAPS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 190, 65, 10 CONTROL "Don't ask me this again", IDC_DONTASKIWAD, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 73, 211, 87, 10 - CONTROL "Play QZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 + CONTROL "Play GZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14 CONTROL "Exit", IDCANCEL, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 228, 50, 14 } @@ -504,13 +504,13 @@ BEGIN BEGIN VALUE "Comments", "Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg." VALUE "CompanyName", " " - VALUE "FileDescription", "QZDoom" + VALUE "FileDescription", "GZDoom" VALUE "FileVersion", RC_FILEVERSION2 - VALUE "InternalName", "QZDoom" + VALUE "InternalName", "GZDoom" VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc." - VALUE "OriginalFilename", "qzdoom.exe" - VALUE "ProductName", "QZDoom" + VALUE "OriginalFilename", "gzdoom.exe" + VALUE "ProductName", "GZDoom" VALUE "ProductVersion", RC_PRODUCTVERSION2 END END From f4e0690c414742f5184246b5e3b8aa71a993ee58 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 20 Jul 2017 06:45:08 -0400 Subject: [PATCH 80/82] - missed one qzdoom reference --- wadsrc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/CMakeLists.txt b/wadsrc/CMakeLists.txt index 5a85840e0..80189a328 100644 --- a/wadsrc/CMakeLists.txt +++ b/wadsrc/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required( VERSION 2.8.7 ) -add_pk3(qzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) +add_pk3(gzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) From ffc529d100e22ff281050b940ce8796306d927d2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 20 Jul 2017 14:23:45 +0200 Subject: [PATCH 81/82] - let r_*_cull variables default to 0. --- src/swrenderer/scene/r_opaque_pass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 478b5e759..b772d62a4 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -79,7 +79,7 @@ namespace double line_distance_cull = 1e16; } -CUSTOM_CVAR(Float, r_sprite_distance_cull, 5000.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Float, r_sprite_distance_cull, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { if (r_sprite_distance_cull > 0.0) { @@ -91,7 +91,7 @@ CUSTOM_CVAR(Float, r_sprite_distance_cull, 5000.0, CVAR_ARCHIVE | CVAR_GLOBALCON } } -CUSTOM_CVAR(Float, r_line_distance_cull, 8000.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Float, r_line_distance_cull, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { if (r_line_distance_cull > 0.0) { From e8e940d22137ec03293ee04b7f18852380d084ba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 20 Jul 2017 18:32:54 +0200 Subject: [PATCH 82/82] - fixed portal handling for P_CheckMissileSpawn to obey commonly established rules about portal types. --- src/p_mobj.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 3f82c7190..e2646ade8 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6718,7 +6718,7 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist) th->tics = 1; } - DVector3 newpos = th->Pos(); + DVector3 newpos = { 0,0,0 }; if (maxdist > 0) { @@ -6736,6 +6736,9 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist) newpos += advance; } + newpos = th->Vec3Offset(newpos); + th->SetXYZ(newpos); + FCheckPosition tm(!!(th->flags2 & MF2_RIP)); // killough 8/12/98: for non-missile objects (e.g. grenades)