From 99be1151f7ae21460aae85a4d017a726033e2ccf Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 24 Jun 2024 21:17:45 -0500 Subject: [PATCH 1/5] Fix web client vid_restart with r_mode -2 If getting the display index of the existing window fails, fallback to the default display size instead of falling back to 640x480. emscripten r_mode -2 worked on window creation but vid_restart fellback to 640x480. --- code/sdl/sdl_glimp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/sdl/sdl_glimp.c b/code/sdl/sdl_glimp.c index 2678dc71..5ce1e47d 100644 --- a/code/sdl/sdl_glimp.c +++ b/code/sdl/sdl_glimp.c @@ -438,10 +438,11 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool if( display < 0 ) { ri.Printf( PRINT_DEVELOPER, "SDL_GetWindowDisplayIndex() failed: %s\n", SDL_GetError() ); + display = 0; } } - if( display >= 0 && SDL_GetDesktopDisplayMode( display, &desktopMode ) == 0 ) + if( SDL_GetDesktopDisplayMode( display, &desktopMode ) == 0 ) { displayAspect = (float)desktopMode.w / (float)desktopMode.h; From e505e34d79d40585a5e2731c459404aefb0b2d1b Mon Sep 17 00:00:00 2001 From: James Darpinian Date: Mon, 24 Jun 2024 23:52:11 -0700 Subject: [PATCH 2/5] Fix framerate throttling in Emscripten builds Default com_maxfps to 0 under Emscripten. Under Emscripten the browser handles throttling the frame rate. Manual framerate throttling interacts poorly with Emscripten's browser-driven event loop. --- code/qcommon/common.c | 7 +++++++ code/renderergl2/tr_init.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/code/qcommon/common.c b/code/qcommon/common.c index aeab6e2e..01ddebf8 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -2741,7 +2741,14 @@ void Com_Init( char *commandLine ) { // init commands and vars // com_altivec = Cvar_Get ("com_altivec", "1", CVAR_ARCHIVE); +#ifdef __EMSCRIPTEN__ + // Under Emscripten the browser handles throttling the frame rate. + // Manual framerate throttling interacts poorly with Emscripten's + // browser-driven event loop. So default throttling to off. + com_maxfps = Cvar_Get ("com_maxfps", "0", CVAR_ARCHIVE); +#else com_maxfps = Cvar_Get ("com_maxfps", "85", CVAR_ARCHIVE); +#endif com_blood = Cvar_Get ("com_blood", "1", CVAR_ARCHIVE); com_logfile = Cvar_Get ("logfile", "0", CVAR_TEMP ); diff --git a/code/renderergl2/tr_init.c b/code/renderergl2/tr_init.c index 48da9ce3..12bac4b0 100644 --- a/code/renderergl2/tr_init.c +++ b/code/renderergl2/tr_init.c @@ -1365,8 +1365,15 @@ void R_Register( void ) r_dlightBacks = ri.Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE ); r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_LINEAR", CVAR_ARCHIVE ); +#ifdef __EMSCRIPTEN__ + // Under Emscripten we don't throttle framerate with com_maxfps by default, so enable + // vsync by default instead. + r_swapInterval = ri.Cvar_Get( "r_swapInterval", "1", + CVAR_ARCHIVE | CVAR_LATCH ); +#else r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0", CVAR_ARCHIVE | CVAR_LATCH ); +#endif r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); From 15f5fe78ad61f7bb0684b420f1d768a87e193a87 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 13 Jul 2024 22:40:07 -0500 Subject: [PATCH 3/5] Fix compiling without PATCH_STITCHING defined --- code/renderergl1/tr_curve.c | 6 +++--- code/renderergl2/tr_curve.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/renderergl1/tr_curve.c b/code/renderergl1/tr_curve.c index eaabba46..c5c9d98d 100644 --- a/code/renderergl1/tr_curve.c +++ b/code/renderergl1/tr_curve.c @@ -306,13 +306,13 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, grid->heightLodError = /*ri.Hunk_Alloc*/ ri.Malloc( height * 4 ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); #else - grid = ri.Hunk_Alloc( size ); + grid = ri.Hunk_Alloc( size, h_low ); Com_Memset(grid, 0, size); - grid->widthLodError = ri.Hunk_Alloc( width * 4 ); + grid->widthLodError = ri.Hunk_Alloc( width * 4, h_low ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = ri.Hunk_Alloc( height * 4 ); + grid->heightLodError = ri.Hunk_Alloc( height * 4, h_low ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); #endif diff --git a/code/renderergl2/tr_curve.c b/code/renderergl2/tr_curve.c index d175789b..54910d04 100644 --- a/code/renderergl2/tr_curve.c +++ b/code/renderergl2/tr_curve.c @@ -388,10 +388,10 @@ void R_CreateSurfaceGridMesh(srfBspSurface_t *grid, int width, int height, grid->numVerts = (width * height); grid->verts = ri.Malloc(grid->numVerts * sizeof(srfVert_t)); #else - grid->widthLodError = ri.Hunk_Alloc( width * 4 ); + grid->widthLodError = ri.Hunk_Alloc( width * 4, h_low ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = ri.Hunk_Alloc( height * 4 ); + grid->heightLodError = ri.Hunk_Alloc( height * 4, h_low ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numIndexes = numIndexes; From 4c19ff2b55e6dd3d97c681112821de0556f78d4a Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 27 Jul 2024 00:43:31 -0500 Subject: [PATCH 4/5] OpenGL2: Don't project sun shadows onto nothing Don't project sun shadows (r_forceSun 1) on to view depth equal to 1.0 (nothing drawn or skybox). This caused a full second shadow of the entire level in tr.screenShadowImage. It would move as the camera far plane changed and rotate/stretch strangely as the camera view changed. It was visible in-game on lightmapped transparent surfaces facing the skybox and happen to overlap the extra shadow of the level. This affected the glass in wop_padship's underwater room. --- code/renderergl2/glsl/shadowmask_fp.glsl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/renderergl2/glsl/shadowmask_fp.glsl b/code/renderergl2/glsl/shadowmask_fp.glsl index 2b57e3ba..56d480fb 100644 --- a/code/renderergl2/glsl/shadowmask_fp.glsl +++ b/code/renderergl2/glsl/shadowmask_fp.glsl @@ -103,14 +103,19 @@ void main() vec4 shadowpos = u_ShadowMvp * biasPos; + if ( depth >= 1.0 - DEPTH_MAX_ERROR ) + { + result = 1.0; + } + else #if defined(USE_SHADOW_CASCADE) if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) - { #endif + { shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5); result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z); -#if defined(USE_SHADOW_CASCADE) } +#if defined(USE_SHADOW_CASCADE) else { shadowpos = u_ShadowMvp2 * biasPos; From 712ec3b493802697ce12cb9fee415e17fea7991c Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Tue, 27 Aug 2024 21:29:27 -0500 Subject: [PATCH 5/5] Update discussion link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4e55ae5..1cdcb3a5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The Visual Studio and Xcode project files are not supported. ## Discussion - * [Discord (Clover.moe Community)](https://discord.gg/7J2pjGD) + * [Discussion / Technical support](https://clover.moe/open-source) ## License