Skip to content

Commit 3f4298b

Browse files
committed
Adds retro-v2-softlight shader
1 parent 46a00f1 commit 3f4298b

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

reshade/retro-v2-softlight.glslp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
shaders = 2
2+
shader0 = ../handheld/shaders/retro-v2.glsl
3+
shader1 = shaders/blendsoftlight/blendsoftlight.glsl
4+
5+
6+
7+
textures = "overlay"
8+
# change this path to point to your overlay image
9+
overlay = shaders/blendsoftlight/shine.png
10+
OverlayMix = 1.0
11+
12+
scale_type0 = source
13+
scale0 = 4
14+
15+
filter_linear0 = false
16+
filter_linear1 = true
17+
18+
parameters = "RETRO_PIXEL_SIZE"
19+
# set these to the width/height of your overlay image
20+
SCALE = "1.0"
21+
RETRO_PIXEL_SIZE = "0.70"
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// version directive if necessary
2+
3+
// blendSoftlight
4+
// based on:
5+
// https://github.com/jamieowen/glsl-blend for blendSoftlight
6+
7+
#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
11+
12+
#if defined(VERTEX)
13+
14+
#if __VERSION__ >= 130
15+
#define COMPAT_VARYING out
16+
#define COMPAT_ATTRIBUTE in
17+
#define COMPAT_TEXTURE texture
18+
#else
19+
#define COMPAT_VARYING varying
20+
#define COMPAT_ATTRIBUTE attribute
21+
#define COMPAT_TEXTURE texture2D
22+
#endif
23+
24+
#ifdef GL_ES
25+
#define COMPAT_PRECISION mediump
26+
#else
27+
#define COMPAT_PRECISION
28+
#endif
29+
30+
COMPAT_ATTRIBUTE vec4 VertexCoord;
31+
COMPAT_ATTRIBUTE vec4 COLOR;
32+
COMPAT_ATTRIBUTE vec4 TexCoord;
33+
COMPAT_VARYING vec4 COL0;
34+
COMPAT_VARYING vec4 TEX0;
35+
36+
vec4 _oPosition1;
37+
uniform mat4 MVPMatrix;
38+
uniform COMPAT_PRECISION int FrameDirection;
39+
uniform COMPAT_PRECISION int FrameCount;
40+
uniform COMPAT_PRECISION vec2 OutputSize;
41+
uniform COMPAT_PRECISION vec2 TextureSize;
42+
uniform COMPAT_PRECISION vec2 InputSize;
43+
44+
// compatibility #defines
45+
#define vTexCoord TEX0.xy
46+
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
47+
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
48+
49+
#ifdef PARAMETER_UNIFORM
50+
// All parameter floats need to have COMPAT_PRECISION in front of them
51+
uniform COMPAT_PRECISION float SCALE;
52+
uniform COMPAT_PRECISION float OUT_X;
53+
uniform COMPAT_PRECISION float OUT_Y;
54+
#else
55+
#define SCALE 0.66667
56+
#define OUT_X 1600.0
57+
#define OUT_Y 800.0
58+
#endif
59+
60+
void main()
61+
{
62+
gl_Position = MVPMatrix * VertexCoord;
63+
vec2 scale = (OutputSize.xy / InputSize.xy) / SCALE;
64+
vec2 middle = vec2(0.5, 0.5) * InputSize.xy / TextureSize.xy;
65+
vec2 diff = TexCoord.xy - middle;
66+
TEX0.xy = middle + diff * scale;
67+
}
68+
69+
#elif defined(FRAGMENT)
70+
71+
#ifdef GL_ES
72+
#ifdef GL_FRAGMENT_PRECISION_HIGH
73+
precision highp float;
74+
#else
75+
precision mediump float;
76+
#endif
77+
#define COMPAT_PRECISION mediump
78+
#else
79+
#define COMPAT_PRECISION
80+
#endif
81+
82+
#if __VERSION__ >= 130
83+
#define COMPAT_VARYING in
84+
#define COMPAT_TEXTURE texture
85+
out COMPAT_PRECISION vec4 FragColor;
86+
#else
87+
#define COMPAT_VARYING varying
88+
#define FragColor gl_FragColor
89+
#define COMPAT_TEXTURE texture2D
90+
#endif
91+
92+
uniform COMPAT_PRECISION int FrameDirection;
93+
uniform COMPAT_PRECISION int FrameCount;
94+
uniform COMPAT_PRECISION vec2 OutputSize;
95+
uniform COMPAT_PRECISION vec2 TextureSize;
96+
uniform COMPAT_PRECISION vec2 InputSize;
97+
uniform sampler2D Texture;
98+
uniform sampler2D overlay;
99+
COMPAT_VARYING vec4 TEX0;
100+
101+
// compatibility #defines
102+
#define Source Texture
103+
#define vTexCoord TEX0.xy
104+
105+
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
106+
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
107+
108+
#ifdef PARAMETER_UNIFORM
109+
uniform COMPAT_PRECISION float OverlayMix;
110+
#else
111+
#define OverlayMix 1.0
112+
#endif
113+
114+
float blendSoftlight(float base, float blend) {
115+
return (blend<0.5)?(2.0*base*blend+base*base*(1.0-2.0*blend)):(sqrt(base)*(2.0*blend-1.0)+2.0*base*(1.0-blend));
116+
}
117+
118+
void main()
119+
{
120+
121+
vec4 frame = COMPAT_TEXTURE(Source, vTexCoord).rgba;
122+
vec4 softlight = COMPAT_TEXTURE(overlay, vTexCoord).rgba;
123+
124+
vec4 ImageFinal = frame;
125+
126+
ImageFinal.r = blendSoftlight(frame.r,softlight.r);
127+
ImageFinal.g = blendSoftlight(frame.g,softlight.g);
128+
ImageFinal.b = blendSoftlight(frame.b,softlight.b);
129+
ImageFinal.a = blendSoftlight(frame.a,softlight.a);
130+
ImageFinal = mix(frame,clamp(ImageFinal,0.0,OverlayMix),softlight.a);
131+
132+
FragColor = vec4(ImageFinal);
133+
}
134+
#endif
3.92 MB
Loading

0 commit comments

Comments
 (0)