Made PSX vertex jitter resolution independent

This commit is contained in:
Robert Beckebans 2024-07-26 17:50:06 +02:00
parent a41c475ad9
commit cebba26908
3 changed files with 21 additions and 6 deletions

View file

@ -5582,8 +5582,14 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
// PSX jitter parms
if( ( r_renderMode.GetInteger() == RENDERMODE_PSX ) && ( _viewDef->viewEntitys && !_viewDef->is2Dgui ) )
{
parm[0] = r_psxVertexJitter.GetFloat();
parm[1] = 0;
int w = viewDef->viewport.x2 - viewDef->viewport.x1 + 1;
int h = viewDef->viewport.y2 - viewDef->viewport.y1 + 1;
w /= 4;
h /= 4;
parm[0] = r_psxVertexJitter.GetFloat() * w;
parm[1] = r_psxVertexJitter.GetFloat() * h;
parm[2] = 0;
parm[3] = 0;
}

View file

@ -304,7 +304,7 @@ idCVar r_retroDitherScale( "r_retroDitherScale", "0.3", CVAR_RENDERER | CVAR_FLO
idCVar r_renderMode( "r_renderMode", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW, "0 = Doom, 1 = Commodore 64, 2 = Commodore 64 Highres, 3 = Amstrad CPC 6128, 4 = Amstrad CPC 6128 Highres, 5 = Sega Genesis, 6 = Sega Genesis Highres, 7 = Sony PSX", 0, 7 );
idCVar r_psxVertexJitter( "r_psxVertexJitter", "0.5", CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW, "" );
idCVar r_psxVertexJitter( "r_psxVertexJitter", "0.5", CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW, "", 0.0f, 0.75f );
// RB end
const char* fileExten[4] = { "tga", "png", "jpg", "exr" };

View file

@ -499,9 +499,18 @@ static float3 psxVertexJitter( float4 spos )
{
// snap to vertex to a pixel position on a lower grid
float3 vertex = spos.xyz / spos.w;
//float2 resolution = float2( 320, 240 ); // TODO 320x240 * jitterScale
float2 resolution = float2( 160, 120 );
vertex.xy = floor( resolution * vertex.xy ) / resolution;
//float2 resolution = float2( 320, 240 ) * ( 1.0 - jitterScale );
//float2 resolution = float2( 160, 120 );
float2 resolution = float2( rpPSXDistortions.x, rpPSXDistortions.y );
float w = dot4( rpProjectionMatrixW, float4( vertex.xyz, 1.0 ) );
vertex.xy = round( vertex.xy / w * resolution ) / resolution * w;
//vertex.xy = floor( vertex.xy / 4.0 ) * 4.0;
//vertex.xy = round( vertex.xy * resolution ) / resolution;
//vertex.xyz = round( vertex.xyz * resolution.x ) / resolution.x;
vertex *= spos.w;
return vertex;