mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
Use shadow atlas for interaction rendering
This commit is contained in:
parent
63fe4a167a
commit
c0e4082651
10 changed files with 119 additions and 91 deletions
|
@ -39,7 +39,6 @@ static const int MAX_HIERARCHICAL_ZBUFFERS = 6; // native resolution + 5 MIP LEV
|
|||
static const int ENVPROBE_CAPTURE_SIZE = 256;
|
||||
static const int RADIANCE_OCTAHEDRON_SIZE = 512;
|
||||
static const int IRRADIANCE_OCTAHEDRON_SIZE = 30 + 2;
|
||||
static const int SHADOW_ATLAS_SIZE = 8192;
|
||||
|
||||
//static int shadowMapResolutions[MAX_SHADOWMAP_RESOLUTIONS] = { 2048, 1024, 512, 512, 256 };
|
||||
static int shadowMapResolutions[MAX_SHADOWMAP_RESOLUTIONS] = { 1024, 512, 512, 256, 128 };
|
||||
|
|
|
@ -625,7 +625,7 @@ void R_QuadraticImage( idImage* image, nvrhi::ICommandList* commandList )
|
|||
// RB begin
|
||||
static void R_CreateShadowMapImage_Atlas( idImage* image, nvrhi::ICommandList* commandList )
|
||||
{
|
||||
image->GenerateShadowArray( SHADOW_ATLAS_SIZE, SHADOW_ATLAS_SIZE, TF_LINEAR, TR_CLAMP_TO_ZERO_ALPHA, TD_DEPTH, commandList );
|
||||
image->GenerateShadowArray( r_shadowMapAtlasSize.GetInteger(), r_shadowMapAtlasSize.GetInteger(), TF_LINEAR, TR_CLAMP_TO_ZERO_ALPHA, TD_DEPTH, commandList );
|
||||
}
|
||||
|
||||
static void R_CreateShadowMapImage_Res0( idImage* image, nvrhi::ICommandList* commandList )
|
||||
|
|
|
@ -1128,7 +1128,7 @@ extern idCVar r_useStencilShadowPreload;
|
|||
|
||||
void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const bool renderZPass )
|
||||
{
|
||||
#if 1
|
||||
#if 0
|
||||
if( renderZPass )
|
||||
{
|
||||
// Z-pass
|
||||
|
|
|
@ -1510,13 +1510,13 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / ( JITTER_SIZE * shadowMapSamples ) ;
|
||||
screenCorrectionParm[1] = 1.0f / JITTER_SIZE;
|
||||
screenCorrectionParm[2] = 1.0f / shadowMapResolutions[vLight->shadowLOD];
|
||||
screenCorrectionParm[2] = 1.0f / vLight->imageSize.x; // atlas sample scale
|
||||
screenCorrectionParm[3] = vLight->parallel ? r_shadowMapSunDepthBiasScale.GetFloat() : r_shadowMapRegularDepthBiasScale.GetFloat();
|
||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||
|
||||
float jitterTexScale[4];
|
||||
jitterTexScale[0] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale; // TODO shadow buffer size fraction shadowMapSize / maxShadowMapSize
|
||||
jitterTexScale[1] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale;
|
||||
jitterTexScale[1] = vLight->imageSize.x / float( r_shadowMapAtlasSize.GetInteger() );
|
||||
jitterTexScale[2] = -r_shadowMapBiasScale.GetFloat();
|
||||
jitterTexScale[3] = shadowMapSamples;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
|
@ -1547,6 +1547,20 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
SetFragmentParm( RENDERPARM_CASCADEDISTANCES, cascadeDistances ); // rpCascadeDistances
|
||||
}
|
||||
|
||||
if( r_useShadowAtlas.GetBool() )
|
||||
{
|
||||
// float4
|
||||
idVec4 shadowOffsets[6];
|
||||
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
shadowOffsets[ i ].x = vLight->imageAtlasOffset[ i ].x;
|
||||
shadowOffsets[ i ].y = vLight->imageAtlasOffset[ i ].y;
|
||||
}
|
||||
|
||||
SetVertexParms( RENDERPARM_SHADOW_ATLAS_OFFSET_0, &shadowOffsets[0][0], 6 );
|
||||
}
|
||||
|
||||
}
|
||||
// RB end
|
||||
|
||||
|
@ -1597,7 +1611,14 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
{
|
||||
// texture 5 will be the shadow maps array
|
||||
GL_SelectTexture( INTERACTION_TEXUNIT_SHADOWMAPS );
|
||||
globalImages->shadowImage[vLight->shadowLOD]->Bind();
|
||||
if( r_useShadowAtlas.GetBool() )
|
||||
{
|
||||
globalImages->shadowAtlasImage->Bind();
|
||||
}
|
||||
else
|
||||
{
|
||||
globalImages->shadowImage[vLight->shadowLOD]->Bind();
|
||||
}
|
||||
|
||||
// texture 6 will be the jitter texture for soft shadowing
|
||||
GL_SelectTexture( INTERACTION_TEXUNIT_JITTER );
|
||||
|
@ -1722,10 +1743,10 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
for( int i = 0; i < ( r_shadowMapSplits.GetInteger() + 1 ); i++ )
|
||||
{
|
||||
idRenderMatrix modelToShadowMatrix;
|
||||
idRenderMatrix::Multiply( shadowV[i], modelMatrix, modelToShadowMatrix );
|
||||
idRenderMatrix::Multiply( vLight->shadowV[i], modelMatrix, modelToShadowMatrix );
|
||||
|
||||
idRenderMatrix shadowClipMVP;
|
||||
idRenderMatrix::Multiply( shadowP[i], modelToShadowMatrix, shadowClipMVP );
|
||||
idRenderMatrix::Multiply( vLight->shadowP[i], modelToShadowMatrix, shadowClipMVP );
|
||||
|
||||
idRenderMatrix shadowWindowMVP;
|
||||
idRenderMatrix::Multiply( renderMatrix_clipSpaceToWindowSpace, shadowClipMVP, shadowWindowMVP );
|
||||
|
@ -1738,10 +1759,10 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
idRenderMatrix modelToShadowMatrix;
|
||||
idRenderMatrix::Multiply( shadowV[i], modelMatrix, modelToShadowMatrix );
|
||||
idRenderMatrix::Multiply( vLight->shadowV[i], modelMatrix, modelToShadowMatrix );
|
||||
|
||||
idRenderMatrix shadowClipMVP;
|
||||
idRenderMatrix::Multiply( shadowP[i], modelToShadowMatrix, shadowClipMVP );
|
||||
idRenderMatrix::Multiply( vLight->shadowP[i], modelToShadowMatrix, shadowClipMVP );
|
||||
|
||||
idRenderMatrix shadowWindowMVP;
|
||||
idRenderMatrix::Multiply( renderMatrix_clipSpaceToWindowSpace, shadowClipMVP, shadowWindowMVP );
|
||||
|
@ -1754,10 +1775,10 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
// spot light
|
||||
|
||||
idRenderMatrix modelToShadowMatrix;
|
||||
idRenderMatrix::Multiply( shadowV[0], modelMatrix, modelToShadowMatrix );
|
||||
idRenderMatrix::Multiply( vLight->shadowV[0], modelMatrix, modelToShadowMatrix );
|
||||
|
||||
idRenderMatrix shadowClipMVP;
|
||||
idRenderMatrix::Multiply( shadowP[0], modelToShadowMatrix, shadowClipMVP );
|
||||
idRenderMatrix::Multiply( vLight->shadowP[0], modelToShadowMatrix, shadowClipMVP );
|
||||
|
||||
SetVertexParms( ( renderParm_t )( RENDERPARM_SHADOW_MATRIX_0_X ), shadowClipMVP[0], 4 );
|
||||
|
||||
|
@ -2748,7 +2769,7 @@ void MatrixLookAtRH( float m[16], const idVec3& eye, const idVec3& dir, const id
|
|||
idRenderBackend::SetupShadowMapMatrices
|
||||
=====================
|
||||
*/
|
||||
void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int side, idRenderMatrix& lightProjectionRenderMatrix, idRenderMatrix& lightViewRenderMatrix )
|
||||
void idRenderBackend::SetupShadowMapMatrices( viewLight_t* vLight, int side, idRenderMatrix& lightProjectionRenderMatrix, idRenderMatrix& lightViewRenderMatrix )
|
||||
{
|
||||
if( vLight->parallel && side >= 0 )
|
||||
{
|
||||
|
@ -2904,8 +2925,8 @@ void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int sid
|
|||
MatrixOrthogonalProjectionRH( lightProjectionMatrix, cropBounds[0][0], cropBounds[1][0], cropBounds[0][1], cropBounds[1][1], -cropBounds[1][2], -cropBounds[0][2] );
|
||||
idRenderMatrix::Transpose( *( idRenderMatrix* )lightProjectionMatrix, lightProjectionRenderMatrix );
|
||||
|
||||
shadowV[side] = lightViewRenderMatrix;
|
||||
shadowP[side] = lightProjectionRenderMatrix;
|
||||
vLight->shadowV[side] = lightViewRenderMatrix;
|
||||
vLight->shadowP[side] = lightProjectionRenderMatrix;
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
ALIGNTYPE16 const idRenderMatrix matClipToUvzw(
|
||||
|
@ -2915,7 +2936,7 @@ void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int sid
|
|||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
);
|
||||
|
||||
idRenderMatrix::Multiply( matClipToUvzw, lightProjectionRenderMatrix, shadowP[side] );
|
||||
idRenderMatrix::Multiply( matClipToUvzw, lightProjectionRenderMatrix, vLight->shadowP[side] );
|
||||
#endif
|
||||
}
|
||||
else if( vLight->pointLight && side >= 0 )
|
||||
|
@ -3039,8 +3060,8 @@ void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int sid
|
|||
|
||||
idRenderMatrix::Transpose( *( idRenderMatrix* )lightProjectionMatrix, lightProjectionRenderMatrix );
|
||||
|
||||
shadowV[side] = lightViewRenderMatrix;
|
||||
shadowP[side] = lightProjectionRenderMatrix;
|
||||
vLight->shadowV[side] = lightViewRenderMatrix;
|
||||
vLight->shadowP[side] = lightProjectionRenderMatrix;
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
ALIGNTYPE16 const idRenderMatrix matClipToUvzw(
|
||||
|
@ -3050,7 +3071,7 @@ void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int sid
|
|||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
);
|
||||
|
||||
idRenderMatrix::Multiply( matClipToUvzw, lightProjectionRenderMatrix, shadowP[side] );
|
||||
idRenderMatrix::Multiply( matClipToUvzw, lightProjectionRenderMatrix, vLight->shadowP[side] );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -3059,8 +3080,8 @@ void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int sid
|
|||
lightViewRenderMatrix.Identity();
|
||||
lightProjectionRenderMatrix = vLight->baseLightProject;
|
||||
|
||||
shadowV[0] = lightViewRenderMatrix;
|
||||
shadowP[0] = lightProjectionRenderMatrix;
|
||||
vLight->shadowV[0] = lightViewRenderMatrix;
|
||||
vLight->shadowP[0] = lightProjectionRenderMatrix;
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
// Calculate alternate matrix that maps to [0, 1] UV space instead of [-1, 1] clip space
|
||||
|
@ -3073,7 +3094,7 @@ void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int sid
|
|||
|
||||
idRenderMatrix shadowToClip;
|
||||
idRenderMatrix::Multiply( renderMatrix_windowSpaceToClipSpace, lightProjectionRenderMatrix, shadowToClip );
|
||||
idRenderMatrix::Multiply( matClipToUvzw, shadowToClip, shadowP[0] );
|
||||
idRenderMatrix::Multiply( matClipToUvzw, shadowToClip, vLight->shadowP[0] );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -3083,7 +3104,7 @@ void idRenderBackend::SetupShadowMapMatrices( const viewLight_t* vLight, int sid
|
|||
idRenderBackend::ShadowMapPassPerforated
|
||||
=====================
|
||||
*/
|
||||
void idRenderBackend::ShadowMapPassPerforated( const drawSurf_t** drawSurfs, int numDrawSurfs, const viewLight_t* vLight, int side, const idRenderMatrix& lightProjectionRenderMatrix, const idRenderMatrix& lightViewRenderMatrix )
|
||||
void idRenderBackend::ShadowMapPassPerforated( const drawSurf_t** drawSurfs, int numDrawSurfs, viewLight_t* vLight, int side, const idRenderMatrix& lightProjectionRenderMatrix, const idRenderMatrix& lightViewRenderMatrix )
|
||||
{
|
||||
if( r_skipShadows.GetBool() )
|
||||
{
|
||||
|
@ -3300,7 +3321,7 @@ void idRenderBackend::ShadowMapPassPerforated( const drawSurf_t** drawSurfs, int
|
|||
idRenderBackend::ShadowMapPassFast
|
||||
=====================
|
||||
*/
|
||||
void idRenderBackend::ShadowMapPassFast( const drawSurf_t* drawSurfs, const viewLight_t* vLight, int side, bool atlas )
|
||||
void idRenderBackend::ShadowMapPassFast( const drawSurf_t* drawSurfs, viewLight_t* vLight, int side, bool atlas )
|
||||
{
|
||||
if( r_skipShadows.GetBool() )
|
||||
{
|
||||
|
@ -3524,7 +3545,7 @@ void idRenderBackend::ShadowMapPassFast( const drawSurf_t* drawSurfs, const view
|
|||
idRenderBackend::ShadowMapPass
|
||||
=====================
|
||||
*/
|
||||
void idRenderBackend::ShadowMapPassOld( const drawSurf_t* drawSurfs, const viewLight_t* vLight, int side )
|
||||
void idRenderBackend::ShadowMapPassOld( const drawSurf_t* drawSurfs, viewLight_t* vLight, int side )
|
||||
{
|
||||
if( r_skipShadows.GetBool() )
|
||||
{
|
||||
|
@ -3827,7 +3848,7 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
|
|||
|
||||
globalFramebuffers.shadowAtlasFBO->Bind();
|
||||
|
||||
GL_ViewportAndScissor( 0, 0, SHADOW_ATLAS_SIZE, SHADOW_ATLAS_SIZE );
|
||||
GL_ViewportAndScissor( 0, 0, r_shadowMapAtlasSize.GetInteger(), r_shadowMapAtlasSize.GetInteger() );
|
||||
|
||||
const nvrhi::FramebufferAttachment& att = currentFrameBuffer->GetApiObject()->getDesc().depthAttachment;
|
||||
if( att.texture )
|
||||
|
@ -3890,8 +3911,6 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
|
|||
|
||||
for( ; side < sideStop ; side++ )
|
||||
{
|
||||
//ShadowMapPassFast( vLight->globalShadows, vLight, side, true );
|
||||
|
||||
inputSizes.Append( idVec2i( shadowMapResolutions[ vLight->shadowLOD ], shadowMapResolutions[ vLight->shadowLOD ] ) );
|
||||
inputNames.Append( lightShader->GetName() );
|
||||
|
||||
|
@ -3902,7 +3921,7 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
|
|||
idList<idVec2i> outputPositions;
|
||||
idVec2i totalSize;
|
||||
|
||||
RectAllocatorBinPack2D( inputSizes, inputNames, outputPositions, totalSize, SHADOW_ATLAS_SIZE );
|
||||
RectAllocatorBinPack2D( inputSizes, inputNames, outputPositions, totalSize, r_shadowMapAtlasSize.GetInteger() );
|
||||
|
||||
//
|
||||
// for each light, perform shadowing to a big atlas Framebuffer
|
||||
|
@ -3935,8 +3954,6 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
|
|||
GL_DepthBoundsTest( vLight->scissorRect.zmin, vLight->scissorRect.zmax );
|
||||
}
|
||||
|
||||
// RB: shadow mapping
|
||||
//if( r_useShadowMapping.GetBool() )
|
||||
int side, sideStop;
|
||||
|
||||
if( vLight->parallel )
|
||||
|
@ -4078,47 +4095,52 @@ void idRenderBackend::DrawInteractions( const viewDef_t* _viewDef )
|
|||
// RB: shadow mapping
|
||||
if( r_useShadowMapping.GetBool() )
|
||||
{
|
||||
int side, sideStop;
|
||||
if( !r_useShadowAtlas.GetBool() )
|
||||
{
|
||||
int side, sideStop;
|
||||
|
||||
if( vLight->parallel )
|
||||
{
|
||||
side = 0;
|
||||
sideStop = r_shadowMapSplits.GetInteger() + 1;
|
||||
}
|
||||
else if( vLight->pointLight )
|
||||
{
|
||||
if( r_shadowMapSingleSide.GetInteger() != -1 )
|
||||
if( vLight->parallel )
|
||||
{
|
||||
side = r_shadowMapSingleSide.GetInteger();
|
||||
sideStop = side + 1;
|
||||
side = 0;
|
||||
sideStop = r_shadowMapSplits.GetInteger() + 1;
|
||||
}
|
||||
else if( vLight->pointLight )
|
||||
{
|
||||
if( r_shadowMapSingleSide.GetInteger() != -1 )
|
||||
{
|
||||
side = r_shadowMapSingleSide.GetInteger();
|
||||
sideStop = side + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
side = 0;
|
||||
sideStop = 6;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
side = 0;
|
||||
sideStop = 6;
|
||||
side = -1;
|
||||
sideStop = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
side = -1;
|
||||
sideStop = 0;
|
||||
}
|
||||
|
||||
for( ; side < sideStop ; side++ )
|
||||
{
|
||||
ShadowMapPassFast( vLight->globalShadows, vLight, side, false );
|
||||
}
|
||||
for( ; side < sideStop ; side++ )
|
||||
{
|
||||
// vLight is const but we make an exception here to store the shadow matrices per vLight
|
||||
// OPTIMIZE: these calculations could be moved to the renderer frontend into the multithreaded job
|
||||
ShadowMapPassFast( vLight->globalShadows, ( viewLight_t* ) vLight, side, false );
|
||||
}
|
||||
|
||||
// go back to main render target
|
||||
if( previousFramebuffer != NULL )
|
||||
{
|
||||
previousFramebuffer->Bind();
|
||||
// go back to main render target
|
||||
if( previousFramebuffer != NULL )
|
||||
{
|
||||
previousFramebuffer->Bind();
|
||||
}
|
||||
else
|
||||
{
|
||||
Framebuffer::Unbind();
|
||||
}
|
||||
renderProgManager.Unbind();
|
||||
}
|
||||
else
|
||||
{
|
||||
Framebuffer::Unbind();
|
||||
}
|
||||
renderProgManager.Unbind();
|
||||
|
||||
GL_State( GLS_DEFAULT );
|
||||
|
||||
|
|
|
@ -330,10 +330,10 @@ private:
|
|||
// RB
|
||||
void AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs, bool fillGbuffer );
|
||||
|
||||
void SetupShadowMapMatrices( const viewLight_t* vLight, int side, idRenderMatrix& lightProjectionRenderMatrix, idRenderMatrix& lightViewRenderMatrix );
|
||||
void ShadowMapPassFast( const drawSurf_t* drawSurfs, const viewLight_t* vLight, int side, bool atlas );
|
||||
void ShadowMapPassPerforated( const drawSurf_t** drawSurfs, int numDrawSurfs, const viewLight_t* vLight, int side, const idRenderMatrix& lightProjectionRenderMatrix, const idRenderMatrix& lightViewRenderMatrix );
|
||||
void ShadowMapPassOld( const drawSurf_t* drawSurfs, const viewLight_t* vLight, int side );
|
||||
void SetupShadowMapMatrices( viewLight_t* vLight, int side, idRenderMatrix& lightProjectionRenderMatrix, idRenderMatrix& lightViewRenderMatrix );
|
||||
void ShadowMapPassFast( const drawSurf_t* drawSurfs, viewLight_t* vLight, int side, bool atlas );
|
||||
void ShadowMapPassPerforated( const drawSurf_t** drawSurfs, int numDrawSurfs, viewLight_t* vLight, int side, const idRenderMatrix& lightProjectionRenderMatrix, const idRenderMatrix& lightViewRenderMatrix );
|
||||
void ShadowMapPassOld( const drawSurf_t* drawSurfs, viewLight_t* vLight, int side );
|
||||
|
||||
void ShadowAtlasPass( const viewDef_t* _viewDef );
|
||||
|
||||
|
@ -496,9 +496,6 @@ private:
|
|||
idRenderMatrix prevMVP[2]; // world MVP from previous frame for motion blur
|
||||
|
||||
// RB begin
|
||||
idRenderMatrix shadowV[6]; // shadow depth view matrix
|
||||
idRenderMatrix shadowP[6]; // shadow depth projection matrix
|
||||
|
||||
// TODO remove
|
||||
float hdrAverageLuminance;
|
||||
float hdrMaxLuminance;
|
||||
|
|
|
@ -416,6 +416,8 @@ struct viewLight_t
|
|||
bool parallel; // lightCenter gives the direction to the light at infinity
|
||||
idVec3 lightCenter; // offset the lighting direction for shading and
|
||||
int shadowLOD; // level of detail for shadowmap selection
|
||||
idRenderMatrix shadowV[6]; // shadow depth view matrix for lighting pass
|
||||
idRenderMatrix shadowP[6]; // shadow depth projection matrix for lighting pass
|
||||
idVec2i imageSize;
|
||||
idVec2i imageAtlasOffset[6];
|
||||
// RB end
|
||||
|
@ -1118,6 +1120,7 @@ extern idCVar r_useLightDepthBounds; // use depth bounds test on lights to redu
|
|||
extern idCVar r_useShadowDepthBounds; // use depth bounds test on individual shadows to reduce shadow fill
|
||||
// RB begin
|
||||
extern idCVar r_useShadowMapping; // use shadow mapping instead of stencil shadows
|
||||
extern idCVar r_useShadowAtlas; // temporary for perf testing: pack shadow maps into big atlas
|
||||
extern idCVar r_useHalfLambertLighting; // use Half-Lambert lighting instead of classic Lambert
|
||||
extern idCVar r_useHDR;
|
||||
extern idCVar r_useSeamlessCubeMap;
|
||||
|
@ -1221,6 +1224,7 @@ extern idCVar stereoRender_deGhost; // subtract from opposite eye to reduce gh
|
|||
extern idCVar r_useGPUSkinning;
|
||||
|
||||
// RB begin
|
||||
extern idCVar r_shadowMapAtlasSize;
|
||||
extern idCVar r_shadowMapFrustumFOV;
|
||||
extern idCVar r_shadowMapSingleSide;
|
||||
extern idCVar r_shadowMapImageSize;
|
||||
|
|
|
@ -183,6 +183,13 @@ enum renderParm_t
|
|||
RENDERPARM_SHADOW_MATRIX_5_Z,
|
||||
RENDERPARM_SHADOW_MATRIX_5_W,
|
||||
|
||||
RENDERPARM_SHADOW_ATLAS_OFFSET_0, // rpShadowAtlasOffsets[6]
|
||||
RENDERPARM_SHADOW_ATLAS_OFFSET_1,
|
||||
RENDERPARM_SHADOW_ATLAS_OFFSET_2,
|
||||
RENDERPARM_SHADOW_ATLAS_OFFSET_3,
|
||||
RENDERPARM_SHADOW_ATLAS_OFFSET_4,
|
||||
RENDERPARM_SHADOW_ATLAS_OFFSET_5,
|
||||
|
||||
RENDERPARM_USER0,
|
||||
RENDERPARM_USER1,
|
||||
RENDERPARM_USER2,
|
||||
|
|
|
@ -68,7 +68,7 @@ idCVar r_debugContext( "r_debugContext", "0", CVAR_RENDERER, "Enable various lev
|
|||
idCVar r_glDriver( "r_glDriver", "", CVAR_RENDERER, "\"opengl32\", etc." );
|
||||
#if defined(USE_NVRHI)
|
||||
idCVar r_gapi( "r_gapi", "dx12", CVAR_RENDERER, "Specifies the graphics api to use (dx12, vulkan)" );
|
||||
idCVar r_useValidationLayers( "r_useValidationLayers", "0", CVAR_INTEGER | CVAR_INIT, "1 is just the NVRHI and 2 will turn on additional DX12, VK validation layers" );
|
||||
idCVar r_useValidationLayers( "r_useValidationLayers", "1", CVAR_INTEGER | CVAR_INIT, "1 is just the NVRHI and 2 will turn on additional DX12, VK validation layers" );
|
||||
#endif
|
||||
// SRS - Added workaround for AMD OSX driver bugs caused by GL_EXT_timer_query when shadow mapping enabled; Intel bugs not present on OSX
|
||||
#if defined(__APPLE__)
|
||||
|
@ -265,6 +265,8 @@ idCVar r_useVirtualScreenResolution( "r_useVirtualScreenResolution", "0", CVAR_R
|
|||
#else
|
||||
idCVar r_useShadowMapping( "r_useShadowMapping", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER, "use shadow mapping instead of stencil shadows" );
|
||||
#endif
|
||||
idCVar r_useShadowAtlas( "r_useShadowAtlas", "1", CVAR_RENDERER | CVAR_INTEGER, "" );
|
||||
idCVar r_shadowMapAtlasSize( "r_shadowMapAtlasSize", "8192", CVAR_RENDERER | CVAR_INTEGER | CVAR_ROM, "size of the shadowmap atlas" );
|
||||
idCVar r_shadowMapFrustumFOV( "r_shadowMapFrustumFOV", "92", CVAR_RENDERER | CVAR_FLOAT, "oversize FOV for point light side matching" );
|
||||
idCVar r_shadowMapSingleSide( "r_shadowMapSingleSide", "-1", CVAR_RENDERER | CVAR_INTEGER, "only draw a single side (0-5) of point lights" );
|
||||
idCVar r_shadowMapImageSize( "r_shadowMapImageSize", "1024", CVAR_RENDERER | CVAR_INTEGER, "", 128, 2048 );
|
||||
|
|
|
@ -38,7 +38,8 @@ Texture2D t_Specular : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
|||
Texture2D t_BaseColor : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightFalloff : register( t3 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightProjection : register( t4 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2DArray<float> t_ShadowMapArray : register( t5 VK_DESCRIPTOR_SET( 0 ) );
|
||||
//Texture2DArray<float> t_ShadowMapArray : register( t5 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_ShadowAtlas : register( t5 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Jitter : register( t6 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState s_Material : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // for the normal/specular/basecolor
|
||||
|
@ -230,12 +231,6 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
//shadowTexcoord.z = shadowTexcoord.z - bias;
|
||||
shadowTexcoord.w = float( shadowIndex );
|
||||
|
||||
#if 0
|
||||
result.color.xyz = float3( shadowTexcoord.z, shadowTexcoord.z, shadowTexcoord.z );
|
||||
result.color.w = 1.0;
|
||||
return;
|
||||
#endif
|
||||
|
||||
// multiple taps
|
||||
|
||||
#if 0
|
||||
|
@ -311,7 +306,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
shadow *= stepSize;
|
||||
|
||||
#elif 1
|
||||
#elif 0
|
||||
|
||||
#if 0
|
||||
|
||||
|
@ -393,13 +388,18 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
#endif
|
||||
|
||||
#else
|
||||
float3 uvzShadow;
|
||||
uvzShadow.x = shadowTexcoord.x;
|
||||
uvzShadow.y = shadowTexcoord.y;
|
||||
uvzShadow.z = shadowTexcoord.w;
|
||||
float shadow = t_ShadowMapArray.SampleCmpLevelZero( samp2, uvzShadow, shadowTexcoord.z );
|
||||
float2 uvShadow;
|
||||
uvShadow.x = shadowTexcoord.x;
|
||||
uvShadow.y = shadowTexcoord.y;
|
||||
|
||||
#if 0
|
||||
// [0 .. 1] -> rectangle in atlas transform
|
||||
uvShadow = uvShadow * rpJitterTexScale.y; // + rpShadowAtlasOffsets[ shadowIndex ].xy
|
||||
uvShadow.x += rpShadowAtlasOffsets[ shadowIndex ].x;
|
||||
uvShadow.y -= rpShadowAtlasOffsets[ shadowIndex ].y;
|
||||
|
||||
float shadow = t_ShadowAtlas.SampleCmpLevelZero( s_Shadow, uvShadow.xy, shadowTexcoord.z );
|
||||
|
||||
#if 1
|
||||
if( shadowIndex == 0 )
|
||||
{
|
||||
result.color = float4( 1.0, 0.0, 0.0, 1.0 );
|
||||
|
|
|
@ -102,19 +102,16 @@ cbuffer globals : register( b0 VK_DESCRIPTOR_SET( 0 ) )
|
|||
float4 rpEnableSkinning;
|
||||
float4 rpAlphaTest;
|
||||
|
||||
// RB begin
|
||||
// RB begin
|
||||
float4 rpAmbientColor;
|
||||
float4 rpGlobalLightOrigin;
|
||||
float4 rpJitterTexScale;
|
||||
float4 rpJitterTexOffset;
|
||||
float4 rpCascadeDistances;
|
||||
|
||||
#if defined( USE_UNIFORM_ARRAYS )
|
||||
float4 rpShadowMatrices;
|
||||
#else
|
||||
float4 rpShadowMatrices[6 * 4];
|
||||
#endif
|
||||
// RB end
|
||||
float4 rpShadowAtlasOffsets[6];
|
||||
// RB end
|
||||
|
||||
float4 rpUser0;
|
||||
float4 rpUser1;
|
||||
|
|
Loading…
Reference in a new issue