Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro Assets
glsl-shaders
Commits
96d9d637
Commit
96d9d637
authored
Feb 27, 2017
by
hunterk
Browse files
add manual GTU-v50 conversion
parent
60479e1a
Changes
4
Hide whitespace changes
Inline
Side-by-side
crt/gtuv50.glslp
0 → 100644
View file @
96d9d637
shaders = 3
shader0 = shaders/gtu-v050/pass1.glsl
scale_type0 = source
scale0 = 1.0
float_framebuffer0 = true
shader1 = shaders/gtu-v050/pass2.glsl
scale_type_x1 = viewport
scale_x1 = 1.0
scale_type_y1 = source
scale_y1 = 1.0
filter_linear1 = false
float_framebuffer1 = true
shader2 = shaders/gtu-v050/pass3.glsl
scale_type2 = viewport
scale_2 = 1.0
filter_linear2 = false
\ No newline at end of file
crt/shaders/gtu-v050/pass1.glsl
0 → 100644
View file @
96d9d637
////////////////////////////////////////////////////////
// GTU version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter compositeConnection1 "Composite Connection Enable 1" 0.0 0.0 1.0 1.0
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform
COMPAT_PRECISION
float
compositeConnection1
;
#else
#define compositeConnection1 0.0
#endif
#define RGB_to_YIQ mat3x3( 0.299 , 0.595716 , 0.211456 , 0.587 , -0.274453 , -0.522591 , 0.114 , -0.321263 , 0.311135 )
#if defined(VERTEX)
#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying
#define COMPAT_ATTRIBUTE attribute
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
COMPAT_ATTRIBUTE
vec4
VertexCoord
;
COMPAT_ATTRIBUTE
vec4
COLOR
;
COMPAT_ATTRIBUTE
vec4
TexCoord
;
COMPAT_VARYING
vec4
COL0
;
COMPAT_VARYING
vec4
TEX0
;
uniform
mat4
MVPMatrix
;
uniform
int
FrameDirection
;
uniform
int
FrameCount
;
uniform
COMPAT_PRECISION
vec2
OutputSize
;
uniform
COMPAT_PRECISION
vec2
TextureSize
;
uniform
COMPAT_PRECISION
vec2
InputSize
;
void
main
()
{
gl_Position
=
MVPMatrix
*
VertexCoord
;
COL0
=
COLOR
;
TEX0
.
xy
=
TexCoord
.
xy
;
}
#elif defined(FRAGMENT)
#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out
vec4
FragColor
;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision
highp
float
;
#else
precision
mediump
float
;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
uniform
int
FrameDirection
;
uniform
int
FrameCount
;
uniform
COMPAT_PRECISION
vec2
OutputSize
;
uniform
COMPAT_PRECISION
vec2
TextureSize
;
uniform
COMPAT_PRECISION
vec2
InputSize
;
uniform
sampler2D
Texture
;
COMPAT_VARYING
vec4
TEX0
;
// compatibility #defines
#define Source Texture
#define vTexCoord TEX0.xy
#define texture(c, d) COMPAT_TEXTURE(c, d)
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
void
main
()
{
vec4
c
=
texture
(
Source
,
vTexCoord
);
if
(
compositeConnection1
>
0
.
0
)
c
.
rgb
=
c
.
rgb
*
RGB_to_YIQ
;
FragColor
=
c
;
}
#endif
crt/shaders/gtu-v050/pass2.glsl
0 → 100644
View file @
96d9d637
////////////////////////////////////////////////////////
// GTU version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter compositeConnection2 "Composite Connection Enable 2" 0.0 0.0 1.0 1.0
#pragma parameter signalResolution "Signal Resolution Y" 256.0 16.0 1024.0 16.0
#pragma parameter signalResolutionI "Signal Resolution I" 83.0 1.0 350.0 2.0
#pragma parameter signalResolutionQ "Signal Resolution Q" 25.0 1.0 350.0 2.0
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform
COMPAT_PRECISION
float
compositeConnection2
;
uniform
COMPAT_PRECISION
float
signalResolution
;
uniform
COMPAT_PRECISION
float
signalResolutionI
;
uniform
COMPAT_PRECISION
float
signalResolutionQ
;
#else
#define compositeConnection2 0.0
#define RETRO_PIXEL_SIZE 256.0
#define RETRO_PIXEL_SIZE 83.0
#define RETRO_PIXEL_SIZE 25.0
#endif
#if defined(VERTEX)
#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying
#define COMPAT_ATTRIBUTE attribute
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
COMPAT_ATTRIBUTE
vec4
VertexCoord
;
COMPAT_ATTRIBUTE
vec4
COLOR
;
COMPAT_ATTRIBUTE
vec4
TexCoord
;
COMPAT_VARYING
vec4
COL0
;
COMPAT_VARYING
vec4
TEX0
;
uniform
mat4
MVPMatrix
;
uniform
int
FrameDirection
;
uniform
int
FrameCount
;
uniform
COMPAT_PRECISION
vec2
OutputSize
;
uniform
COMPAT_PRECISION
vec2
TextureSize
;
uniform
COMPAT_PRECISION
vec2
InputSize
;
void
main
()
{
gl_Position
=
MVPMatrix
*
VertexCoord
;
COL0
=
COLOR
;
TEX0
.
xy
=
TexCoord
.
xy
;
}
#elif defined(FRAGMENT)
#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out
vec4
FragColor
;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision
highp
float
;
#else
precision
mediump
float
;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
uniform
int
FrameDirection
;
uniform
int
FrameCount
;
uniform
COMPAT_PRECISION
vec2
OutputSize
;
uniform
COMPAT_PRECISION
vec2
TextureSize
;
uniform
COMPAT_PRECISION
vec2
InputSize
;
uniform
sampler2D
Texture
;
COMPAT_VARYING
vec4
TEX0
;
// compatibility #defines
#define Source Texture
#define vTexCoord TEX0.xy
#define texture(c, d) COMPAT_TEXTURE(c, d)
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
#define YIQ_to_RGB mat3x3( 1.0 , 1.0 , 1.0 , 0.9563 , -0.2721 , -1.1070 , 0.6210 , -0.6474 , 1.7046 )
#define pi 3.14159265358
#define a(x) abs(x)
#define d(x,b) (pi*b*min(a(x)+0.5,1.0/b))
#define e(x,b) (pi*b*min(max(a(x)-0.5,-1.0/b),1.0/b))
#define STU(x,b) ((d(x,b)+sin(d(x,b))-e(x,b)-sin(e(x,b)))/(2.0*pi))
#define X(i) (offset-(i))
#define GETC (texture(Source, vec2(vTexCoord.x - X * SourceSize.z, vTexCoord.y)).rgb)
#define VAL_composite vec3((c.x*STU(X,(signalResolution / InputSize.x))),(c.y*STU(X,(signalResolutionI / InputSize.x))),(c.z*STU(X,(signalResolutionQ / InputSize.x))))
#define VAL (c*STU(X,(signalResolution / InputSize.x)))
#define PROCESS(i) X=(i);c=GETC;tempColor+=VAL;
#define PROCESS_composite(i) X=(i);c=GETC;tempColor+=VAL_composite;
void
main
()
{
float
offset
=
fract
((
vTexCoord
.
x
*
SourceSize
.
x
)
-
0
.
5
);
vec3
tempColor
=
vec3
(
0
.
0
);
float
X
;
vec3
c
;
float
range
;
if
(
compositeConnection2
>
0
.
0
)
range
=
ceil
(
0
.
5
+
InputSize
.
x
/
min
(
min
(
signalResolution
,
signalResolutionI
),
signalResolutionQ
));
else
range
=
ceil
(
0
.
5
+
InputSize
.
x
/
signalResolution
);
float
i
;
if
(
compositeConnection2
>
0
.
0
){
for
(
i
=-
range
;
i
<
range
+
2
.
0
;
i
++
){
PROCESS_composite
((
offset
-
(
i
)))
}
}
else
{
for
(
i
=-
range
;
i
<
range
+
2
.
0
;
i
++
){
PROCESS
((
offset
-
(
i
)))
}
}
if
(
compositeConnection2
>
0
.
0
)
tempColor
=
clamp
(
tempColor
*
YIQ_to_RGB
,
0
.
0
,
1
.
0
);
else
tempColor
=
clamp
(
tempColor
,
0
.
0
,
1
.
0
);
// tempColor=clamp(tempColor,0.0,1.0);
FragColor
=
vec4
(
tempColor
,
1
.
0
);
}
#endif
crt/shaders/gtu-v050/pass3.glsl
0 → 100644
View file @
96d9d637
////////////////////////////////////////////////////////
// GTU version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter noScanlines "No Scanlines" 0.0 0.0 1.0 1.0
#pragma parameter tvVerticalResolution "TV Vertical Resolution" 250.0 20.0 1000.0 10.0
#pragma parameter blackLevel "Black Level" 0.07 -0.30 0.30 0.01
#pragma parameter contrast "Contrast" 1.0 0.0 2.0 0.1
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform
COMPAT_PRECISION
float
noScanlines
;
uniform
COMPAT_PRECISION
float
tvVerticalResolution
;
uniform
COMPAT_PRECISION
float
blackLevel
;
uniform
COMPAT_PRECISION
float
contrast
;
#else
#define noScanlines 0.0
#define tvVerticalResolution 250.0
#define blackLevel 0.07
#define contrast 1.0
#endif
#define pi 3.14159265358
#define normalGauss(x) ((exp(-(x)*(x)*0.5))/sqrt(2.0*pi))
#if defined(VERTEX)
#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying
#define COMPAT_ATTRIBUTE attribute
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
COMPAT_ATTRIBUTE
vec4
VertexCoord
;
COMPAT_ATTRIBUTE
vec4
COLOR
;
COMPAT_ATTRIBUTE
vec4
TexCoord
;
COMPAT_VARYING
vec4
COL0
;
COMPAT_VARYING
vec4
TEX0
;
// out variables go here as COMPAT_VARYING whatever
vec4
_oPosition1
;
uniform
mat4
MVPMatrix
;
uniform
int
FrameDirection
;
uniform
int
FrameCount
;
uniform
COMPAT_PRECISION
vec2
OutputSize
;
uniform
COMPAT_PRECISION
vec2
TextureSize
;
uniform
COMPAT_PRECISION
vec2
InputSize
;
void
main
()
{
gl_Position
=
MVPMatrix
*
VertexCoord
;
COL0
=
COLOR
;
TEX0
.
xy
=
TexCoord
.
xy
;
// Paste vertex contents here:
}
#elif defined(FRAGMENT)
#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out
vec4
FragColor
;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision
highp
float
;
#else
precision
mediump
float
;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
uniform
int
FrameDirection
;
uniform
int
FrameCount
;
uniform
COMPAT_PRECISION
vec2
OutputSize
;
uniform
COMPAT_PRECISION
vec2
TextureSize
;
uniform
COMPAT_PRECISION
vec2
InputSize
;
uniform
sampler2D
Texture
;
COMPAT_VARYING
vec4
TEX0
;
// in variables go here as COMPAT_VARYING whatever
// compatibility #defines
#define Source Texture
#define vTexCoord TEX0.xy
#define texture(c, d) COMPAT_TEXTURE(c, d)
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
COMPAT_PRECISION
float
normalGaussIntegral
(
float
x
)
{
float
a1
=
0
.
4361836
;
float
a2
=
-
0
.
1201676
;
float
a3
=
0
.
9372980
;
float
p
=
0
.
3326700
;
float
t
=
1
.
0
/
(
1
.
0
+
p
*
abs
(
x
));
return
(
0
.
5
-
normalGauss
(
x
)
*
(
t
*
(
a1
+
t
*
(
a2
+
a3
*
t
))))
*
sign
(
x
);
}
vec3
scanlines
(
float
x
,
vec3
c
){
float
temp
=
sqrt
(
2
*
pi
)
*
(
tvVerticalResolution
/
InputSize
.
y
);
float
rrr
=
0
.
5
*
(
InputSize
.
y
*
OutputSize
.
w
);
float
x1
=
(
x
+
rrr
)
*
temp
;
float
x2
=
(
x
-
rrr
)
*
temp
;
c
.
r
=
(
c
.
r
*
(
normalGaussIntegral
(
x1
)
-
normalGaussIntegral
(
x2
)));
c
.
g
=
(
c
.
g
*
(
normalGaussIntegral
(
x1
)
-
normalGaussIntegral
(
x2
)));
c
.
b
=
(
c
.
b
*
(
normalGaussIntegral
(
x1
)
-
normalGaussIntegral
(
x2
)));
c
*=
(
OutputSize
.
y
/
InputSize
.
y
);
return
c
;
}
#define Y(j) (offset.y-(j))
#define a(x) abs(x)
#define d(x,b) (pi*b*min(a(x)+0.5,1.0/b))
#define e(x,b) (pi*b*min(max(a(x)-0.5,-1.0/b),1.0/b))
#define STU(x,b) ((d(x,b)+sin(d(x,b))-e(x,b)-sin(e(x,b)))/(2.0*pi))
#define SOURCE(j) vec2(vTexCoord.x,vTexCoord.y - Y(j) * SourceSize.w)
#define C(j) (texture(Source, SOURCE(j)).xyz)
#define VAL(j) (C(j)*STU(Y(j),(tvVerticalResolution / InputSize.y)))
#define VAL_scanlines(j) (scanlines(Y(j),C(j)))
void
main
()
{
vec2
offset
=
fract
((
vTexCoord
.
xy
*
SourceSize
.
xy
)
-
0
.
5
);
vec3
tempColor
=
vec3
(
0
.
0
);
float
range
=
ceil
(
0
.
5
+
InputSize
.
y
/
tvVerticalResolution
);
float
i
;
if
(
noScanlines
>
0
.
0
)
for
(
i
=-
range
;
i
<
range
+
2
.
0
;
i
++
){
tempColor
+=
VAL
(
i
);
}
else
for
(
i
=-
range
;
i
<
range
+
2
.
0
;
i
++
){
tempColor
+=
VAL_scanlines
(
i
);
}
tempColor
-=
vec3
(
blackLevel
);
tempColor
*=
(
contrast
/
vec3
(
1
.
0
-
blackLevel
));
FragColor
=
vec4
(
tempColor
,
1
.
0
);
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment