[Idea] Depth selection for depth effects

More
6 months 4 weeks ago #1 by Sasuke_Louis
[Idea] Depth selection for depth effects was created by Sasuke_Louis
I'm not sure if its possible to do that, im not a programer at all, but i idealize something like the fog removal or the ui mask, where you select any effect between the in and out of those effects to have some condition. For example , i would like to have some kind of depth mask, cause sometimes im playing a 3rd person game, and i dont want the screenspace reflections or any other depth effect aplied near (on my character) something like that

[Depthmask_top]
[Dof]
[Ssr]
[Rtgi]
[any other depth based effect]
[Depthmask_bottom]

The [Depthmask_top] will detect and select the depth buffer that the effects below will be aplied, then the [Depthmask_bottom] will restore the depth buffer to its original form.

That is it, im sorry for the poor english, its not my native language. if any one knows if its possible just reply to me for more details

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago - 6 months 3 weeks ago #2 by du
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;
    }
}
Last edit: 6 months 3 weeks ago by du.

Please Log in or Create an account to join the conversation.