forked from crosire/reshade-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayer.fx
98 lines (80 loc) · 2.48 KB
/
Layer.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*------------------.
| :: Description :: |
'-------------------/
Layer (version 0.2)
Author: CeeJay.dk
License: MIT
About:
Blends an image with the game.
The idea is to give users with graphics skills the ability to create effects using a layer just like in an image editor.
Maybe they could use this to create custom CRT effects, custom vignettes, logos, custom hud elements, toggable help screens and crafting tables or something I haven't thought of.
Ideas for future improvement:
* More blend modes
* Tiling control
* A default Layer texture with something useful in it
History:
(*) Feature (+) Improvement (x) Bugfix (-) Information (!) Compatibility
Version 0.2 by seri14 & Marot Satil
* Added the ability to scale and move the layer around on XY axis
*/
#include "ReShade.fxh"
#ifndef LAYER_SOURCE
#define LAYER_SOURCE "Layer.png"
#endif
#ifndef LAYER_SIZE_X
#define LAYER_SIZE_X 1280
#endif
#ifndef LAYER_SIZE_Y
#define LAYER_SIZE_Y 720
#endif
#if LAYER_SINGLECHANNEL
#define TEXFORMAT R8
#else
#define TEXFORMAT RGBA8
#endif
#include "ReShadeUI.fxh"
uniform float2 Layer_Pos < __UNIFORM_DRAG_FLOAT2
ui_label = "Layer Position";
ui_min = 0.0; ui_max = 1.0;
ui_step = (1.0 / 200.0);
> = float2(0.5, 0.5);
uniform float Layer_Scale < __UNIFORM_DRAG_FLOAT1
ui_label = "Layer Scale";
ui_min = (1.0 / 100.0); ui_max = 4.0;
ui_step = (1.0 / 250.0);
> = 1.0;
uniform float Layer_Blend < __UNIFORM_COLOR_FLOAT1
ui_label = "Layer Blend";
ui_tooltip = "How much to blend layer with the original image.";
ui_min = 0.0; ui_max = 1.0;
ui_step = (1.0 / 255.0); // for slider and drag
> = 1.0;
texture Layer_Tex <
source = LAYER_SOURCE;
> {
Format = TEXFORMAT;
Width = LAYER_SIZE_X;
Height = LAYER_SIZE_Y;
};
sampler Layer_Sampler
{
Texture = Layer_Tex;
AddressU = BORDER;
AddressV = BORDER;
};
void PS_Layer(float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target)
{
const float4 backColor = tex2D(ReShade::BackBuffer, texCoord);
const float2 pixelSize = 1.0 / (float2(LAYER_SIZE_X, LAYER_SIZE_Y) * Layer_Scale / BUFFER_SCREEN_SIZE);
const float4 layer = tex2D(Layer_Sampler, texCoord * pixelSize + Layer_Pos * (1.0 - pixelSize));
passColor = lerp(backColor, layer, layer.a * Layer_Blend);
passColor.a = backColor.a;
}
technique Layer
{
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_Layer;
}
}