ProjectArcade
73 строки · 2.3 Кб
1/**
2* Border version 1.4.1
3*
4* -- Version 1.0 by Oomek --
5* Fixes light, one pixel thick border in some games when forcing MSAA like i.e. Dishonored
6* -- Version 1.1 by CeeJay.dk --
7* Optimized the shader. It still does the same but now it runs faster.
8* -- Version 1.2 by CeeJay.dk --
9* Added border_width and border_color features
10* -- Version 1.3 by CeeJay.dk --
11* Optimized the performance further
12* -- Version 1.4 by CeeJay.dk --
13* Added the border_ratio feature
14* -- Version 1.4.1 by CeeJay.dk --
15* Cleaned up setting for Reshade 3.x
16*/
17
18#include "ReShade.fxh"
19#include "ReShadeUI.fxh"
20
21/*
22uniform float2 border_width <
23ui_type = "input";
24ui_label = "Size";
25ui_tooltip = "Measured in pixels. If this is set to zero then the ratio will be used instead.";
26> = float2(15.0, 15.0);
27*/
28
29uniform float2 border_width <
30ui_type = "drag";
31ui_label = "Size";
32ui_tooltip = "Measured in pixels. If this is set to zero then the ratio will be used instead.";
33ui_min = 0.0; ui_max = (BUFFER_WIDTH * 0.5);
34ui_step = 1.0;
35> = float2(15.0, 15.0);
36
37uniform float border_ratio <
38ui_type = "input";
39ui_label = "Size Ratio";
40ui_tooltip = "Set the desired ratio for the visible area.";
41> = 2.35;
42
43uniform float3 border_color <
44ui_type = "color";
45ui_label = "Border Color";
46> = float3(255.0, 255.0, 255.0);
47
48float3 BorderPass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
49{
50float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
51
52// -- calculate the right border_width for a given border_ratio --
53float2 border_width_variable = border_width;
54if (border_width.x == -border_width.y) // If width is not used
55if (BUFFER_ASPECT_RATIO < border_ratio)
56border_width_variable = float2(0.0, (BUFFER_HEIGHT - (BUFFER_WIDTH / border_ratio)) * 0.5);
57else
58border_width_variable = float2((BUFFER_WIDTH - (BUFFER_HEIGHT * border_ratio)) * 0.5, 0.0);
59
60float2 border = (BUFFER_PIXEL_SIZE * border_width_variable); // Translate integer pixel width to floating point
61float2 within_border = saturate((-texcoord * texcoord + texcoord) - (-border * border + border)); // Becomes positive when inside the border and zero when outside
62
63return all(within_border) ? color : border_color;
64}
65
66technique Border
67{
68pass
69{
70VertexShader = PostProcessVS;
71PixelShader = BorderPass;
72}
73}
74