mirror of
https://github.com/libretro/glsl-shaders.git
synced 2025-02-07 07:46:07 +00:00
add ntsc-cgwg-tm (#238)
* add ntsc-cgwg-tm * add ntsc-cgwg-tm * Update ntsc-cgwg-tm.glslp * Update ntsc-cgwg-p1.glsl * Rename ntsc/shaders/ntsc-cgwg-p1.glsl to ntsc/shaders/ntsc-cgwg-tm/ntsc-cgwg-p1.glsl * Rename ntsc/shaders/ntsc-cgwg-p2.glsl to ntsc/shaders/ ntsc-cgwg-tm /ntsc-cgwg-p2.glsl * Rename ntsc-cgwg-p2.glsl to ntsc-cgwg-p2.glsl * Update ntsc-cgwg-tm.glslp * add crt-consumer-ntsc-light
This commit is contained in:
parent
d787db2f59
commit
5cea07744d
8
ntsc/ntsc-cgwg-tm.glslp
Normal file
8
ntsc/ntsc-cgwg-tm.glslp
Normal file
@ -0,0 +1,8 @@
|
||||
shaders = "2"
|
||||
feedback_pass = "0"
|
||||
shader0 = "shaders/ntsc-cgwg-tm/ntsc-cgwg-p1.glsl"
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "shaders/ntsc-cgwg-tm/ntsc-cgwg-p2.glsl"
|
135
ntsc/shaders/ntsc-cgwg-tm/ntsc-cgwg-p1.glsl
Normal file
135
ntsc/shaders/ntsc-cgwg-tm/ntsc-cgwg-p1.glsl
Normal file
@ -0,0 +1,135 @@
|
||||
#version 110
|
||||
|
||||
/*
|
||||
NTSC encoding artifact shader
|
||||
|
||||
This shader renders the input image with added NTSC artifacts, by
|
||||
transforming the input into an NTSC signal, then decoding it again.
|
||||
It was originally developed in this forum thread:
|
||||
|
||||
http://board.byuu.org/viewtopic.php?f=10&t=1494
|
||||
|
||||
Copyright (C) 2010-2012 cgwg and Themaister
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
*/
|
||||
|
||||
|
||||
// begin params
|
||||
#define PI 3.14159265
|
||||
|
||||
#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 COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define outsize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
}
|
||||
|
||||
#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 vec4 TEX0;
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define outsize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
const mat3 rgb2yuv = mat3(0.299,-0.14713, 0.615,
|
||||
0.587,-0.28886,-0.51499,
|
||||
0.114, 0.436 ,-0.10001);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 xy = vTexCoord;
|
||||
float f = float (FrameCount);
|
||||
vec2 xyp = xy * TextureSize.xy * 4.0 * PI / 3.0;
|
||||
xyp.y = xyp.y / 2.0 + 2.0 * PI / 3.0 * mod(f,2.0);
|
||||
|
||||
vec4 rgb = texture2D(Source,xy);
|
||||
|
||||
|
||||
|
||||
vec3 yuv;
|
||||
yuv = rgb2yuv * rgb.rgb;
|
||||
|
||||
float dx = PI/3.0;
|
||||
//commented so it works globally
|
||||
//xyp.x = xyp.x * InputSize.x/256.0;
|
||||
float c0 = yuv.x + yuv.y * sin(xyp.x+xyp.y) + yuv.z*cos(xyp.x+xyp.y);
|
||||
float c1 = yuv.x + yuv.y * sin(xyp.x+xyp.y+dx) + yuv.z * cos(xyp.x+xyp.y+dx);
|
||||
rgb = texture2D(Source,xy + vec2(1.0/TextureSize.x * InputSize.x / 512.0, 0.0));
|
||||
yuv = rgb2yuv * rgb.rgb;
|
||||
float c2 = yuv.x + yuv.y * sin(xyp.x+xyp.y+2.0*dx) + yuv.z * cos(xyp.x+xyp.y+2.0*dx);
|
||||
float c3 = yuv.x + yuv.y * sin(xyp.x+xyp.y+3.0*dx) + yuv.z * cos(xyp.x+xyp.y+3.0*dx);
|
||||
|
||||
FragColor = (vec4(c0,c1,c2,c3)+0.65)/2.3;
|
||||
}
|
||||
#endif
|
176
ntsc/shaders/ntsc-cgwg-tm/ntsc-cgwg-p2.glsl
Normal file
176
ntsc/shaders/ntsc-cgwg-tm/ntsc-cgwg-p2.glsl
Normal file
@ -0,0 +1,176 @@
|
||||
#version 110
|
||||
|
||||
/*
|
||||
NTSC encoding artifact shader
|
||||
|
||||
This shader renders the input image with added NTSC artifacts, by
|
||||
transforming the input into an NTSC signal, then decoding it again.
|
||||
It was originally developed in this forum thread:
|
||||
|
||||
http://board.byuu.org/viewtopic.php?f=10&t=1494
|
||||
|
||||
Copyright (C) 2010-2012 cgwg and Themaister
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
*/
|
||||
|
||||
|
||||
// begin params
|
||||
#define PI 3.14159265
|
||||
|
||||
#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 COMPAT_PRECISION int FrameDirection;
|
||||
uniform COMPAT_PRECISION int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define outsize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
}
|
||||
|
||||
#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 vec4 TEX0;
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define outsize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
uniform COMPAT_PRECISION float xres;
|
||||
|
||||
#else
|
||||
|
||||
#define xres 54.0
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// ------------
|
||||
|
||||
#define iTime float (FrameCount/2)
|
||||
#define TEX2D(c) texture2D(Source,(c))
|
||||
|
||||
|
||||
const mat3 rgb2yuv = mat3(0.299,-0.14713, 0.615,
|
||||
0.587,-0.28886,-0.51499,
|
||||
0.114, 0.436 ,-0.10001);
|
||||
const mat3 yuv2rgb = mat3(1.0, 1.0, 1.0,
|
||||
0.0,-0.39465,2.03211,
|
||||
1.13983,-0.58060,0.0);
|
||||
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 xy = vTexCoord;
|
||||
|
||||
vec2 xyf = fract(xy * SourceSize.xy);
|
||||
vec2 xyp = floor(xy * SourceSize.xy)+vec2(0.5);
|
||||
xy = xyp / SourceSize.xy;
|
||||
float f = float (FrameCount);
|
||||
float offs = mod(f,2.0)/2.0;
|
||||
vec4 phases = (vec4(0.0,0.25,0.5,0.75) + vec4(xyp.x+xyp.y/2.0+offs)) *4.0*PI/3.0;
|
||||
vec4 phasesl = (vec4(0.0,0.25,0.5,0.75) + vec4(-1.0+xyp.x+xyp.y/2.0+offs)) *4.0*PI/3.0;
|
||||
vec4 phasesr = (vec4(0.0,0.25,0.5,0.75) + vec4( 1.0+xyp.x+xyp.y/2.0+offs)) *4.0*PI/3.0;
|
||||
vec4 phsin = sin(phases);
|
||||
vec4 phcos = cos(phases);
|
||||
vec4 phsinl= sin(phasesl);
|
||||
vec4 phcosl= cos(phasesl);
|
||||
vec4 phsinr= sin(phasesr);
|
||||
vec4 phcosr= cos(phasesr);
|
||||
vec4 phone = vec4(1.0);
|
||||
|
||||
vec2 one = 1.0/SourceSize.xy;
|
||||
|
||||
vec4 c = TEX2D(xy)*2.3-0.65;
|
||||
vec4 cl= TEX2D(xy + vec2(-one.x,0.0))*2.3-0.65;
|
||||
vec4 cr= TEX2D(xy + vec2( one.x,0.0))*2.3-0.65;
|
||||
|
||||
vec3 yuva = vec3((dot(cl.zw,phone.zw)+dot(c.xyz,phone.xyz)+0.5*(cl.y+c.w))/6.0, (dot(cl.zw,phsinl.zw)+dot(c.xyz,phsin.xyz)+0.5*(cl.y*phsinl.y+c.w*phsin.w))/3.0, (dot(cl.zw,phcosl.zw)+dot(c.xyz,phcos.xyz)+0.5*(cl.y*phcosl.y+c.w*phcos.w))/3.0);
|
||||
|
||||
vec3 yuvb = vec3((cl.w*phone.w+dot(c.xyzw,phone.xyzw)+0.5*(cl.z+cr.x))/6.0, (cl.w*phsinl.w+dot(c.xyzw,phsin.xyzw)+0.5*(cl.z*phsinl.z+cr.x*phsinr.x))/3.0, (cl.w*phcosl.w+dot(c.xyzw,phcos.xyzw)+0.5*(cl.z*phcosl.z+cr.x*phcosr.x))/3.0);
|
||||
|
||||
vec3 yuvc = vec3((cr.x*phone.x+dot(c.xyzw,phone.xyzw)+0.5*(cl.w+cr.y))/6.0, (cr.x*phsinr.x+dot(c.xyzw,phsin.xyzw)+0.5*(cl.w*phsinl.w+cr.y*phsinr.y))/3.0, (cr.x*phcosr.x+dot(c.xyzw,phcos.xyzw)+0.5*(cl.w*phcosl.w+cr.y*phcosr.y))/3.0);
|
||||
|
||||
vec3 yuvd = vec3((dot(cr.xy,phone.xy)+dot(c.yzw,phone.yzw)+0.5*(c.x+cr.z))/6.0, (dot(cr.xy,phsinr.xy)+dot(c.yzw,phsin.yzw)+0.5*(c.x*phsin.x+cr.z*phsinr.z))/3.0, (dot(cr.xy,phcosr.xy)+dot(c.yzw,phcos.yzw)+0.5*(c.x*phcos.x+cr.z*phcosr.z))/3.0);
|
||||
|
||||
|
||||
if (xyf.x < 0.25)
|
||||
FragColor = vec4(yuv2rgb*yuva, 0.0);
|
||||
else if (xyf.x < 0.5)
|
||||
FragColor = vec4(yuv2rgb*yuvb, 0.0);
|
||||
else if (xyf.x < 0.75)
|
||||
FragColor = vec4(yuv2rgb*yuvc, 0.0);
|
||||
else
|
||||
FragColor = vec4(yuv2rgb*yuvd, 0.0);
|
||||
}
|
||||
#endif
|
18
presets/crt-consumer-ntsc-light.glslp
Normal file
18
presets/crt-consumer-ntsc-light.glslp
Normal file
@ -0,0 +1,18 @@
|
||||
shaders = "4"
|
||||
feedback_pass = "0"
|
||||
shader0 = "../misc/shaders/chromaticity.glsl"
|
||||
filter_linear0 = "false"
|
||||
shader1 = "../ntsc/shaders/ntsc-cgwg-tm/ntsc-cgwg-p1.glsl"
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "../ntsc/shaders/ntsc-cgwg-tm/ntsc-cgwg-p2.glsl"
|
||||
shader3 = "../crt/shaders/zfast_crt_composite.glsl"
|
||||
filter_linear3 = "true"
|
||||
COLOR_MODE = "5.000000"
|
||||
HIGHSCANAMOUNT1 = "0.350000"
|
||||
HIGHSCANAMOUNT2 = "0.150000"
|
||||
TYPE = "1.000000"
|
||||
sat = "1.100000"
|
||||
FLICK = "9.000000"
|
Loading…
x
Reference in New Issue
Block a user