Skip to content

Commit ec17fb0

Browse files
committed
Adds MIT license for retro-v2 soft-light, also fixes border/aspect ratio
1 parent b17e0f2 commit ec17fb0

File tree

4 files changed

+47
-21
lines changed

4 files changed

+47
-21
lines changed

reshade/retro-v2-softlight-subtle.glslp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ shader1 = shaders/blendsoftlight/blendsoftlight.glsl
44

55

66

7-
textures = "overlay"
7+
textures = "overlay;BORDER"
88
# change this path to point to your overlay image
99
overlay = shaders/blendsoftlight/shine_subtle.png
10+
BORDER = shaders/blendsoftlight/border.png
1011
OverlayMix = 1.0
12+
ASPECTRATIO = "43.0"
1113

1214
scale_type0 = source
1315
scale0 = 4
@@ -18,4 +20,4 @@ filter_linear1 = true
1820
parameters = "RETRO_PIXEL_SIZE"
1921
# set these to the width/height of your overlay image
2022
SCALE = "1.0"
21-
RETRO_PIXEL_SIZE = "0.70"
23+
RETRO_PIXEL_SIZE = "0.70"

reshade/retro-v2-softlight.glslp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ shader1 = shaders/blendsoftlight/blendsoftlight.glsl
44

55

66

7-
textures = "overlay"
7+
textures = "overlay;BORDER"
88
# change this path to point to your overlay image
99
overlay = shaders/blendsoftlight/shine.png
10+
BORDER = shaders/blendsoftlight/border.png
1011
OverlayMix = 1.0
12+
ASPECTRATIO = "43.0"
1113

1214
scale_type0 = source
1315
scale0 = 4
@@ -18,4 +20,4 @@ filter_linear1 = true
1820
parameters = "RETRO_PIXEL_SIZE"
1921
# set these to the width/height of your overlay image
2022
SCALE = "1.0"
21-
RETRO_PIXEL_SIZE = "0.70"
23+
RETRO_PIXEL_SIZE = "0.70"

reshade/shaders/blendsoftlight/blendsoftlight.glsl

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
// blendSoftlight
44
// based on:
55
// https://github.com/jamieowen/glsl-blend for blendSoftlight
6+
//
7+
// The MIT License (MIT) Copyright (c) 2015 Jamie Owen
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9+
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
//
12+
// Same MIT License applies to contributions from Ben Reaves
13+
//
614

715
#pragma parameter OverlayMix "Overlay Mix" 1.0 0.0 1.0 0.05
8-
#pragma parameter SCALE "Box Scale" 0.6667 0.6667 1.5 0.33333
9-
#pragma parameter OUT_X "Out X" 1600.0 1600.0 4800.0 8000.0
10-
#pragma parameter OUT_Y "Out Y" 800.0 800.0 2400.0 400.0
16+
#pragma parameter SCALE "Box Scale" 4.0 0.25 4.0 0.05
17+
#pragma parameter ASPECTRATIO "Aspect Ratio" 87.0 43.0 87.0 44.0
1118

1219
#if defined(VERTEX)
1320

@@ -44,28 +51,33 @@ uniform COMPAT_PRECISION vec2 InputSize;
4451
// compatibility #defines
4552
#define vTexCoord TEX0.xy
4653
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
47-
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
54+
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
4855

4956
#ifdef PARAMETER_UNIFORM
5057
// All parameter floats need to have COMPAT_PRECISION in front of them
5158
uniform COMPAT_PRECISION float SCALE;
52-
uniform COMPAT_PRECISION float OUT_X;
53-
uniform COMPAT_PRECISION float OUT_Y;
59+
uniform COMPAT_PRECISION float ASPECTRATIO;
5460
#else
55-
#define SCALE 0.66667
56-
#define OUT_X 1600.0
57-
#define OUT_Y 800.0
61+
#define SCALE 1.0
62+
#define ASPECTRATIO 87.0
5863
#endif
5964

6065
void main()
6166
{
6267
gl_Position = MVPMatrix * VertexCoord;
63-
TEX0.xy = TexCoord.xy;
64-
65-
// vec2 scale = (OutputSize.xy / InputSize.xy) / SCALE;
66-
// vec2 middle = vec2(0.5, 0.5) * InputSize.xy / TextureSize.xy;
67-
// vec2 diff = TexCoord.xy - middle;
68-
// TEX0.xy = middle + diff * scale;
68+
if (ASPECTRATIO == 43.0) {
69+
TEX0.xy = TexCoord.xy;
70+
}
71+
else if (ASPECTRATIO == 87.0) {
72+
vec2 box_scale = vec2(SCALE + 0.06, SCALE + 0.06);
73+
vec2 scale = (OutputSize.xy / SourceSize.xy) / box_scale;
74+
vec2 middle = vec2(0.5, 0.5) * SourceSize.xy / TextureSize.xy;
75+
vec2 diff = TexCoord.xy - middle;
76+
TEX0.xy = (middle + diff * scale);
77+
}
78+
else {
79+
TEX0.xy = TexCoord.xy;
80+
}
6981
}
7082

7183
#elif defined(FRAGMENT)
@@ -97,6 +109,7 @@ uniform COMPAT_PRECISION vec2 OutputSize;
97109
uniform COMPAT_PRECISION vec2 TextureSize;
98110
uniform COMPAT_PRECISION vec2 InputSize;
99111
uniform sampler2D Texture;
112+
uniform sampler2D BORDER;
100113
uniform sampler2D overlay;
101114
COMPAT_VARYING vec4 TEX0;
102115

@@ -109,8 +122,10 @@ COMPAT_VARYING vec4 TEX0;
109122

110123
#ifdef PARAMETER_UNIFORM
111124
uniform COMPAT_PRECISION float OverlayMix;
125+
uniform COMPAT_PRECISION float ASPECTRATIO;
112126
#else
113127
#define OverlayMix 1.0
128+
#define ASPECTRATIO 43.0
114129
#endif
115130

116131
float blendSoftlight(float base, float blend) {
@@ -130,7 +145,14 @@ void main()
130145
ImageFinal.b = blendSoftlight(frame.b,softlight.b);
131146
ImageFinal.a = blendSoftlight(frame.a,softlight.a);
132147
ImageFinal = mix(frame,clamp(ImageFinal,0.0,OverlayMix),softlight.a);
133-
134-
FragColor = vec4(ImageFinal);
148+
149+
if (ASPECTRATIO == 87.0) {
150+
vec4 background = COMPAT_TEXTURE(BORDER, vTexCoord);
151+
152+
FragColor = vec4(mix(ImageFinal, background, background.a));
153+
}
154+
else{
155+
FragColor = vec4(ImageFinal);
156+
}
135157
}
136158
#endif
7.69 KB
Loading

0 commit comments

Comments
 (0)