[DX9 and DX11] Darken Distance

share shaders here
Post Reply
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

[DX9 and DX11] Darken Distance

This was done by request from jake_S.

It allows a darkening effect, that visually behaves similar to fog. But is not dependent on anything in-game.

You can alter the amount of darkening, or even brighten the distance up a bit. It is also possible to determine where the effect should start from, right from the player feet or at the bottom of the distant mountains.

ImageNew ENBSeries effect 1 by JanderswedinZ, on Flickr

ImageNew ENBSeries effect 2 by JanderswedinZ, on Flickr

ImageNew ENBSeries effect 3 by JanderswedinZ, on Flickr


Files
Note: There is no TOD seperation in this file, you will have to do that on your own!

v1.1: Corrected DX9 version, added a simple color tint to both versions.
Darken Distance v1.1 - Google Drive Download

Offline
User avatar
*blah-blah-blah maniac*
Posts: 983
Joined: 09 Dec 2012, 00:29

Re: [DX9 and DX11] Darken Distance

Thanks a lot JawZ and all the best in the New Year :D
_________________
Rudy ENB for Skyrim, Skyrim SE, for Fallout New Vegas, for Dragon's Dogma

English is not my native language.

AMD Ryzen 9 5900X, Gigabyte B550 AORUS PRO AC, Arctic Liquid Freezer II 280, Nvidia Geforce RTX 2070 Super, 64GB ram

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [DX9 and DX11] Darken Distance

You're welcome Guzio ;)

Offline
User avatar
*sensei*
Posts: 391
Joined: 03 Oct 2012, 06:12
Location: Ottawa, Canada

Re: [DX9 and DX11] Darken Distance

Thank you. The more unique effects, the better :)
_________________
Intel Core i9 10900K @4.9GHz | ASUS ROG Strix Z490-G | NVIDIA - EVGA RTX 2080 XC Ultra | 32GB DDR4 Corsair Vengeance RGB PRO | 2x ADATA XPG SX8200 Pro 1TB

Flickr
Twitter

Offline
User avatar
*master*
Posts: 156
Joined: 04 Jan 2019, 15:27

Re: [DX9 and DX11] Darken Distance

Rather than darkening I'd have desaturation or color shift towards blue in the distance. OK now I see there's color tint option, maybe that'd work.
_________________
ENB Light at NexusMods

Offline
Posts: 4
Joined: 17 Feb 2018, 02:43

Re: [DX9 and DX11] Darken Distance

Sorry for the noob question, I really love the idea here, but I have no clue on how to make this work on my game; is there a tutorial for adding custom effects, or I just drop the files somewhere?

Offline
User avatar
*sensei*
Posts: 391
Joined: 03 Oct 2012, 06:12
Location: Ottawa, Canada

Re: [DX9 and DX11] Darken Distance

Hey guys,

Is there a way to implement a sort of gradient between the foreground to the distance? Say, for the instance, you can choose a foreground tint and then transition to the distance tint that is already implemented in the included code.

Thanks for the code and help! :)
_________________
Intel Core i9 10900K @4.9GHz | ASUS ROG Strix Z490-G | NVIDIA - EVGA RTX 2080 XC Ultra | 32GB DDR4 Corsair Vengeance RGB PRO | 2x ADATA XPG SX8200 Pro 1TB

Flickr
Twitter

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17444
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: [DX9 and DX11] Darken Distance

Better make sample image in photo editor to understand what is background for you and how to apply it.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
Posts: 99
Joined: 11 May 2014, 10:48

Re: [DX9 and DX11] Darken Distance

ZeroKing wrote:Hey guys,

Is there a way to implement a sort of gradient between the foreground to the distance? Say, for the instance, you can choose a foreground tint and then transition to the distance tint that is already implemented in the included code.

Thanks for the code and help! :)
My "split tone" effect from ColorLab will basically let you do this, you just use depth instead of brightness for it.

Code: Select all

// step function to use for the split range effect
// possible options:
//   linearstep
//   smoothstep
#define SPLIT_RANGE_STEP_FUNCTION linearstep

float3 splitRanges(float t, float lo1, float lo2, float hi1, float hi2)
{
    float3 res;

    float2 lo = float2(lo1, lo2);
    float2 hi = float2(hi1, hi2);

    hi.x = 1.0 - hi.x;

    hi.y = clamp(hi.y, lo.x, hi.x-1e-6);
    lo.y = clamp(lo.y, lo.x+1e-6, hi.x);

    res.x = SPLIT_RANGE_STEP_FUNCTION(lo.y, lo.x, t);
    res.y = SPLIT_RANGE_STEP_FUNCTION(lo.x, lo.y, t) - SPLIT_RANGE_STEP_FUNCTION(hi.y, hi.x, t);
    res.z = SPLIT_RANGE_STEP_FUNCTION(hi.y, hi.x, t);

    return saturate(res);
}

/* Proposed usage for depth based effect:
    float linear_depth = getLinearDepth(); // Get it one way or another
    float3 split_weights = splitRanges(linear_depth, ForegroundDeadzone, ForegroundCutoff, BackgroundDeadzone, BackgroundCutoff);
    float3 tint = mul(split_weights, float3x3(ForegroundColor, MiddlegroundColor, BackgroundColor));
    color.xyz = lerp(color.xyz, color.xyz * tint, DepthEffectIntensity);
*/

/* Proposed usage for luma based effect:
    float luma = getLuma(color); // Your preferred luma function
    float3 split_weights = splitRanges(luma, ShadowsDeadzone, ShadowsCutoff, HighlightsDeadzone, HighlightsCutoff);
    float3 tint = mul(split_weights, float3x3(ShadowsColor, MidtonesColor, HighlightsColor));
    color.xyz = lerp(color.xyz, color.xyz * tint, SplitToneEffectIntensity);
*/
Image

The Deadzone and Cutoff parameters should just be in the 0-1 range. You could look at ColorLab to see how the parameters work and how to set them up, if you enable graphs you can get a feel for it. I hope I didn't leave out too much details for using the code, if you need help using it let me know.
_________________
Reforged ENB for Dragon's Dogma, The Witcher 2, Kingdom Come: Deliverance
Post Reply