Try to ensure currentDepthImage always uses NEAREST filtering

cleaner than only setting it in CopyDepthbuffer()
This commit is contained in:
Daniel Gibson 2024-06-15 05:38:25 +02:00
parent 6a3fa8c28a
commit 47bd8afa91
3 changed files with 20 additions and 6 deletions

View file

@ -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" );

View file

@ -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";

View file

@ -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 );