Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ReShade.fxh"
- // I hereby decree this shader to be version 1
- // Spectral power distribution
- static const float3 SPD = float3(0.412656, 0.715158, 0.072186);
- static const float SPD_MAG = 1.73205;
- uniform float amount <
- ui_category = "General";
- ui_label = "Amount";
- ui_max = 4;
- ui_min = -4;
- ui_step = 0.0000001;
- ui_tooltip = "Effect intensity";
- ui_type = "slider";
- > = 1;
- uniform float skyboxDepth <
- ui_category = "General";
- ui_label = "Skybox Depth";
- ui_max = 1;
- ui_min = -1;
- ui_step = 0.0001;
- ui_tooltip = "Objects at or past this threshold will be treated as part of the skybox. Use negative values if the skybox has a zero depth.";
- ui_type = "slider";
- > = 1;
- uniform float skyboxKnee <
- ui_category = "General";
- ui_label = "Skybox Depth Knee";
- ui_max = 1;
- ui_min = 0;
- ui_step = 0.0001;
- ui_tooltip = "I guess this might prevent the threshold from being visible? Leave at 1 if not seeing any issues";
- ui_type = "slider";
- > = 1;
- uniform float darkenAmount <
- ui_category = "Darkening";
- ui_label = "Strength";
- ui_max = 4;
- ui_min = -4;
- ui_step = 0.0000001;
- ui_tooltip = "How much darker would dark areas be";
- ui_type = "slider";
- > = 0;
- uniform float darkenKnee <
- ui_category = "Darkening";
- ui_label = "Knee";
- ui_max = 4;
- ui_min = 0;
- ui_step = 0.0000001;
- ui_tooltip = "How smooth will the transition between affected and unaffected areas be";
- ui_type = "slider";
- > = 1;
- uniform float saturateAmount <
- ui_category = "Saturation";
- ui_label = "Strength";
- ui_max = 4;
- ui_min = -4;
- ui_step = 0.0000001;
- ui_tooltip = "Darker colors appear more saturated to a human eye; use this slider to account for that";
- ui_type = "slider";
- > = 1;
- uniform float saturateKnee <
- ui_category = "Saturation";
- ui_label = "Knee";
- ui_max = 4;
- ui_min = 0;
- ui_step = 0.0000001;
- ui_tooltip = "How smooth will the transition between affected and unaffected areas be";
- ui_type = "slider";
- > = 1;
- // PD80 Base Effects
- float getLuma(in float3 col)
- {
- return dot(col, SPD);
- }
- // PD80 Base Effects
- float3 sat(float3 col, float fac)
- {
- return saturate(lerp(getLuma(col.rgb), col.rgb, fac));
- }
- float3 exposure(float3 col, float fac)
- {
- // Why? Hell if I know, I'm just not gonna touch that
- fac = fac < 0.0f ? fac * 0.333f : fac;
- float3 preexp = col * exp2(fac);
- float3 blowout = (max(0, preexp - 1));
- float3 adjust = float3(blowout.g + blowout.b, blowout.r + blowout.b, blowout.r + blowout.g);
- return preexp + adjust;
- }
- float3 PS_SkyboxDarkenFXmain(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
- {
- float3 input = tex2D(ReShade::BackBuffer, texcoord).rgb;
- float fragDepth = pow(ReShade::GetLinearizedDepth(texcoord), skyboxKnee);
- float3 result = input;
- if(skyboxDepth <= 0.0)
- {
- skyboxDepth = -skyboxDepth;
- fragDepth = 1.0 - fragDepth;
- }
- if(fragDepth >= skyboxDepth)
- {
- float shadow = 1.0 - getLuma(input) / SPD_MAG;
- result = exposure(result, pow(shadow, darkenKnee) * -darkenAmount);
- result = lerp(result, sat(result, saturateAmount), pow(shadow, saturateKnee));
- }
- return lerp(input, result, amount);
- }
- technique SkyboxDarken
- {
- pass draw
- {
- VertexShader = PostProcessVS;
- PixelShader = PS_SkyboxDarkenFXmain;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment