mirror of
https://github.com/libretro/glsl-shaders.git
synced 2024-11-23 15:50:12 +00:00
Port SLANG yo6 shaders to legacy GLSL
This commit is contained in:
parent
72b170001e
commit
01ea4935bc
22
crt/crt-yo6-KV-M1420B-fast.glslp
Normal file
22
crt/crt-yo6-KV-M1420B-fast.glslp
Normal file
@ -0,0 +1,22 @@
|
||||
shaders = 3
|
||||
|
||||
shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.glsl"
|
||||
filter_linear0 = true
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type0 = "absolute"
|
||||
scale_x0 = 439
|
||||
scale_y0 = 233
|
||||
|
||||
shader1 = "shaders/crt-yo6/crt-yo6-warp.glsl"
|
||||
filter_linear1 = true
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type1 = "absolute"
|
||||
scale_x1 = 1684
|
||||
scale_y1 = 1329
|
||||
|
||||
shader2 = "../stock.glsl"
|
||||
filter_linear2 = true
|
||||
|
||||
textures = TEX_CRT
|
||||
TEX_CRT = "shaders/crt-yo6/KV-M1420B.png"
|
||||
TEX_CRT_linear = false
|
27
crt/crt-yo6-KV-M1420B-sharp.glslp
Normal file
27
crt/crt-yo6-KV-M1420B-sharp.glslp
Normal file
@ -0,0 +1,27 @@
|
||||
shaders = 3
|
||||
|
||||
shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.glsl"
|
||||
filter_linear0 = true
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type0 = "absolute"
|
||||
scale_x0 = 439
|
||||
scale_y0 = 233
|
||||
|
||||
shader1 = "shaders/crt-yo6/crt-yo6-warp.glsl"
|
||||
filter_linear1 = true
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type1 = "absolute"
|
||||
scale_x1 = 1684
|
||||
scale_y1 = 1329
|
||||
|
||||
shader2 = "../windowed/shaders/jinc2-params.glsl"
|
||||
filter_linear2 = false
|
||||
|
||||
textures = TEX_CRT
|
||||
TEX_CRT = "shaders/crt-yo6/KV-M1420B.png"
|
||||
TEX_CRT_linear = false
|
||||
|
||||
parameters = "JINC2_WINDOW_SINC;JINC2_SINC;JINC2_AR_STRENGTH"
|
||||
JINC2_WINDOW_SINC = 0.44
|
||||
JINC2_SINC = 0.82
|
||||
JINC2_AR_STRENGTH = 0.5
|
27
crt/crt-yo6-KV-M1420B.glslp
Normal file
27
crt/crt-yo6-KV-M1420B.glslp
Normal file
@ -0,0 +1,27 @@
|
||||
shaders = 3
|
||||
|
||||
shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.glsl"
|
||||
filter_linear0 = true
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type0 = "absolute"
|
||||
scale_x0 = 439
|
||||
scale_y0 = 233
|
||||
|
||||
shader1 = "shaders/crt-yo6/crt-yo6-warp.glsl"
|
||||
filter_linear1 = true
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type1 = "absolute"
|
||||
scale_x1 = 1684
|
||||
scale_y1 = 1329
|
||||
|
||||
shader2 = "../windowed/shaders/jinc2-params.glsl"
|
||||
filter_linear2 = false
|
||||
|
||||
textures = TEX_CRT
|
||||
TEX_CRT = "shaders/crt-yo6/KV-M1420B.png"
|
||||
TEX_CRT_linear = false
|
||||
|
||||
parameters = "JINC2_WINDOW_SINC;JINC2_SINC;JINC2_AR_STRENGTH"
|
||||
JINC2_WINDOW_SINC = 0.44
|
||||
JINC2_SINC = 0.40
|
||||
JINC2_AR_STRENGTH = 0.0
|
BIN
crt/shaders/crt-yo6/KV-M1420B.png
Normal file
BIN
crt/shaders/crt-yo6/KV-M1420B.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 MiB |
79
crt/shaders/crt-yo6/crt-yo6-native-resolution.glsl
Normal file
79
crt/shaders/crt-yo6/crt-yo6-native-resolution.glsl
Normal file
@ -0,0 +1,79 @@
|
||||
#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 float vU;
|
||||
COMPAT_VARYING float vY;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
vU = TexCoord.x;
|
||||
vY = (((TexCoord.y * TextureSize.y) / InputSize.y) * OutputSize.y) -
|
||||
floor(((OutputSize.y - InputSize.y) / 2.0) + 0.5);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#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
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out COMPAT_PRECISION vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
uniform COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING float vU;
|
||||
COMPAT_VARYING float vY;
|
||||
|
||||
void main()
|
||||
{
|
||||
float clip0 = (vY < 0.0) ? 0.0 : 1.0;
|
||||
float clipH = ((InputSize.y - vY) < 0.0) ? 0.0 : 1.0;
|
||||
vec3 col = COMPAT_TEXTURE(Texture, vec2(vU, vY / TextureSize.y)).rgb;
|
||||
FragColor = vec4(clip0 * clipH * col, 1.0);
|
||||
}
|
||||
#endif
|
79
crt/shaders/crt-yo6/crt-yo6-warp.glsl
Normal file
79
crt/shaders/crt-yo6/crt-yo6-warp.glsl
Normal file
@ -0,0 +1,79 @@
|
||||
#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 vec2 vNUV;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
vNUV = (TexCoord.xy * TextureSize) / InputSize;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#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
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out COMPAT_PRECISION vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
uniform COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D TEX_CRT;
|
||||
COMPAT_VARYING vec2 vNUV;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 dat = COMPAT_TEXTURE(TEX_CRT, vNUV).rgb;
|
||||
|
||||
vec2 dudv = ((dat.rg * 255.0) / 16.0) - 7.0;
|
||||
vec2 uv0 = vNUV * InputSize;
|
||||
vec2 uv = (uv0 + dudv) / TextureSize;
|
||||
|
||||
FragColor = vec4(dat.b * COMPAT_TEXTURE(Texture, uv).rgb, 1.0);
|
||||
}
|
||||
#endif
|
4
windowed/jinc2-params.glslp
Normal file
4
windowed/jinc2-params.glslp
Normal file
@ -0,0 +1,4 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = shaders/jinc2-params.glsl
|
||||
filter_linear0 = false
|
213
windowed/shaders/jinc2-params.glsl
Normal file
213
windowed/shaders/jinc2-params.glsl
Normal file
@ -0,0 +1,213 @@
|
||||
/*
|
||||
Hyllian's jinc windowed-jinc 2-lobe sharper with anti-ringing Shader
|
||||
|
||||
Copyright (C) 2011-2016 Hyllian/Jararaca - sergiogdb@gmail.com
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#pragma parameter JINC2_WINDOW_SINC "Window Sinc Param" 0.44 0.0 1.0 0.01
|
||||
#pragma parameter JINC2_SINC "Sinc Param" 0.82 0.0 1.0 0.01
|
||||
#pragma parameter JINC2_AR_STRENGTH "Anti-ringing Strength" 0.5 0.0 1.0 0.1
|
||||
|
||||
#define texCoord TEX0
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define OUT out
|
||||
#define IN in
|
||||
#define tex2D texture
|
||||
#else
|
||||
#define OUT varying
|
||||
#define IN attribute
|
||||
#define tex2D texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
|
||||
IN vec4 VertexCoord;
|
||||
IN vec4 Color;
|
||||
IN vec2 TexCoord;
|
||||
OUT vec4 color;
|
||||
OUT vec2 texCoord;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
color = Color;
|
||||
texCoord = TexCoord * 1.0001;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define IN in
|
||||
#define tex2D texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define IN varying
|
||||
#define FragColor gl_FragColor
|
||||
#define tex2D 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 COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D s_p;
|
||||
IN vec2 texCoord;
|
||||
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
uniform COMPAT_PRECISION float JINC2_WINDOW_SINC;
|
||||
uniform COMPAT_PRECISION float JINC2_SINC;
|
||||
uniform COMPAT_PRECISION float JINC2_AR_STRENGTH;
|
||||
#else
|
||||
#define JINC2_WINDOW_SINC 0.44
|
||||
#define JINC2_SINC 0.82
|
||||
#define JINC2_AR_STRENGTH 0.5
|
||||
#endif
|
||||
|
||||
#define halfpi 1.5707963267948966192313216916398
|
||||
#define pi 3.1415926535897932384626433832795
|
||||
#define wa (JINC2_WINDOW_SINC*pi)
|
||||
#define wb (JINC2_SINC*pi)
|
||||
|
||||
|
||||
// Calculates the distance between two points
|
||||
float d(vec2 pt1, vec2 pt2)
|
||||
{
|
||||
vec2 v = pt2 - pt1;
|
||||
return sqrt(dot(v,v));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
vec4 resampler(vec4 x)
|
||||
{
|
||||
vec4 res;
|
||||
|
||||
res = (x==vec4(0.0, 0.0, 0.0, 0.0)) ? vec4(wa*wb) : sin(x*wa)*sin(x*wb)/(x*x);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec3 color;
|
||||
vec4 weights[4];
|
||||
|
||||
vec2 dx = vec2(1.0, 0.0);
|
||||
vec2 dy = vec2(0.0, 1.0);
|
||||
|
||||
vec2 pc = texCoord*TextureSize;
|
||||
|
||||
vec2 tc = (floor(pc-vec2(0.5,0.5))+vec2(0.5,0.5));
|
||||
|
||||
weights[0] = resampler(vec4(d(pc, tc -dx -dy), d(pc, tc -dy), d(pc, tc +dx -dy), d(pc, tc+2.0*dx -dy)));
|
||||
weights[1] = resampler(vec4(d(pc, tc -dx ), d(pc, tc ), d(pc, tc +dx ), d(pc, tc+2.0*dx )));
|
||||
weights[2] = resampler(vec4(d(pc, tc -dx +dy), d(pc, tc +dy), d(pc, tc +dx +dy), d(pc, tc+2.0*dx +dy)));
|
||||
weights[3] = resampler(vec4(d(pc, tc -dx+2.0*dy), d(pc, tc +2.0*dy), d(pc, tc +dx+2.0*dy), d(pc, tc+2.0*dx+2.0*dy)));
|
||||
|
||||
dx = dx/TextureSize;
|
||||
dy = dy/TextureSize;
|
||||
tc = tc/TextureSize;
|
||||
|
||||
vec3 c00 = tex2D(s_p, tc -dx -dy).xyz;
|
||||
vec3 c10 = tex2D(s_p, tc -dy).xyz;
|
||||
vec3 c20 = tex2D(s_p, tc +dx -dy).xyz;
|
||||
vec3 c30 = tex2D(s_p, tc+2.0*dx -dy).xyz;
|
||||
vec3 c01 = tex2D(s_p, tc -dx ).xyz;
|
||||
vec3 c11 = tex2D(s_p, tc ).xyz;
|
||||
vec3 c21 = tex2D(s_p, tc +dx ).xyz;
|
||||
vec3 c31 = tex2D(s_p, tc+2.0*dx ).xyz;
|
||||
vec3 c02 = tex2D(s_p, tc -dx +dy).xyz;
|
||||
vec3 c12 = tex2D(s_p, tc +dy).xyz;
|
||||
vec3 c22 = tex2D(s_p, tc +dx +dy).xyz;
|
||||
vec3 c32 = tex2D(s_p, tc+2.0*dx +dy).xyz;
|
||||
vec3 c03 = tex2D(s_p, tc -dx+2.0*dy).xyz;
|
||||
vec3 c13 = tex2D(s_p, tc +2.0*dy).xyz;
|
||||
vec3 c23 = tex2D(s_p, tc +dx+2.0*dy).xyz;
|
||||
vec3 c33 = tex2D(s_p, tc+2.0*dx+2.0*dy).xyz;
|
||||
|
||||
color = tex2D(s_p, texCoord).xyz;
|
||||
|
||||
// Get min/max samples
|
||||
vec3 min_sample = min4(c11, c21, c12, c22);
|
||||
vec3 max_sample = max4(c11, c21, c12, c22);
|
||||
/*
|
||||
color = mat4x3(c00, c10, c20, c30) * weights[0];
|
||||
color+= mat4x3(c01, c11, c21, c31) * weights[1];
|
||||
color+= mat4x3(c02, c12, c22, c32) * weights[2];
|
||||
color+= mat4x3(c03, c13, c23, c33) * weights[3];
|
||||
mat4 wgts = mat4(weights[0], weights[1], weights[2], weights[3]);
|
||||
vec4 wsum = wgts * vec4(1.0,1.0,1.0,1.0);
|
||||
color = color/(dot(wsum, vec4(1.0,1.0,1.0,1.0)));
|
||||
*/
|
||||
|
||||
|
||||
color = vec3(dot(weights[0], vec4(c00.x, c10.x, c20.x, c30.x)), dot(weights[0], vec4(c00.y, c10.y, c20.y, c30.y)), dot(weights[0], vec4(c00.z, c10.z, c20.z, c30.z)));
|
||||
color+= vec3(dot(weights[1], vec4(c01.x, c11.x, c21.x, c31.x)), dot(weights[1], vec4(c01.y, c11.y, c21.y, c31.y)), dot(weights[1], vec4(c01.z, c11.z, c21.z, c31.z)));
|
||||
color+= vec3(dot(weights[2], vec4(c02.x, c12.x, c22.x, c32.x)), dot(weights[2], vec4(c02.y, c12.y, c22.y, c32.y)), dot(weights[2], vec4(c02.z, c12.z, c22.z, c32.z)));
|
||||
color+= vec3(dot(weights[3], vec4(c03.x, c13.x, c23.x, c33.x)), dot(weights[3], vec4(c03.y, c13.y, c23.y, c33.y)), dot(weights[3], vec4(c03.z, c13.z, c23.z, c33.z)));
|
||||
color = color/(dot(weights[0], vec4(1,1,1,1)) + dot(weights[1], vec4(1,1,1,1)) + dot(weights[2], vec4(1,1,1,1)) + dot(weights[3], vec4(1,1,1,1)));
|
||||
|
||||
// Anti-ringing
|
||||
vec3 aux = color;
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
color = mix(aux, color, JINC2_AR_STRENGTH);
|
||||
|
||||
// final sum and weight normalization
|
||||
FragColor.xyz = color;
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user