From 319b65930294779823a93203cef3c4a76e154823 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 19 Mar 2015 00:31:08 +0100 Subject: [PATCH 1/4] Tweaked shadowmap bias to fight Peter Pan effect --- base/renderprogs/interactionSM.pixel | 4 ++-- neo/renderer/RenderProgs_embedded.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/base/renderprogs/interactionSM.pixel b/base/renderprogs/interactionSM.pixel index db40f3ac..17c9ec8b 100644 --- a/base/renderprogs/interactionSM.pixel +++ b/base/renderprogs/interactionSM.pixel @@ -196,8 +196,8 @@ void main( PS_IN fragment, out PS_OUT result ) float bias = 0.001; shadowTexcoord.xyz /= shadowTexcoord.w; - //shadowTexcoord.z = shadowTexcoord.z * 0.9991; - shadowTexcoord.z = shadowTexcoord.z - bias; + shadowTexcoord.z = shadowTexcoord.z * 0.9995; + //shadowTexcoord.z = shadowTexcoord.z - bias; shadowTexcoord.w = float(shadowIndex); #if 0 diff --git a/neo/renderer/RenderProgs_embedded.h b/neo/renderer/RenderProgs_embedded.h index e690693d..579d41ea 100644 --- a/neo/renderer/RenderProgs_embedded.h +++ b/neo/renderer/RenderProgs_embedded.h @@ -4389,8 +4389,8 @@ static const cgShaderDef_t cg_renderprogs[] = " float bias = 0.001;\n" " \n" " shadowTexcoord.xyz /= shadowTexcoord.w;\n" - " //shadowTexcoord.z = shadowTexcoord.z * 0.9991;\n" - " shadowTexcoord.z = shadowTexcoord.z - bias;\n" + " shadowTexcoord.z = shadowTexcoord.z * 0.9995;\n" + " //shadowTexcoord.z = shadowTexcoord.z - bias;\n" " shadowTexcoord.w = float(shadowIndex);\n" "\n" "#if 0\n" From 395ef525b12a044d7e70a1fba57ca1de2f11c1e3 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 19 Mar 2015 01:27:44 +0100 Subject: [PATCH 2/4] Tweaked shadowmap bias to fight shadow acne --- base/renderprogs/interactionSM.pixel | 6 ++++-- neo/renderer/RenderProgs_embedded.h | 6 ++++-- neo/renderer/RenderSystem_init.cpp | 2 ++ neo/renderer/tr_backend_draw.cpp | 2 +- neo/renderer/tr_local.h | 2 ++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/base/renderprogs/interactionSM.pixel b/base/renderprogs/interactionSM.pixel index 17c9ec8b..e261dc06 100644 --- a/base/renderprogs/interactionSM.pixel +++ b/base/renderprogs/interactionSM.pixel @@ -196,7 +196,9 @@ void main( PS_IN fragment, out PS_OUT result ) float bias = 0.001; shadowTexcoord.xyz /= shadowTexcoord.w; - shadowTexcoord.z = shadowTexcoord.z * 0.9995; + + shadowTexcoord.z = shadowTexcoord.z * rpScreenCorrectionFactor.w; + //shadowTexcoord.z = shadowTexcoord.z * 0.999991; //shadowTexcoord.z = shadowTexcoord.z - bias; shadowTexcoord.w = float(shadowIndex); @@ -216,7 +218,7 @@ void main( PS_IN fragment, out PS_OUT result ) float shadow = 0.0; //float stepSize = 1.0 / 16.0; - float numSamples = rpScreenCorrectionFactor.w; + float numSamples = 16; float stepSize = 1.0 / numSamples; float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset; diff --git a/neo/renderer/RenderProgs_embedded.h b/neo/renderer/RenderProgs_embedded.h index 579d41ea..cecce404 100644 --- a/neo/renderer/RenderProgs_embedded.h +++ b/neo/renderer/RenderProgs_embedded.h @@ -4389,7 +4389,9 @@ static const cgShaderDef_t cg_renderprogs[] = " float bias = 0.001;\n" " \n" " shadowTexcoord.xyz /= shadowTexcoord.w;\n" - " shadowTexcoord.z = shadowTexcoord.z * 0.9995;\n" + " \n" + " shadowTexcoord.z = shadowTexcoord.z * rpScreenCorrectionFactor.w;\n" + " //shadowTexcoord.z = shadowTexcoord.z * 0.999991;\n" " //shadowTexcoord.z = shadowTexcoord.z - bias;\n" " shadowTexcoord.w = float(shadowIndex);\n" "\n" @@ -4409,7 +4411,7 @@ static const cgShaderDef_t cg_renderprogs[] = " float shadow = 0.0;\n" " \n" " //float stepSize = 1.0 / 16.0;\n" - " float numSamples = rpScreenCorrectionFactor.w;\n" + " float numSamples = 16;\n" " float stepSize = 1.0 / numSamples;\n" " \n" " float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;\n" diff --git a/neo/renderer/RenderSystem_init.cpp b/neo/renderer/RenderSystem_init.cpp index b4f12cba..150ca363 100644 --- a/neo/renderer/RenderSystem_init.cpp +++ b/neo/renderer/RenderSystem_init.cpp @@ -235,6 +235,8 @@ idCVar r_shadowMapLodBias( "r_shadowMapLodBias", "0", CVAR_RENDERER | CVAR_INTEG idCVar r_shadowMapPolygonFactor( "r_shadowMapPolygonFactor", "2", CVAR_RENDERER | CVAR_FLOAT, "polygonOffset factor for drawing shadow buffer" ); idCVar r_shadowMapPolygonOffset( "r_shadowMapPolygonOffset", "3000", CVAR_RENDERER | CVAR_FLOAT, "polygonOffset units for drawing shadow buffer" ); idCVar r_shadowMapOccluderFacing( "r_shadowMapOccluderFacing", "2", CVAR_RENDERER | CVAR_INTEGER, "0 = front faces, 1 = back faces, 2 = twosided" ); +idCVar r_shadowMapRegularDepthBiasScale( "r_shadowMapRegularDepthBiasScale", "0.999", CVAR_RENDERER | CVAR_FLOAT, "shadowmap bias to fight shadow acne for point and spot lights" ); +idCVar r_shadowMapSunDepthBiasScale( "r_shadowMapSunDepthBiasScale", "0.999991", CVAR_RENDERER | CVAR_FLOAT, "shadowmap bias to fight shadow acne for cascaded shadow mapping with parallel lights" ); // RB end const char* fileExten[3] = { "tga", "png", "jpg" }; diff --git a/neo/renderer/tr_backend_draw.cpp b/neo/renderer/tr_backend_draw.cpp index 81a57ea8..83dccf30 100644 --- a/neo/renderer/tr_backend_draw.cpp +++ b/neo/renderer/tr_backend_draw.cpp @@ -1302,7 +1302,7 @@ static void RB_RenderInteractions( const drawSurf_t* surfList, const viewLight_t screenCorrectionParm[0] = 1.0f / ( JITTER_SIZE * shadowMapSamples ) ; screenCorrectionParm[1] = 1.0f / JITTER_SIZE; screenCorrectionParm[2] = 1.0f / shadowMapResolutions[vLight->shadowLOD]; - screenCorrectionParm[3] = shadowMapSamples; + screenCorrectionParm[3] = vLight->parallel ? r_shadowMapSunDepthBiasScale.GetFloat() : r_shadowMapRegularDepthBiasScale.GetFloat(); SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor float jitterTexScale[4]; diff --git a/neo/renderer/tr_local.h b/neo/renderer/tr_local.h index 26c0d89d..01b7b5c2 100644 --- a/neo/renderer/tr_local.h +++ b/neo/renderer/tr_local.h @@ -1070,6 +1070,8 @@ extern idCVar r_shadowMapLodBias; extern idCVar r_shadowMapPolygonFactor; extern idCVar r_shadowMapPolygonOffset; extern idCVar r_shadowMapOccluderFacing; +extern idCVar r_shadowMapRegularDepthBiasScale; +extern idCVar r_shadowMapSunDepthBiasScale; // RB end /* From f1655be62a8eef6fa652b30d64923a1be19d4626 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 26 Mar 2015 00:12:51 +0000 Subject: [PATCH 3/4] Linux users can get the game data with native Steam --- README.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.txt b/README.txt index e6059dea..f9ee9f13 100644 --- a/README.txt +++ b/README.txt @@ -218,6 +218,23 @@ Fortunately, you can run Steam in Wine to install Doom3 BFG and afterwards copy game data somewhere else to use it with native executables. Winetricks ( http://winetricks.org/ ) makes installing Windows Steam on Linux really easy. +If using the Linux version of Steam, you can open the console (launch steam with -console or +try steam://open/console in a web browser) and enter the following: + download_depot 208200 208202 +This will download the base game files to a path similar to (the path cannot be configured): + ~/.steam/root/ubuntu12_32/steamapps/common/app_208200/depot_208202/ +Steam will not provide feedback on the download progress so you will have to watch the folder. +You will also have to run download_depot for your language: + download_depot 208200 + Where is: + English: 208203 + German: 208204 + French: 208205 + Italian: 208206 + Spanish: 208207 + Japanese: 208208 +Combining the contents of both depots will provide the necessary game files for the engine. + Anyway: 1. Install Doom 3 BFG in Steam (Windows version), make sure it's getting From 43b2d36cbcbbf2236dc47d289e990b82b015dd90 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 26 Mar 2015 00:19:26 +0000 Subject: [PATCH 4/4] Update README.txt --- README.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index f9ee9f13..33979412 100644 --- a/README.txt +++ b/README.txt @@ -218,11 +218,10 @@ Fortunately, you can run Steam in Wine to install Doom3 BFG and afterwards copy game data somewhere else to use it with native executables. Winetricks ( http://winetricks.org/ ) makes installing Windows Steam on Linux really easy. -If using the Linux version of Steam, you can open the console (launch steam with -console or -try steam://open/console in a web browser) and enter the following: +If using the Linux version of Steam, you can open the console (launch steam with -console or try steam://open/console in a web browser) and enter the following: download_depot 208200 208202 This will download the base game files to a path similar to (the path cannot be configured): - ~/.steam/root/ubuntu12_32/steamapps/common/app_208200/depot_208202/ + ~/.steam/root/ubuntu12_32/steamapps/content/app_208200/depot_208202/ Steam will not provide feedback on the download progress so you will have to watch the folder. You will also have to run download_depot for your language: download_depot 208200