mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Implemented typical PSX style vertex jittering
This commit is contained in:
parent
a23ed41687
commit
333bc486d6
23 changed files with 83 additions and 0 deletions
|
@ -5578,6 +5578,24 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
float projMatrixTranspose[16];
|
||||
R_MatrixTranspose( viewDef->projectionMatrix, projMatrixTranspose );
|
||||
SetVertexParms( RENDERPARM_PROJMATRIX_X, projMatrixTranspose, 4 );
|
||||
|
||||
// PSX jitter parms
|
||||
if( !_viewDef->is2Dgui )
|
||||
{
|
||||
parm[0] = r_psxVertexJitter.GetFloat();
|
||||
parm[1] = 0;
|
||||
parm[2] = 0;
|
||||
parm[3] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
parm[0] = 0;
|
||||
parm[1] = 0;
|
||||
parm[2] = 0;
|
||||
parm[3] = 0;
|
||||
}
|
||||
|
||||
SetVertexParm( RENDERPARM_PSX_DISTORTIONS, parm );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -1276,6 +1276,8 @@ extern idCVar r_retroDitherScale;
|
|||
|
||||
extern idCVar r_renderMode;
|
||||
extern idCVar image_pixelLook;
|
||||
|
||||
extern idCVar r_psxVertexJitter;
|
||||
// RB end
|
||||
|
||||
/*
|
||||
|
|
|
@ -151,6 +151,9 @@ enum renderParm_t
|
|||
RENDERPARM_GLOBALLIGHTORIGIN,
|
||||
RENDERPARM_JITTERTEXSCALE,
|
||||
RENDERPARM_JITTERTEXOFFSET,
|
||||
|
||||
RENDERPARM_PSX_DISTORTIONS,
|
||||
|
||||
RENDERPARM_CASCADEDISTANCES,
|
||||
|
||||
RENDERPARM_SHADOW_MATRIX_0_X, // rpShadowMatrices[6 * 4]
|
||||
|
|
|
@ -303,6 +303,8 @@ idCVar r_crtVignette( "r_crtVignette", "0.8", CVAR_RENDERER | CVAR_FLOAT | CVAR_
|
|||
idCVar r_retroDitherScale( "r_retroDitherScale", "0.3", CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW, "" );
|
||||
|
||||
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, "" );
|
||||
// RB end
|
||||
|
||||
const char* fileExten[4] = { "tga", "png", "jpg", "exr" };
|
||||
|
|
|
@ -101,4 +101,6 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
#endif
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
}
|
|
@ -94,9 +94,12 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
#else
|
||||
|
||||
result.position.x = dot4( vertex.position, rpMVPmatrixX );
|
||||
result.position.y = dot4( vertex.position, rpMVPmatrixY );
|
||||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
#endif
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
}
|
|
@ -120,4 +120,6 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.texcoord1.x = dot4( vertex.position, rpTexGen1S );
|
||||
result.texcoord1.y = 0.5;
|
||||
#endif
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
}
|
||||
|
|
|
@ -116,4 +116,6 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.texcoord1.x = dot4( vertex.position, rpTexGen1S );
|
||||
result.texcoord1.y = dot4( vertex.position, rpTexGen1T );
|
||||
#endif
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
}
|
||||
|
|
|
@ -130,6 +130,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
// textures 0 takes the base coordinates by the texture matrix
|
||||
result.texcoord0.x = dot4( vertex.texcoord.xy, rpBumpMatrixS );
|
||||
result.texcoord0.y = dot4( vertex.texcoord.xy, rpBumpMatrixT );
|
||||
|
|
|
@ -173,5 +173,7 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
|
||||
#endif
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
result.color = rpColor;
|
||||
}
|
||||
|
|
|
@ -121,5 +121,7 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.texcoord1 = vNormal.xyz;
|
||||
#endif
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
result.color = sRGBAToLinearRGBA( rpColor );
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
result.texcoord0 = vertex.position.xyz - rpLocalViewOrigin.xyz;
|
||||
|
||||
result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd;
|
||||
|
|
|
@ -135,6 +135,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
|
|
@ -135,6 +135,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
|
||||
|
||||
//calculate vector to light
|
||||
|
|
|
@ -133,6 +133,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
|
||||
|
||||
//calculate vector to light
|
||||
|
|
|
@ -132,6 +132,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
|
||||
|
||||
//calculate vector to light
|
||||
|
|
|
@ -136,6 +136,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
|
||||
|
||||
//calculate vector to light
|
||||
|
|
|
@ -53,6 +53,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
// compute oldschool texgen or multiply by texture matrix
|
||||
BRANCH if( rpTexGen0Enabled.x > 0.0 )
|
||||
{
|
||||
|
|
|
@ -91,6 +91,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
modelPosition.z = dot4( matZ, vertex.position );
|
||||
modelPosition.w = 1.0;
|
||||
|
||||
modelPosition.xyz = psxVertexJitter( modelPosition );
|
||||
|
||||
result.position.x = dot4( modelPosition, rpMVPmatrixX );
|
||||
result.position.y = dot4( modelPosition, rpMVPmatrixY );
|
||||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
|
@ -114,6 +116,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
// Compute oldschool texgen or multiply by texture matrix
|
||||
BRANCH if( rpTexGen0Enabled.x > 0.0 )
|
||||
{
|
||||
|
|
|
@ -55,6 +55,8 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
float4 tc0;
|
||||
tc0.x = dot4( vertex.position, rpTexGen0S );
|
||||
tc0.y = dot4( vertex.position, rpTexGen0T );
|
||||
|
|
|
@ -55,5 +55,7 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
result.color = swizzleColor( vertex.color );
|
||||
}
|
|
@ -53,5 +53,7 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
|
||||
result.position.xyz = psxVertexJitter( result.position );
|
||||
|
||||
result.texcoord0 = vertex.texcoord;
|
||||
}
|
|
@ -107,6 +107,7 @@ cbuffer globals : register( b0 VK_DESCRIPTOR_SET( 0 ) )
|
|||
float4 rpGlobalLightOrigin;
|
||||
float4 rpJitterTexScale;
|
||||
float4 rpJitterTexOffset;
|
||||
float4 rpPSXDistortions;
|
||||
float4 rpCascadeDistances;
|
||||
|
||||
float4 rpShadowMatrices[6 * 4];
|
||||
|
@ -491,6 +492,24 @@ static float2 vposToScreenPosTexCoord( float2 vpos )
|
|||
return vpos.xy * rpWindowCoord.xy;
|
||||
}
|
||||
|
||||
static float3 psxVertexJitter( float4 spos )
|
||||
{
|
||||
float jitterScale = rpPSXDistortions.x;
|
||||
if( jitterScale > 0.0 )
|
||||
{
|
||||
// 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;
|
||||
vertex *= spos.w;
|
||||
|
||||
return vertex;
|
||||
}
|
||||
|
||||
return spos.xyz;
|
||||
}
|
||||
|
||||
#define BRANCH
|
||||
#define IFANY
|
||||
|
||||
|
|
Loading…
Reference in a new issue