mirror of
https://github.com/libretro/glsl-shaders.git
synced 2024-11-27 01:40:47 +00:00
add Hyllian's fast-bilateral-3d shader and presets
This commit is contained in:
parent
71ad714f44
commit
dc7fd770fc
42
denoisers/crt-fast-bilateral-super-xbr.glslp
Normal file
42
denoisers/crt-fast-bilateral-super-xbr.glslp
Normal file
@ -0,0 +1,42 @@
|
||||
shaders = "6"
|
||||
shader0 = "shaders/fast-bilateral.glsl"
|
||||
filter_linear0 = "false"
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "../xbr/shaders/super-xbr/super-xbr-pass0.glsl"
|
||||
filter_linear1 = "false"
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "../xbr/shaders/super-xbr/super-xbr-pass1.glsl"
|
||||
filter_linear2 = "false"
|
||||
wrap_mode2 = "clamp_to_edge"
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "2.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "2.000000"
|
||||
shader3 = "../xbr/shaders/super-xbr/super-xbr-pass2.glsl"
|
||||
filter_linear3 = "false"
|
||||
wrap_mode3 = "clamp_to_edge"
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "1.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "1.000000"
|
||||
shader4 = "../windowed/shaders/jinc2-sharper.glsl"
|
||||
filter_linear4 = "false"
|
||||
wrap_mode4 = "clamp_to_edge"
|
||||
float_framebuffer4 = "false"
|
||||
scale_type_x4 = "source"
|
||||
scale_x4 = "1.000000"
|
||||
scale_type_y4 = "source"
|
||||
scale_y4 = "0.500000"
|
||||
shader5 = "../crt/shaders/crt-hyllian.glsl"
|
||||
filter_linear5 = "false"
|
||||
wrap_mode5 = "clamp_to_edge"
|
||||
float_framebuffer5 = "false"
|
||||
|
33
denoisers/fast-bilateral-super-2xbr-3d-3p.glslp
Normal file
33
denoisers/fast-bilateral-super-2xbr-3d-3p.glslp
Normal file
@ -0,0 +1,33 @@
|
||||
shaders = "5"
|
||||
shader0 = "shaders/fast-bilateral-3d.glsl"
|
||||
filter_linear0 = "false"
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "../xbr/shaders/super-xbr/super-2xbr-3d-pass0.glsl"
|
||||
filter_linear1 = "false"
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "../xbr/shaders/super-xbr/super-2xbr-3d-pass1.glsl"
|
||||
filter_linear2 = "false"
|
||||
wrap_mode2 = "clamp_to_edge"
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "1.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "1.000000"
|
||||
shader3 = "../xbr/shaders/super-xbr/super-2xbr-3d-pass2.glsl"
|
||||
filter_linear3 = "false"
|
||||
wrap_mode3 = "clamp_to_edge"
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "1.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "1.000000"
|
||||
shader4 = "../windowed/shaders/jinc2-sharper.glsl"
|
||||
filter_linear4 = "false"
|
||||
wrap_mode4 = "clamp_to_edge"
|
||||
|
43
denoisers/fast-bilateral-super-xbr-4p.glslp
Normal file
43
denoisers/fast-bilateral-super-xbr-4p.glslp
Normal file
@ -0,0 +1,43 @@
|
||||
shaders = "6"
|
||||
shader0 = "shaders/fast-bilateral.glsl"
|
||||
filter_linear0 = "false"
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "../xbr/shaders/super-xbr/super-xbr-pass0.glsl"
|
||||
filter_linear1 = "false"
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "../xbr/shaders/super-xbr/super-xbr-pass1.glsl"
|
||||
filter_linear2 = "false"
|
||||
wrap_mode2 = "clamp_to_edge"
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "2.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "2.000000"
|
||||
shader3 = "../xbr/shaders/super-xbr/super-xbr-pass0.glsl"
|
||||
filter_linear3 = "false"
|
||||
wrap_mode3 = "clamp_to_edge"
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "1.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "1.000000"
|
||||
|
||||
shader4 = "../xbr/shaders/super-xbr/super-xbr-pass1.glsl"
|
||||
filter_linear4 = "false"
|
||||
wrap_mode4 = "clamp_to_edge"
|
||||
scale_type_x4 = "source"
|
||||
scale_x4 = "2.000000"
|
||||
scale_type_y4 = "source"
|
||||
scale_y4 = "2.000000"
|
||||
|
||||
|
||||
shader5 = "../windowed/shaders/jinc2-sharper.glsl"
|
||||
filter_linear5 = "false"
|
||||
wrap_mode5 = "clamp_to_edge"
|
||||
|
57
denoisers/fast-bilateral-super-xbr-6p.glslp
Normal file
57
denoisers/fast-bilateral-super-xbr-6p.glslp
Normal file
@ -0,0 +1,57 @@
|
||||
shaders = "8"
|
||||
shader0 = "shaders/fast-bilateral.glsl"
|
||||
filter_linear0 = "false"
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "../xbr/shaders/super-xbr/super-xbr-pass0.glsl"
|
||||
filter_linear1 = "false"
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "../xbr/shaders/super-xbr/super-xbr-pass1.glsl"
|
||||
filter_linear2 = "false"
|
||||
wrap_mode2 = "clamp_to_edge"
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "2.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "2.000000"
|
||||
shader3 = "../xbr/shaders/super-xbr/super-xbr-pass2.glsl"
|
||||
filter_linear3 = "false"
|
||||
wrap_mode3 = "clamp_to_edge"
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "1.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "1.000000"
|
||||
|
||||
shader4 = "../xbr/shaders/super-xbr/super-xbr-pass0.glsl"
|
||||
filter_linear4 = "false"
|
||||
wrap_mode4 = "clamp_to_edge"
|
||||
scale_type_x4 = "source"
|
||||
scale_x4 = "1.000000"
|
||||
scale_type_y4 = "source"
|
||||
scale_y4 = "1.000000"
|
||||
shader5 = "../xbr/shaders/super-xbr/super-xbr-pass1.glsl"
|
||||
filter_linear5 = "false"
|
||||
wrap_mode5 = "clamp_to_edge"
|
||||
scale_type_x5 = "source"
|
||||
scale_x5 = "2.000000"
|
||||
scale_type_y5 = "source"
|
||||
scale_y5 = "2.000000"
|
||||
shader6 = "../xbr/shaders/super-xbr/super-xbr-pass2.glsl"
|
||||
filter_linear6 = "false"
|
||||
wrap_mode6 = "clamp_to_edge"
|
||||
scale_type_x6 = "source"
|
||||
scale_x6 = "1.000000"
|
||||
scale_type_y6 = "source"
|
||||
scale_y6 = "1.000000"
|
||||
|
||||
|
||||
shader7 = "../windowed/shaders/jinc2-sharper.glsl"
|
||||
filter_linear7 = "false"
|
||||
wrap_mode7 = "clamp_to_edge"
|
||||
|
40
denoisers/fast-bilateral-super-xbr-natural-vision.glslp
Normal file
40
denoisers/fast-bilateral-super-xbr-natural-vision.glslp
Normal file
@ -0,0 +1,40 @@
|
||||
shaders = "6"
|
||||
shader0 = "shaders/fast-bilateral.glsl"
|
||||
filter_linear0 = "false"
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "../misc/natural-vision.glsl"
|
||||
filter_linear1 = "false"
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "../xbr/shaders/super-xbr/super-xbr-pass0.glsl"
|
||||
filter_linear2 = "false"
|
||||
wrap_mode2 = "clamp_to_edge"
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "1.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "1.000000"
|
||||
shader3 = "../xbr/shaders/super-xbr/super-xbr-pass1.glsl"
|
||||
filter_linear3 = "false"
|
||||
wrap_mode3 = "clamp_to_edge"
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "2.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "2.000000"
|
||||
shader4 = "../xbr/shaders/super-xbr/super-xbr-pass2.glsl"
|
||||
filter_linear4 = "false"
|
||||
wrap_mode4 = "clamp_to_edge"
|
||||
scale_type_x4 = "source"
|
||||
scale_x4 = "1.000000"
|
||||
scale_type_y4 = "source"
|
||||
scale_y4 = "1.000000"
|
||||
shader5 = "../windowed/shaders/jinc2-sharper.glsl"
|
||||
filter_linear5 = "false"
|
||||
wrap_mode5 = "clamp_to_edge"
|
||||
|
33
denoisers/fast-bilateral-super-xbr.glslp
Normal file
33
denoisers/fast-bilateral-super-xbr.glslp
Normal file
@ -0,0 +1,33 @@
|
||||
shaders = "5"
|
||||
shader0 = "shaders/fast-bilateral.glsl"
|
||||
filter_linear0 = "false"
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "../xbr/shaders/super-xbr/super-xbr-pass0.glsl"
|
||||
filter_linear1 = "false"
|
||||
wrap_mode1 = "clamp_to_edge"
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "../xbr/shaders/super-xbr/super-xbr-pass1.glsl"
|
||||
filter_linear2 = "false"
|
||||
wrap_mode2 = "clamp_to_edge"
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "2.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "2.000000"
|
||||
shader3 = "../xbr/shaders/super-xbr/super-xbr-pass2.glsl"
|
||||
filter_linear3 = "false"
|
||||
wrap_mode3 = "clamp_to_edge"
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "1.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "1.000000"
|
||||
shader4 = "../windowed/shaders/jinc2-sharper.glsl"
|
||||
filter_linear4 = "false"
|
||||
wrap_mode4 = "clamp_to_edge"
|
||||
|
183
denoisers/shaders/fast-bilateral-3d.glsl
Normal file
183
denoisers/shaders/fast-bilateral-3d.glsl
Normal file
@ -0,0 +1,183 @@
|
||||
#version 120
|
||||
|
||||
/*
|
||||
Hyllian's Fast Bilateral 3D Shader
|
||||
|
||||
Copyright (C) 2011/2016 Hyllian - 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.
|
||||
|
||||
*/
|
||||
|
||||
// Parameter lines go here:
|
||||
#pragma parameter FB_RES "Bilateral Internal Res" 2.0 1.0 8.0 1.0
|
||||
#pragma parameter SIGMA_R "Bilateral Blur" 0.4 0.0 2.0 0.1
|
||||
#pragma parameter SIGMA_D "Bilateral Space" 3.0 0.0 10.0 0.2
|
||||
// END PARAMETERS //
|
||||
|
||||
#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 outsize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
uniform float FB_RES;
|
||||
uniform float SIGMA_R;
|
||||
uniform float SIGMA_D;
|
||||
#else
|
||||
#define FB_RES 2.0
|
||||
#define SIGMA_R 0.4
|
||||
#define SIGMA_D 3.0
|
||||
#endif
|
||||
|
||||
#define GET(M,K) (texture(Source,tc+M*dx+K*dy).xyz)
|
||||
|
||||
#define BIL(M,K) {\
|
||||
col=GET(M,K);\
|
||||
ds=M*M+K*K;\
|
||||
weight=exp(-ds/sd2)*exp(-(col-center)*(col-center)/si2);\
|
||||
color+=(weight*col);\
|
||||
wsum+=weight;\
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float ds, sd2, si2;
|
||||
float sigma_d = SIGMA_D;
|
||||
float sigma_r = SIGMA_R*0.04;
|
||||
|
||||
vec3 color = vec3(0.0, 0.0, 0.0);
|
||||
vec3 wsum = vec3(0.0, 0.0, 0.0);
|
||||
vec3 weight;
|
||||
|
||||
vec2 dx = vec2(FB_RES, 0.0) * SourceSize.zw;
|
||||
vec2 dy = vec2(0.0, FB_RES) * SourceSize.zw;
|
||||
|
||||
sd2 = 2.0 * sigma_d * sigma_d;
|
||||
si2 = 2.0 * sigma_r * sigma_r;
|
||||
|
||||
vec2 tc = vTexCoord;
|
||||
|
||||
vec3 col;
|
||||
vec3 center = GET(0,0);
|
||||
// center = sqrt(center);
|
||||
|
||||
BIL(-2,-2)
|
||||
BIL(-1,-2)
|
||||
BIL( 0,-2)
|
||||
BIL( 1,-2)
|
||||
BIL( 2,-2)
|
||||
BIL(-2,-1)
|
||||
BIL(-1,-1)
|
||||
BIL( 0,-1)
|
||||
BIL( 1,-1)
|
||||
BIL( 2,-1)
|
||||
BIL(-2, 0)
|
||||
BIL(-1, 0)
|
||||
BIL( 0, 0)
|
||||
BIL( 1, 0)
|
||||
BIL( 2, 0)
|
||||
BIL(-2, 1)
|
||||
BIL(-1, 1)
|
||||
BIL( 0, 1)
|
||||
BIL( 1, 1)
|
||||
BIL( 2, 1)
|
||||
BIL(-2, 2)
|
||||
BIL(-1, 2)
|
||||
BIL( 0, 2)
|
||||
BIL( 1, 2)
|
||||
BIL( 2, 2)
|
||||
|
||||
// Weight normalization
|
||||
color /= wsum;
|
||||
|
||||
FragColor = vec4(color, 1.);
|
||||
}
|
||||
#endif
|
136
misc/natural-vision.glsl
Normal file
136
misc/natural-vision.glsl
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
ShadX's Natural Vision Shader
|
||||
|
||||
Ported and tweaked by Hyllian - 2016
|
||||
parameterized by Sp00kyFox
|
||||
|
||||
*/
|
||||
|
||||
#pragma parameter GIN "NaturalVision Gamma In" 2.2 0.0 10.0 0.05
|
||||
#pragma parameter GOUT "NaturalVision Gamma Out" 2.2 0.0 10.0 0.05
|
||||
#pragma parameter Y "NaturalVision Luminance" 1.1 0.0 10.0 0.01
|
||||
#pragma parameter I "NaturalVision Orange-Cyan" 1.1 0.0 10.0 0.01
|
||||
#pragma parameter Q "NaturalVision Magenta-Green" 1.1 0.0 10.0 0.01
|
||||
|
||||
#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;
|
||||
|
||||
vec4 _oPosition1;
|
||||
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;
|
||||
|
||||
// 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;
|
||||
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 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;
|
||||
|
||||
// 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 OutSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
uniform COMPAT_PRECISION float GIN;
|
||||
uniform COMPAT_PRECISION float GOUT;
|
||||
uniform COMPAT_PRECISION float Y;
|
||||
uniform COMPAT_PRECISION float I;
|
||||
uniform COMPAT_PRECISION float Q;
|
||||
#else
|
||||
#define GIN 2.2
|
||||
#define GOUT 2.2
|
||||
#define Y 1.1
|
||||
#define I 1.1
|
||||
#define Q 1.1
|
||||
#endif
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
const mat3x3 RGBtoYIQ = mat3x3(0.299, 0.587, 0.114,
|
||||
0.595716, -0.274453, -0.321263,
|
||||
0.211456, -0.522591, 0.311135);
|
||||
|
||||
const mat3x3 YIQtoRGB = mat3x3(1, 0.95629572, 0.62102442,
|
||||
1, -0.27212210, -0.64738060,
|
||||
1, -1.10698902, 1.70461500);
|
||||
|
||||
const vec3 YIQ_lo = vec3(0, -0.595716, -0.522591);
|
||||
const vec3 YIQ_hi = vec3(1, 0.595716, 0.522591);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c = texture(Source, vTexCoord).xyz;
|
||||
|
||||
c = pow(c, vec3(GIN, GIN, GIN));
|
||||
c = mul(RGBtoYIQ, c);
|
||||
c = vec3(pow(c.x,Y), c.y*I, c.z*Q);
|
||||
c = clamp(c, YIQ_lo, YIQ_hi);
|
||||
c = mul(YIQtoRGB, c);
|
||||
c = pow(c, vec3(1.0/GOUT, 1.0/GOUT, 1.0/GOUT));
|
||||
|
||||
FragColor = vec4(c, 1.0);
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user