From 47bd8afa91a31194dd87cb4dcd389c1aa461e7c1 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 15 Jun 2024 05:38:25 +0200 Subject: [PATCH] Try to ensure currentDepthImage always uses NEAREST filtering cleaner than only setting it in CopyDepthbuffer() --- neo/renderer/Image_init.cpp | 15 ++++++++++++++- neo/renderer/draw_arb2.cpp | 4 +++- neo/renderer/draw_common.cpp | 7 +++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/neo/renderer/Image_init.cpp b/neo/renderer/Image_init.cpp index e1807caa..89d9c578 100644 --- a/neo/renderer/Image_init.cpp +++ b/neo/renderer/Image_init.cpp @@ -388,6 +388,19 @@ static void R_RGBA8Image( idImage *image ) { TF_DEFAULT, false, TR_REPEAT, TD_HIGH_QUALITY ); } +static void R_DepthImage( idImage *image ) { + byte data[DEFAULT_SIZE][DEFAULT_SIZE][4]; + + memset( data, 0, sizeof( data ) ); + data[0][0][0] = 16; + data[0][0][1] = 32; + data[0][0][2] = 48; + data[0][0][3] = 96; + + image->GenerateImage( (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, + TF_NEAREST, false, TR_CLAMP, TD_HIGH_QUALITY ); +} + #if 0 static void R_RGB8Image( idImage *image ) { byte data[DEFAULT_SIZE][DEFAULT_SIZE][4]; @@ -1993,7 +2006,7 @@ void idImageManager::Init() { accumImage = ImageFromFunction("_accum", R_RGBA8Image ); scratchCubeMapImage = ImageFromFunction("_scratchCubeMap", makeNormalizeVectorCubeMap ); currentRenderImage = ImageFromFunction("_currentRender", R_RGBA8Image ); - currentDepthImage = ImageFromFunction( "_currentDepth", R_RGBA8Image ); // #3877. Allow shaders to access scene depth + currentDepthImage = ImageFromFunction( "_currentDepth", R_DepthImage ); // #3877. Allow shaders to access scene depth cmdSystem->AddCommand( "reloadImages", R_ReloadImages_f, CMD_FL_RENDERER, "reloads images" ); cmdSystem->AddCommand( "listImages", R_ListImages_f, CMD_FL_RENDERER, "lists images" ); diff --git a/neo/renderer/draw_arb2.cpp b/neo/renderer/draw_arb2.cpp index a6d5667a..5bb0e86c 100644 --- a/neo/renderer/draw_arb2.cpp +++ b/neo/renderer/draw_arb2.cpp @@ -458,7 +458,9 @@ void R_LoadARBProgram( int progIndex ) { end[3] = 0; // DG: hack gamma correction into shader - if ( r_gammaInShader.GetBool() && progs[progIndex].target == GL_FRAGMENT_PROGRAM_ARB ) { + if ( r_gammaInShader.GetBool() && progs[progIndex].target == GL_FRAGMENT_PROGRAM_ARB + && strstr( start, "nodhewm3gammahack" ) == NULL ) + { // note that strlen("dhewm3tmpres") == strlen("result.color") const char* tmpres = "TEMP dhewm3tmpres; # injected by dhewm3 for gamma correction\n"; diff --git a/neo/renderer/draw_common.cpp b/neo/renderer/draw_common.cpp index b609097d..c2b494f9 100644 --- a/neo/renderer/draw_common.cpp +++ b/neo/renderer/draw_common.cpp @@ -560,8 +560,8 @@ void RB_STD_FillDepthBuffer( drawSurf_t **drawSurfs, int numDrawSurfs ) { RB_RenderDrawSurfListWithFunction( drawSurfs, numDrawSurfs, RB_T_FillDepthBuffer ); // Make the early depth pass available to shaders. #3877 - if ( /*backEnd.viewDef->renderView.viewID >= 0 // Suppress for lightgem rendering passes - &&*/ !r_skipDepthCapture.GetBool() ) + if ( backEnd.viewDef->renderView.viewID >= 0 // Suppress for lightgem rendering passes + && !r_skipDepthCapture.GetBool() ) { globalImages->currentDepthImage->CopyDepthbuffer( backEnd.viewDef->viewport.x1, backEnd.viewDef->viewport.y1, @@ -812,7 +812,7 @@ void RB_STD_T_RenderShaderPasses( const drawSurf_t *surf ) { RB_EnterWeaponDepthHack(); } - if ( surf->space->modelDepthHack != 0.0f && !soft_particle ) // #3878 soft particles don't want modelDepthHack, which is + if ( surf->space->modelDepthHack != 0.0f && !soft_particle ) // #3878 soft particles don't want modelDepthHack, which is { // an older way to slightly "soften" particles RB_EnterModelDepthHack( surf->space->modelDepthHack ); } @@ -954,7 +954,6 @@ void RB_STD_T_RenderShaderPasses( const drawSurf_t *surf ) { GL_State( pStage->drawStateBits | GLS_DEPTHFUNC_ALWAYS ); // Disable depth clipping. The fragment program will // handle it to allow overdraw. - //GL_State( pStage->drawStateBits ); qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_SOFT_PARTICLE ); qglEnable( GL_VERTEX_PROGRAM_ARB );