-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLumaLines.fx
More file actions
62 lines (49 loc) · 1.83 KB
/
LumaLines.fx
File metadata and controls
62 lines (49 loc) · 1.83 KB
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
#include "ReShade.fxh"
#include "ReShadeUI.fxh"
uniform int lineDensity < __UNIFORM_SLIDER_INT1
ui_min = 1; ui_max = 100;
ui_tooltip = "if you put this at 0 your game crashes";
> = 10;
uniform float blackThreshold < __UNIFORM_SLIDER_FLOAT1
ui_min = 0.0; ui_max = 1.0;
> = 0.1;
uniform float whiteThreshold < __UNIFORM_SLIDER_FLOAT1
ui_min = 0.0; ui_max = 1.0;
> = 0.9;
uniform bool blend <
> = false;
float3 lumaLines(in float4 pos : SV_Position, in float2 texcoord : TEXCOORD) : COLOR
{
int OneBitLuma, OneBitLumaShift, lines;
float luma = dot(tex2D(ReShade::BackBuffer, texcoord).rgb, 1.0 / 3.0);
for(float i = 1.0 / lineDensity; i <= 1.0 - (1.0 / lineDensity); i += (1.0 / lineDensity))
{
OneBitLuma = ceil(1.0 - step(luma, i));
OneBitLumaShift = ceil(1.0 - step(dot(tex2D(ReShade::BackBuffer, float2(texcoord.x + BUFFER_RCP_WIDTH, texcoord.y)).rgb, 1.0 / 3.0), i));
lines += OneBitLumaShift - OneBitLuma;
OneBitLumaShift = ceil(1.0 - step(dot(tex2D(ReShade::BackBuffer, float2(texcoord.x - BUFFER_RCP_WIDTH, texcoord.y)).rgb, 1.0 / 3.0), i));
lines += OneBitLumaShift - OneBitLuma;
OneBitLumaShift = ceil(1.0 - step(dot(tex2D(ReShade::BackBuffer, float2(texcoord.x, texcoord.y + BUFFER_RCP_HEIGHT)).rgb, 1.0 / 3.0), i));
lines += OneBitLumaShift - OneBitLuma;
OneBitLumaShift = ceil(1.0 - step(dot(tex2D(ReShade::BackBuffer, float2(texcoord.x, texcoord.y - BUFFER_RCP_HEIGHT)).rgb, 1.0 / 3.0), i));
lines += OneBitLumaShift - OneBitLuma;
}
lines = max(lines, ceil(step(luma, blackThreshold)));
lines = min(lines, ceil(step(luma, whiteThreshold)));
if(blend)
{
return (1.0 - lines) * tex2D(ReShade::BackBuffer, texcoord).rgb;
}
else
{
return 1.0 - lines;
}
}
technique LumaLines
{
pass pass0
{
VertexShader = PostProcessVS;
PixelShader = lumaLines;
}
}