Skip to content

Commit

Permalink
Performance Update
Browse files Browse the repository at this point in the history
This update tries to improve performance overall managing texture formats better.
  • Loading branch information
BlueSkyDefender committed May 21, 2024
1 parent 85cb3c0 commit e25306f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Shaders/SuperDepth3D.fx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
57 changes: 36 additions & 21 deletions Shaders/SuperDepth3D_VR+.fx
Original file line number Diff line number Diff line change
@@ -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...
Expand Down Expand Up @@ -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; };

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand All @@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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));
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ) ;

Expand Down Expand Up @@ -4561,6 +4575,7 @@ uniform int Extra_Information <
VertexShader = PostProcessVS;
PixelShader = DepthMap;
RenderTarget0 = texDMVR;
RenderTarget1 = texCVR;
}
pass zbufferVR
{
Expand Down

0 comments on commit e25306f

Please sign in to comment.