[HLSL code] Original postprocess SSE.ver

share shaders here
  • Author
  • Message
Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

[HLSL code] Original postprocess SSE.ver

It start with loading textures:
The UV coord of bloom texture has a scaling factor controlled by clamps and a on/off switch.

Code: Select all

    bool   scalebloom  = (0.5<=Params01[0].x);
    float2 scaleduv    = clamp(0.0, Params01[6].zy, Params01[6].xy * IN.txcoord0.xy);
    float4 color       = TextureColor.Sample(Sampler0, IN.txcoord0.xy); //hdr scene color, point sampler
    float4 bloom       = TextureBloom.Sample(Sampler1, (scalebloom)? IN.txcoord0.xy: scaleduv); //linear sampler
    float2 middlegray  = TextureAdaptation.Sample(Sampler1, IN.txcoord0.xy).xy; //.x == current, .y == previous
    middlegray.y = 1.0; //bypass for enbadaptation format

then, the tonemapper"s"
A additional switch for switching between Reinhard-modified and Filmic ALU by Heji

Code: Select all

    bool   UseFilmic   = (0.5<Params01[2].z);
    float  WhiteFactor = Params01[2].y;
    
    float  original_lum = max( dot(LUM_709, color.rgb), DELTA);
    float  lum_scaled   = original_lum * middlegray.y / middlegray.x;
           
    float  lum_filmic = max( lum_scaled - 0.004, 0.0); 
           lum_filmic = lum_filmic * (lum_filmic * 6.2 + 0.5)  / (lum_filmic * (lum_filmic * 6.2 + 1.7) + 0.06);
           lum_filmic = pow(lum_filmic, 2.2);          //de-gamma-correction for gamma-corrected tonemapper
           lum_filmic = lum_filmic * WhiteFactor;    //linear scale
    
    float lum_reinhard = lum_scaled * (lum_scaled * WhiteFactor + 1.0) / (lum_scaled + 1.0);
    
    float lum_mapped   = (UseFilmic)? lum_filmic : lum_reinhard; //if filmic
    
    color.rgb = color.rgb * lum_mapped / original_lum;

then do the bloom blending, this part is identical to the old Skyrim.

Code: Select all

    float bloomfactor = Params01[2].x;
    color.rgb = color.rgb + bloom.rgb * saturate(bloomfactor - lum_mapped); 
And the imagespace modifiers, mostly the same as the old Skyrim,
but it has a inactive process with Params01[6].w, seemly supposed to have a gamma ops there.

Code: Select all

    float  saturation  = Params01[3].x;   // 0 == gray scale
    float  contrast    = Params01[3].z;   // 0 == no contrast
    float  brightness  = Params01[3].w;   // intensity
    
    
    float3 tint_color  = Params01[4].rgb; // tint color
    float  tint_weight = Params01[4].w;   // 0 == no tint

    float3 fade        = Params01[5].xyz; // fade current scene to specified color, mostly used in special effects
    float  fade_weight = Params01[5].w;   // 0 == no fade
    
    color.a   = dot(color.rgb, LUM_709);
    color.rgb = lerp(color.a, color.rgb, saturation);
    color.rgb = lerp(color.rgb, tint_color * color.a , tint_weight);
    color.rgb = lerp(middlegray.x, color.rgb * brightness, contrast);
//    color.rgb = pow(saturate(color.rgb), Params01[6].w); //this line is unused??
    color.rgb = lerp(color.rgb, fade, fade_weight);
    color.a = 1.0;
Last edited by kingeric1992 on 10 Jan 2017, 03:00, edited 3 times in total.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
Posts: 78
Joined: 08 Nov 2013, 07:42
Location: Taiwan

Re: [HLSL code] Original postprocess SEE.ver

Hell yeah~ ;) ;)
_________________
Observing the world with aesthetic taste.

Offline
User avatar
*master*
Posts: 136
Joined: 08 Nov 2012, 15:24

Re: [HLSL code] Original postprocess SEE.ver

This is really interesting. Thank you very much.

Offline
*master*
Posts: 144
Joined: 10 May 2015, 04:33

Re: [HLSL code] Original postprocess SEE.ver

Now to learn how to take that and apply it :) lol..... baby steps... one day....

Offline
User avatar
*master*
Posts: 136
Joined: 08 Nov 2012, 15:24

Re: [HLSL code] Original postprocess SEE.ver

A small bug - tint_color and tint_weight should refer to Params01[4], not Params01[3].

While this may be obvious to some people, I feel I should note that as ENB doesn't have a UseOriginalAdaptation option, you'll need to replace the code for lum_scaled with one designed around ENB's adaptation system, which is single channel. Otherwise, you'll get a black screen.
Last edited by roxahris on 13 Nov 2016, 15:10, edited 1 time in total.

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL code] Original postprocess SEE.ver

@roxahris

Indeed. thanks for the reply.

post updated.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

l00
Offline
User avatar
*master*
Posts: 112
Joined: 30 Jan 2016, 11:26
Location: France

Re: [HLSL code] Original postprocess SEE.ver

I found what is the coef definition for LUM_709 (just in case, is that right: "0.2126, 0.7152, 0.0722"?) but what should be used for DELTA, what is this variable ?
_________________
Released ENB: PRC - PRT - Painterly' | FO4 mods: NAC | Videos: ::Virtual.Camera::

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: [HLSL code] Original postprocess SEE.ver

Assuming from the code, just some very small value, so the original lum can never be 0, hence avoiding the division through 0 in the last line of the tonemapper. It's very common in shadercode to do stuff like this, max(x,0.00000001) for instance.

l00
Offline
User avatar
*master*
Posts: 112
Joined: 30 Jan 2016, 11:26
Location: France

Re: [HLSL code] Original postprocess SEE.ver

Ho I see, it works.
Thanks both of you McFly and Kingeric, my AGCC is working great now !
_________________
Released ENB: PRC - PRT - Painterly' | FO4 mods: NAC | Videos: ::Virtual.Camera::

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: [HLSL code] Original postprocess SEE.ver

l00
Would you mind sharing your effect.fx ?
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop
Post Reply