Skip to content

Commit 6e4f26e

Browse files
committed
Thief: unify lut builders
1 parent 8db6071 commit 6e4f26e

6 files changed

Lines changed: 99 additions & 222 deletions

‎Shaders/Thief (2014)/Dev/UnknownPP_0x06F9EC9F.ps_5_0.hlsl‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎Shaders/Thief (2014)/Dev/UnknownPP_0x51A8FE04.ps_5_0.hlsl‎

Lines changed: 0 additions & 49 deletions
This file was deleted.

‎Shaders/Thief (2014)/Dev/UnknownPP_0x56B46C0A.ps_5_0.hlsl‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎Shaders/Thief (2014)/Dev/UnknownPP_0x90F01F91.ps_5_0.hlsl‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

‎Shaders/Thief (2014)/Dev/UnknownPP_0x9D987720.ps_5_0.hlsl‎

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#include "../../Includes/Common.hlsl"
2+
3+
// Number of authored grading LUTs; the neutral LUT is generated below.
4+
#if _56B46C0A
5+
#define LUT_COUNT 0
6+
#elif _90F01F91
7+
#define LUT_COUNT 1
8+
#elif _06F9EC9F
9+
#define LUT_COUNT 2
10+
#elif _51A8FE04
11+
#define LUT_COUNT 3
12+
#elif _9D987720
13+
#define LUT_COUNT 4
14+
#else
15+
#error Unknown LUT builder shader hash
16+
#endif
17+
18+
Texture2D<float4> t3 : register(t3);
19+
Texture2D<float4> t2 : register(t2);
20+
Texture2D<float4> t1 : register(t1);
21+
Texture2D<float4> t0 : register(t0);
22+
23+
SamplerState s3_s : register(s3);
24+
SamplerState s2_s : register(s2);
25+
SamplerState s1_s : register(s1);
26+
SamplerState s0_s : register(s0);
27+
28+
cbuffer cb0 : register(b0)
29+
{
30+
float4 cb0[11 + LUT_COUNT];
31+
}
32+
33+
void main(
34+
float2 v0 : TEXCOORD0,
35+
out float4 o0 : SV_Target0)
36+
{
37+
float4 r0,r1,r2,r3,r4;
38+
r0.xz = float2(-0.001953125,-0.03125) + v0.xy;
39+
r1.x = 16 * r0.x;
40+
r0.w = frac(r1.x);
41+
r0.y = -r0.w * 0.0625 + r0.x;
42+
r0.xyz = cb0[10].x * r0.yzw;
43+
44+
#if LUT_COUNT == 0 // No luts, use neutral
45+
46+
r1.xyz = 1.06666672 * r0.xyz;
47+
r0.w = GetLuminance(r1.xyz); // Luma: fixed from BT.601 coeffs
48+
r0.xyz = -r0.xyz * 1.06666672 + r0.w;
49+
r0.w = linear_to_gamma1(r0.w, GCT_POSITIVE); // Luma: fixed using sqrt as approximation of gamma 2.2
50+
r2.x = cb0[7].x * r0.w;
51+
r2.y = cb0[7].x * r0.w - 0.5;
52+
r2.xy = saturate(r2.xy + r2.xy);
53+
54+
#else // LUT_COUNT != 0
55+
56+
r0.xyz = 1.06666672 * r0.xyz;
57+
r0.w = 0;
58+
#if LUT_COUNT >= 1
59+
r1.xyzw = t0.Sample(s0_s, v0.xy).xyzw;
60+
r0.xyzw += cb0[11].x * r1.xyzw;
61+
#endif
62+
#if LUT_COUNT >= 2
63+
r1.xyzw = t1.Sample(s1_s, v0.xy).xyzw;
64+
r0.xyzw += cb0[12].x * r1.xyzw;
65+
#endif
66+
#if LUT_COUNT >= 3
67+
r1.xyzw = t2.Sample(s2_s, v0.xy).xyzw;
68+
r0.xyzw += cb0[13].x * r1.xyzw;
69+
#endif
70+
#if LUT_COUNT >= 4
71+
r1.xyzw = t3.Sample(s3_s, v0.xy).xyzw;
72+
r0.xyzw += cb0[14].x * r1.xyzw;
73+
74+
#endif // LUT_COUNT == 0
75+
76+
r1.x = GetLuminance(r0.xyz); // Luma: fixed from BT.601 coeffs
77+
r1.yzw = r1.x - r0.xyz;
78+
r1.x = linear_to_gamma1(r1.x, GCT_POSITIVE); // Luma: fixed using sqrt as approximation of gamma 2.2
79+
r2.x = cb0[7].x * r1.x;
80+
r2.y = cb0[7].x * r1.x - 0.5;
81+
r2.xy = saturate(r2.xy + r2.xy);
82+
#endif
83+
r3.xyzw = cb0[3].xyzw - cb0[1].xyzw;
84+
r3.xyzw = r2.x * r3.xyzw + cb0[1].xyzw;
85+
r4.xyzw = cb0[5].xyzw - r3.xyzw;
86+
r2.xyzw = r2.y * r4.xyzw + r3.xyzw;
87+
#if LUT_COUNT == 0
88+
r0.xyz = r2.w * r0.xyz + r1.xyz;
89+
#else
90+
r0.xyz = r2.w * r1.yzw + r0.xyz;
91+
o0.w = r0.w;
92+
#endif
93+
r1.xyz = r2.xyz * r0.xyz;
94+
r0.xyz = -r2.xyz * r0.xyz + cb0[9].xyz;
95+
o0.xyz = cb0[9].w * r0.xyz + r1.xyz;
96+
#if LUT_COUNT == 0
97+
o0.w = 0;
98+
#endif
99+
}

0 commit comments

Comments
 (0)