-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHejl2015.fx
69 lines (54 loc) · 2.01 KB
/
Hejl2015.fx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Reshade port of Hejl's 2015 filmic tonemap
// Base code sourced from a Jim Hejl tweet at https://twitter.com/jimhejl/status/633777619998130176
// by Jace Regenbrecht
uniform float H2015_W <
ui_type = "drag";
ui_min = 0.00; ui_max = 20.00;
ui_label = "Scene White Point Value";
> = 11.2;
uniform float H2015_Exp <
ui_type = "drag";
ui_min = 1.00; ui_max = 20.00;
ui_label = "Exposure";
> = 1.0;
uniform float H2015_Gamma <
ui_type = "drag";
ui_min = 1.00; ui_max = 3.00;
ui_label = "Gamma value";
ui_tooltip = "Most monitors/images use a value of 2.2. Setting this to 1 disables the pre-tonemapping degamma of the game image, causing that ugly washed out effect you see in the SweetFx implementation.";
> = 2.2;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include "ReShade.fxh"
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
float3 Hejl2015_Tonemap(float4 pos : SV_Position, float2 texcoord : TexCoord ) : COLOR
{
float3 texColor = tex2D(ReShade::BackBuffer, texcoord ).rgb;
// Do inital de-gamma of the game image to ensure we're operating in the correct colour range.
if( H2015_Gamma > 1.00 )
texColor = pow(texColor,H2015_Gamma);
texColor *= H2015_Exp; // Exposure Adjustment
// Hejl 2015 tonemap
float4 vh = float4(texColor, H2015_W); // pack: [r,g,b,w]
float4 va = (1.425f * vh) + 0.05f; // eval filmic curve
float4 vf = ((vh * va + 0.004f) / ((vh * (va + 0.55f) + 0.0491f))) - 0.0821f;
texColor = vf.rgb / vf.www; // White point correction
// Do the post-tonemapping gamma correction
if( H2015_Gamma > 1.00 )
texColor = pow(texColor,1/H2015_Gamma);
return texColor;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
technique Hejl2015
{
pass
{
VertexShader = PostProcessVS;
PixelShader = Hejl2015_Tonemap;
}
}