I don't know how to program.
#include "ReShade.fxh"
#define TEXFORMAT R8
uniform float fMask_Intensity <
ui_label = "Mask Intensity";
ui_type = "drag";
ui_min = 0.0;
ui_max = 1.0;
ui_step = 0.001;
> = 1.0;
uniform float DepthMaskCut <
ui_type = "drag";
ui_min = 0.0;
ui_max = 1.0;
ui_step = 0.001;
> = 1.0;
uniform bool bDisplayMask <
ui_label = "Display Mask";
> = false;
uniform float MaskExposure <
ui_type = "drag";
ui_min = -1.0; ui_max = 1.0;
> = 0.0;
uniform bool MaskReverse = false;
texture tDepthMask { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };
sampler sDepthMask { Texture = tDepthMask; };
float4 PS_Backup(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
return tex2D(ReShade::BackBuffer, uv);
}
float4 PS_ApplyMask(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
float3 col = tex2D(ReShade::BackBuffer, uv).rgb;
float3 bak = tex2D(sDepthMask, uv).rgb;
float mask;
if ( MaskReverse == 1 )
mask = (1-ReShade::GetLinearizedDepth(uv).r);
else
mask = ReShade::GetLinearizedDepth(uv).r;
if (mask > DepthMaskCut )
mask == 1;
mask *= pow(2.0f, MaskExposure); // Exposure
mask = lerp(1.0, mask, fMask_Intensity);
col = lerp(bak, col, mask);
col = bDisplayMask ? mask : col;
return float4(col, 1.0);
}
technique DepthMask_Top {
pass {
VertexShader = PostProcessVS;
PixelShader = PS_Backup;
RenderTarget = tDepthMask;
}
}
technique DepthMask_Bottom {
pass {
VertexShader = PostProcessVS;
PixelShader = PS_ApplyMask;
}
}