[Idea] Depth selection for depth effects

  • Sasuke_Louis
  • Topic Author
More
2 years 4 months 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.

  • du
More
2 years 4 months ago - 2 years 4 months ago #2 by du Replied by du on topic [Idea] Depth selection for depth effects
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: 2 years 4 months ago by du.

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

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.