From e25306f88f64283785d25720517bcdd345827fe9 Mon Sep 17 00:00:00 2001 From: BlueSkyDefender Date: Mon, 20 May 2024 22:12:55 -0600 Subject: [PATCH] Performance Update This update tries to improve performance overall managing texture formats better. --- Shaders/SuperDepth3D.fx | 3 +- Shaders/SuperDepth3D_VR+.fx | 57 +++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/Shaders/SuperDepth3D.fx b/Shaders/SuperDepth3D.fx index 1519468..e9372c1 100644 --- a/Shaders/SuperDepth3D.fx +++ b/Shaders/SuperDepth3D.fx @@ -3128,8 +3128,9 @@ uniform int Extra_Information < float3 DB_Comb(float2 texcoord) { float Auto_Adjust_Weapon_Depth = 1, Anti_Weapon_Z = abs(AWZ); + float2 MD_W = tex2Dlod(SamplerDMN,float4(texcoord,0,0)).xy; // X = Mix Depth | Y = Weapon Mask | Z = Weapon Hand | W = Normal Depth - float4 DM = float4(tex2Dlod(SamplerDMN,float4(texcoord,0,0)).x,WeaponMask(texcoord,0),tex2Dlod(SamplerDMN,float4(texcoord,0,0)).y,PrepDepth( texcoord )[1][1]); + float4 DM = float4(MD_W.x,WeaponMask(texcoord,0),MD_W.y,PrepDepth( texcoord )[1][1]); //Hide Temporal passthrough if(texcoord.x < pix.x * 2 && texcoord.y < pix.y * 2) DM = PrepDepth(texcoord)[0][0]; diff --git a/Shaders/SuperDepth3D_VR+.fx b/Shaders/SuperDepth3D_VR+.fx index 5e519b8..b637c7c 100644 --- a/Shaders/SuperDepth3D_VR+.fx +++ b/Shaders/SuperDepth3D_VR+.fx @@ -1,7 +1,7 @@ ////--------------------// ///**SuperDepth3D_VR+**/// //--------------------//// - #define SD3DVR "SuperDepth3D_VR+ v4.1.9\n" + #define SD3DVR "SuperDepth3D_VR+ v4.2.0\n" ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //* Depth Map Based 3D post-process shader //* For Reshade 4.4+ I think... @@ -1392,12 +1392,19 @@ uniform int Extra_Information < #define Lower_Depth_Rez_B 1.0 #endif - texture texDMVR { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT * Lower_Depth_Rez_B; Format = RGBA16F; MipLevels = 8;}; + texture texDMVR { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT * Lower_Depth_Rez_B; Format = RG16F; MipLevels = 8;}; sampler SamplerDMVR { Texture = texDMVR; }; + + texture texCVR { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT * Lower_Depth_Rez_B; Format = R8; MipLevels = 8;}; + + sampler SamplerCVR + { + Texture = texCVR; + }; texture texzBufferVR_P { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT * Lower_Depth_Rez_A; Format = RG16F; }; @@ -1690,7 +1697,7 @@ uniform int Extra_Information < float SLLTresh(float2 TCLocations, float MipLevel) { - return tex2Dlod(SamplerDMVR,float4(TCLocations,0, MipLevel)).w; + return tex2Dlod(SamplerCVR,float4(TCLocations,0, MipLevel)).x; } bool LBDetection()//Active RGB Detection @@ -2478,15 +2485,16 @@ uniform int Extra_Information < } R = DM.x; //Mix Depth - G = DM.y > saturate(smoothstep(0,2.5,DM.w)); //Weapon Mask - B = DM.z; //Weapon Hand + G = DM.z; //Weapon Hand + B = DM.y > saturate(smoothstep(0,2.5,DM.w)); //Weapon Mask + #if IWS float Isolating_Weapon_Stencil = texcoord.x+(texcoord.y*0.5) < DCC_W; - A = ZPD_Boundary >= 4 ? Isolating_Weapon_Stencil ? R : max( G, R) : R; //Grid Depth Stenciled + A = ZPD_Boundary >= 4 ? Isolating_Weapon_Stencil ? R : max( B, R) : R; //Grid Depth Stenciled #else - A = ZPD_Boundary >= 4 ? max( G, R) : R; //Grid Depth + A = ZPD_Boundary >= 4 ? max( B, R) : R; //Grid Depth #endif - return float3x3( saturate(float3(R, G, B)) , //[0][0] = R | [0][1] = G | [0][2] = B + return float3x3( saturate(float3(R, G, 0)) , //[0][0] = R | [0][1] = G | [0][2] = B saturate(float3(A,Depth( TC_SP(texcoord).xy).x ,DM.w)) , //[1][0] = A | [1][1] = D | [1][2] = DM float3(0,0,0) ); //[2][0] = Null | [2][1] = Null | [2][2] = Null } @@ -2661,11 +2669,8 @@ uniform int Extra_Information < //#else float PDepth = PrepDepth(GridXY)[1][0]; //#endif - if(ZPD_Boundary >= 4) - { - if ( PDepth == 1 ) + if(ZPD_Boundary >= 4 && PDepth == 1) ZPD_I = 0; - } //Weapon Hand Consideration #if CWH @@ -2754,7 +2759,7 @@ uniform int Extra_Information < return float2(Auto_Balance_Ex > 0 ? saturate(lerp(AB_EX * 2 , Avr_Mix(float2(0.5,Switch_Height_Point)).x , 0.25) ) : 1, saturate(lerp( Depth( float2(0.5,Switch_Height_Point) ) * 2 , Avr_Mix(float2(0.5,Switch_Height_Point)).x , 0.25) ) ) ; } - float4 DepthMap(in float4 position : SV_Position,in float2 texcoord : TEXCOORD) : SV_Target + void DepthMap(in float4 position : SV_Position, in float2 texcoord : TEXCOORD, out float2 DM_Out : SV_Target0 , out float Color_Out : SV_Target1) { float4 DM = float4(PrepDepth(texcoord)[0][0],PrepDepth(texcoord)[0][1],PrepDepth(texcoord)[0][2],PrepDepth(texcoord)[1][1]); float R = DM.x, G = DM.y, B = DM.z, Auto_Scale = WZPD_and_WND.z > 0 ? lerp(lerp(1.0,0.1,saturate(WZPD_and_WND.z * 2)),1.0,lerp(saturate(Auto_Balance_Selection().y * 2.5) , smoothstep(0,0.5,tex2D(SamplerLumVR,float2(0,0.750)).z), 0.5)) : 1; @@ -2827,8 +2832,8 @@ uniform int Extra_Information < float3 Color, Color_A = tex2D(BackBufferCLAMP,texcoord ).rgb;//, Color_B = step(0.9,tex2D(BackBufferCLAMP,texcoord ).rgb); Color.x = max(Color_A.r, max(Color_A.g, Color_A.b)); //Color.y = max(Color_B.r, max(Color_B.g, Color_B.b)); - float3 Out = float3(R,G,B); - return saturate(float4(Out,Color.x)); + DM_Out = saturate(float2(R,G)); + Color_Out = saturate(Color.x); } float AutoDepthRange(float d, float2 texcoord ) @@ -2849,7 +2854,7 @@ uniform int Extra_Information < [unroll] //only really only need to check one point just above the center bottom and to the right. for( int i = 0 ; i < 6; i++ ) { - WZPDB = 1 - WConverge / tex2Dlod(SamplerDMVR, float4(float2(WArray[i],Distance_From_Bottom), 0, 0)).z; + WZPDB = 1 - WConverge / tex2Dlod(SamplerDMVR, float4(float2(WArray[i],Distance_From_Bottom), 0, 0)).y; if(Weapon_ZPD_Boundary.x >= 0) { if ( WZPDB < -DJ_W ) // Default -0.1 @@ -2936,11 +2941,20 @@ uniform int Extra_Information < return float4( lerp(Convergence,lerp(D,Convergence,saturate(Convergence)), ZP), lerp(W_Convergence,WD,WZP), Store_WC, WZPD_Switch); } + float WeaponMask(float2 TC,float Mips) + { + if(WP == 0) + return 1; + else + return tex2Dlod(SamplerDMVR,float4(TC,0,Mips)).y == 0.5 ? 0 : 1; + } + float3 DB_Comb( float2 texcoord) { float Auto_Adjust_Weapon_Depth = 1, Anti_Weapon_Z = abs(AWZ); + float2 MD_W = tex2Dlod(SamplerDMVR,float4(texcoord,0,0)).xy; // X = Mix Depth | Y = Weapon Mask | Z = Weapon Hand | W = Normal Depth - float4 DM = float4(tex2Dlod(SamplerDMVR,float4(texcoord,0,0)).xyz,PrepDepth( texcoord )[1][1]); + float4 DM = float4(MD_W.x,WeaponMask(texcoord,0),MD_W.y,PrepDepth( texcoord )[1][1]); //Hide Temporal passthrough if(texcoord.x < pix.x * 2 && texcoord.y < pix.y * 2) DM = PrepDepth(texcoord)[0][0]; @@ -3107,7 +3121,7 @@ uniform int Extra_Information < #if WHM float DT_Switch = DT_Z < 0; - float Mask = tex2Dlod(SamplerDMVR,float4(texcoord,0,DT_Switch ? 2.0 : 7.5)).y; + float Mask = WeaponMask(texcoord,DT_Switch ? 2.0 : 7.5);; float Blur_Mask = tex2Dlod(SamplerDMVR,float4(texcoord,0,9)).x; if(WP > 0) DM.y = lerp(DM.y,DT_Switch ? lerp(0.0,0.2,Blur_Mask) * lerp(2,1,FadeIO) : 0.025 ,smoothstep(0,abs(DT_Z),Mask) * lerp(1- FD_Adjust,1,FadeIO)); @@ -3119,7 +3133,7 @@ uniform int Extra_Information < ////////////////////////////////////////////////////Depth & Special Depth Triggers////////////////////////////////////////////////////////////////// void zBuffer(in float4 position : SV_Position, in float2 texcoord : TEXCOORD, out float2 Point_Out : SV_Target0 , out float Linear_Out : SV_Target1) { //Temporal adaptation https://knarkowicz.wordpress.com/2016/01/09/automatic-exposure/ - float ExAd = (1-Adapt_Adjust)*1250, Lum = tex2Dlod(SamplerDMVR,float4(texcoord,0,12)).w, PastLum = tex2D(SamplerLumVR,float2(0,0.583)).z; + float ExAd = (1-Adapt_Adjust)*1250, Lum = tex2Dlod(SamplerCVR,float4(texcoord,0,12)).x, PastLum = tex2D(SamplerLumVR,float2(0,0.583)).z; float3 Set_Depth = DB_Comb( texcoord.xy ).xyz; @@ -3421,7 +3435,7 @@ uniform int Extra_Information < if( View_Mode == 5) Perf = lerp(0.4,1.0f,GetDepth); //Luma Based VRS - float Luma_Map = smoothstep(0.0,0.375, tex2Dlod(SamplerDMVR,float4(Coordinates,0,7)).w); + float Luma_Map = smoothstep(0.0,0.375, tex2Dlod(SamplerCVR,float4(Coordinates,0,7)).x); if( Performance_Level > 1 ) Perf *= lerp(0.25,1.0,smoothstep(0.0,0.25,saturate( Luma_Map ))); //Foveated Calculations @@ -3469,7 +3483,7 @@ uniform int Extra_Information < float2 PrevParallaxCoord = float2( ParallaxCoord.x + deltaCoordinates, ParallaxCoord.y), Depth_Adjusted = 1-saturate(float2(GetDepth * 5.0, GetDepth)); //Anti-Weapon Hand Fighting - float Weapon_Mask = tex2Dlod(SamplerDMVR,float4(Coordinates,0,0)).y, ZFighting_Mask = 1.0-(1.0-tex2Dlod(SamplerDMVR,float4(Coordinates ,0,5.5)).y - Weapon_Mask); + float Weapon_Mask = WeaponMask(Coordinates,0), ZFighting_Mask = 1.0-(1.0-WeaponMask(Coordinates,5.5) - Weapon_Mask);//tex2Dlod(SamplerDMVR,float4(Coordinates,0,0)).y, ZFighting_Mask = 1.0-(1.0-tex2Dlod(SamplerDMVR,float4(Coordinates ,0,5.5)).y - Weapon_Mask); ZFighting_Mask = ZFighting_Mask * (1.0-Weapon_Mask); float2 PCoord = float2(View_Mode <= 1 || View_Mode >= 5 ? PrevParallaxCoord.x : ParallaxCoord.x, PrevParallaxCoord.y ) ; @@ -4561,6 +4575,7 @@ uniform int Extra_Information < VertexShader = PostProcessVS; PixelShader = DepthMap; RenderTarget0 = texDMVR; + RenderTarget1 = texCVR; } pass zbufferVR {