mirror of
https://github.com/libretro/glsl-shaders.git
synced 2025-02-12 02:45:18 +00:00
Update zfast_crt_composite.glsl (#236)
* Update zfast-composite.glslp * Update zfast_crt_composite.glsl Update to be somewhat of a "light" version of crt-consumer.
This commit is contained in:
parent
53b773f4e9
commit
7b68c0d0e9
@ -2,17 +2,16 @@
|
||||
zfast_crt - A very simple CRT shader.
|
||||
|
||||
Copyright (C) 2017 Greg Hogan (SoltanGris42)
|
||||
edited by metallic 77.
|
||||
edited by metallic 77.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
@ -21,16 +20,19 @@
|
||||
#endif
|
||||
|
||||
// Parameter lines go here:
|
||||
#pragma parameter blurx "Convergence X-Axis" 0.45 -2.0 2.0 0.05
|
||||
#pragma parameter blury "Convergence Y-Axis" -0.15 -2.0 2.0 0.05
|
||||
#pragma parameter Curvature "Curvature" 1.0 0.0 1.0 1.0
|
||||
#pragma parameter blurx "Convergence X-Axis" 0.85 -2.0 2.0 0.05
|
||||
#pragma parameter blury "Convergence Y-Axis" -0.10 -2.0 2.0 0.05
|
||||
#pragma parameter HIGHSCANAMOUNT1 "Scanline Amount (Dark)" 0.4 0.0 1.0 0.05
|
||||
#pragma parameter HIGHSCANAMOUNT2 "Scanline Amount (Bright)" 0.3 0.0 1.0 0.05
|
||||
#pragma parameter TYPE "Mask Type" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter MASK_DARK "Mask Effect Amount" 0.3 0.0 1.0 0.05
|
||||
#pragma parameter MASK_FADE "Mask/Scanline Fade" 0.7 0.0 1.0 0.05
|
||||
#pragma parameter sat "Saturation" 1.0 0.0 2.0 0.05
|
||||
#pragma parameter FLICK "Flicker" 10.0 0.0 50.0 1.0
|
||||
#pragma parameter FLICK "Flicker" 6.0 0.0 50.0 1.0
|
||||
|
||||
#define pi 3.14159
|
||||
#define scale vec4(TextureSize/InputSize,InputSize/TextureSize)
|
||||
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
// All parameter floats need to have COMPAT_PRECISION in front of them
|
||||
@ -42,6 +44,8 @@ uniform COMPAT_PRECISION float MASK_DARK;
|
||||
uniform COMPAT_PRECISION float MASK_FADE;
|
||||
uniform COMPAT_PRECISION float sat;
|
||||
uniform COMPAT_PRECISION float FLICK;
|
||||
uniform COMPAT_PRECISION float Curvature;
|
||||
uniform COMPAT_PRECISION float TYPE;
|
||||
|
||||
#else
|
||||
|
||||
@ -53,7 +57,8 @@ uniform COMPAT_PRECISION float FLICK;
|
||||
#define MASK_FADE 0.8
|
||||
#define sat 1.0
|
||||
#define FLICK 0.0
|
||||
|
||||
#define Curvature 1.0
|
||||
#define TYPE 0.0
|
||||
#endif
|
||||
|
||||
#if defined(VERTEX)
|
||||
@ -99,9 +104,9 @@ uniform COMPAT_PRECISION vec2 InputSize;
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
TEX0.xy = TexCoord.xy*1.0001;
|
||||
maskFade = 0.3333*MASK_FADE;
|
||||
omega = 2.0*pi*TextureSize.y;
|
||||
TEX0.xy = TexCoord.xy*1.0001;
|
||||
maskFade = 0.3333*MASK_FADE;
|
||||
omega = 2.0*pi*TextureSize.y;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
@ -152,12 +157,36 @@ COMPAT_VARYING float omega;
|
||||
#define flicker FLICK/1000.0
|
||||
|
||||
|
||||
// Distortion of scanlines, and end of screen alpha.
|
||||
vec2 Warp(vec2 pos)
|
||||
{
|
||||
pos = pos*2.0-1.0;
|
||||
pos *= vec2(1.0 + (pos.y*pos.y)*0.03, 1.0 + (pos.x*pos.x)*0.05);
|
||||
|
||||
return pos*0.5 + 0.5;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pos = TEX0.xy;
|
||||
float cent = floor(TEX0.y*TextureSize.y)+0.5;
|
||||
vec2 pos,corn;
|
||||
if (Curvature == 1.0)
|
||||
{
|
||||
pos = Warp(TEX0.xy*(scale.xy));
|
||||
corn = min(pos,vec2(1.0)-pos); // This is used to mask the rounded
|
||||
corn.x = 0.00001/corn.x; // corners later on
|
||||
pos *= scale.zw;
|
||||
}
|
||||
|
||||
else pos = vTexCoord;
|
||||
|
||||
float OGL2Pos = pos.y*TextureSize.y;
|
||||
float cent = floor(OGL2Pos)+0.5;
|
||||
float ycoord = cent*SourceSize.w;
|
||||
pos = vec2(TEX0.x,ycoord);
|
||||
ycoord = mix(pos.y,ycoord,0.6);
|
||||
pos = vec2(pos.x,ycoord);
|
||||
|
||||
|
||||
|
||||
vec3 sample1 = sin(iTimer)*flicker + COMPAT_TEXTURE(Source,vec2(pos.x + blur_x, pos.y - blur_y)).rgb;
|
||||
vec3 sample2 = 0.5*COMPAT_TEXTURE(Source,pos).rgb;
|
||||
vec3 sample3 = sin(iTimer)*flicker + COMPAT_TEXTURE(Source,vec2(pos.x - blur_x, pos.y + blur_y)).rgb;
|
||||
@ -165,25 +194,34 @@ void main()
|
||||
vec3 colour = vec3 (sample1.r*0.5 + sample2.r,
|
||||
sample1.g*0.25 + sample2.g + sample3.g*0.25,
|
||||
sample2.b + sample3.b*0.5);
|
||||
|
||||
vec3 interl = colour;
|
||||
vec3 lumweight=vec3(0.22,0.71,0.07);
|
||||
float lum = dot(colour,lumweight);
|
||||
float lumsat = dot(colour,lumweight);
|
||||
|
||||
vec3 graycolour = vec3(lum);
|
||||
vec3 graycolour = vec3(lumsat);
|
||||
colour = vec3(mix(graycolour,colour.rgb,sat));
|
||||
|
||||
float SCANAMOUNT = mix(HIGHSCANAMOUNT1,HIGHSCANAMOUNT2,max(max(colour.r,colour.g),colour.b));
|
||||
|
||||
float scanLine = SCANAMOUNT * sin(fract(TEX0.y*TextureSize.y)*3.14159)+1.0-SCANAMOUNT;
|
||||
|
||||
if (InputSize.y > 400.0) scanLine = 1.0;
|
||||
float SCANAMOUNT = mix(HIGHSCANAMOUNT1,HIGHSCANAMOUNT2,max(max(colour.r,colour.g),colour.b));
|
||||
|
||||
|
||||
float whichmask = fract(gl_FragCoord.x*0.4999);
|
||||
float mask = 1.0 + float(whichmask < 0.5) * -MASK_DARK;
|
||||
if (InputSize.y > 400.0) {
|
||||
colour ;
|
||||
}
|
||||
else {
|
||||
colour *= SCANAMOUNT * sin(fract(OGL2Pos)*3.14159)+1.0-SCANAMOUNT;
|
||||
colour *= SCANAMOUNT * sin(fract(1.0-OGL2Pos)*3.14159)+1.0-SCANAMOUNT;
|
||||
colour *= SCANAMOUNT * sin(fract(1.0+OGL2Pos)*3.14159)+1.0-SCANAMOUNT;
|
||||
}
|
||||
|
||||
float steps; if (TYPE == 0.0) steps = 0.5; else steps = 0.3333;
|
||||
float whichmask = fract(gl_FragCoord.x*steps);
|
||||
float mask = 1.0 + float(whichmask < steps) * -MASK_DARK;
|
||||
|
||||
colour.rgb = mix(mask*colour, colour, dot(colour.rgb,vec3(maskFade)));
|
||||
|
||||
if (Curvature == 1.0 && corn.y < corn.x || Curvature == 1.0 && corn.x < 0.00001 )
|
||||
colour = vec3(0.0);
|
||||
|
||||
colour *= colour;
|
||||
colour.rgb *= mix(mask*scanLine, scanLine, dot(colour.rgb,vec3(maskFade)));
|
||||
colour = sqrt(colour);
|
||||
FragColor.rgb = colour.rgb;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,8 +1,3 @@
|
||||
shaders = "1"
|
||||
shader0 = "shaders/zfast_crt_composite.glsl"
|
||||
filter_linear0 = "true"
|
||||
wrap_mode0 = "clamp_to_border"
|
||||
mipmap_input0 = "false"
|
||||
alias0 = ""
|
||||
float_framebuffer0 = "false"
|
||||
srgb_framebuffer0 = "false"
|
||||
|
Loading…
x
Reference in New Issue
Block a user