From b0bf39fe7def101155f684fb1bcb5b220e4ae8c3 Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Sat, 13 Mar 2021 02:29:00 +0100 Subject: [PATCH] Remove old custom shaders, add new chain ones. --- assets/shaders/Luna.fsh | 1452 ----------------- assets/shaders/Luna2.fsh | 1452 ----------------- assets/shaders/Luna2M.fsh | 1376 ---------------- assets/shaders/{LunaM.vsh => LunaAll.vsh} | 0 assets/shaders/LunaBilateral.fsh | 109 ++ assets/shaders/LunaBloom.fsh | 114 ++ assets/shaders/LunaCartoon.fsh | 134 ++ assets/shaders/LunaChainShaders.ini | 646 ++++++++ assets/shaders/{Luna.vsh => LunaColor.vsh} | 2 - assets/shaders/LunaColorReduction.fsh | 29 + assets/shaders/LunaColored.fsh | 87 + assets/shaders/LunaComplexSharpen.fsh | 137 ++ assets/shaders/LunaCustomAspectRatio.fsh | 47 + assets/shaders/LunaDeband.fsh | 81 + assets/shaders/LunaFXAA.fsh | 125 ++ assets/shaders/LunaFrost.fsh | 96 ++ assets/shaders/LunaGAUSS_S.fsh | 106 ++ assets/shaders/LunaGAUSS_SQ.fsh | 117 ++ assets/shaders/LunaGamma.fsh | 74 + assets/shaders/LunaGuest_AA4o.fsh | 227 +++ assets/shaders/LunaLCD3x.fsh | 84 + assets/shaders/LunaM.fsh | 1376 ---------------- assets/shaders/LunaNaturalColors.fsh | 114 ++ assets/shaders/LunaPixelate.fsh | 31 + assets/shaders/LunaScan.vsh | 12 + assets/shaders/LunaShadeboostA.fsh | 108 ++ assets/shaders/LunaShadeboostB.fsh | 108 ++ assets/shaders/LunaShadeboostC.fsh | 102 ++ assets/shaders/LunaShadeboostD.fsh | 126 ++ assets/shaders/LunaShadeboostE.fsh | 137 ++ assets/shaders/LunaSimpleScanlines.fsh | 105 ++ assets/shaders/LunaSimpleSharpen.fsh | 71 + assets/shaders/LunaTest.fsh | 77 + assets/shaders/LunaV.fsh | 1707 -------------------- assets/shaders/LunaVignette.fsh | 84 + assets/shaders/LunaXBR.fsh | 433 +++++ assets/shaders/LunaXHQ.fsh | 131 ++ assets/shaders/LunaxBRZf-DU.fsh | 340 ++++ assets/shaders/scaling shaders.ini | 36 - 39 files changed, 4192 insertions(+), 7401 deletions(-) delete mode 100644 assets/shaders/Luna.fsh delete mode 100644 assets/shaders/Luna2.fsh delete mode 100644 assets/shaders/Luna2M.fsh rename assets/shaders/{LunaM.vsh => LunaAll.vsh} (100%) create mode 100644 assets/shaders/LunaBilateral.fsh create mode 100644 assets/shaders/LunaBloom.fsh create mode 100644 assets/shaders/LunaCartoon.fsh create mode 100644 assets/shaders/LunaChainShaders.ini rename assets/shaders/{Luna.vsh => LunaColor.vsh} (89%) create mode 100644 assets/shaders/LunaColorReduction.fsh create mode 100644 assets/shaders/LunaColored.fsh create mode 100644 assets/shaders/LunaComplexSharpen.fsh create mode 100644 assets/shaders/LunaCustomAspectRatio.fsh create mode 100644 assets/shaders/LunaDeband.fsh create mode 100644 assets/shaders/LunaFXAA.fsh create mode 100644 assets/shaders/LunaFrost.fsh create mode 100644 assets/shaders/LunaGAUSS_S.fsh create mode 100644 assets/shaders/LunaGAUSS_SQ.fsh create mode 100644 assets/shaders/LunaGamma.fsh create mode 100644 assets/shaders/LunaGuest_AA4o.fsh create mode 100644 assets/shaders/LunaLCD3x.fsh delete mode 100644 assets/shaders/LunaM.fsh create mode 100644 assets/shaders/LunaNaturalColors.fsh create mode 100644 assets/shaders/LunaPixelate.fsh create mode 100644 assets/shaders/LunaScan.vsh create mode 100644 assets/shaders/LunaShadeboostA.fsh create mode 100644 assets/shaders/LunaShadeboostB.fsh create mode 100644 assets/shaders/LunaShadeboostC.fsh create mode 100644 assets/shaders/LunaShadeboostD.fsh create mode 100644 assets/shaders/LunaShadeboostE.fsh create mode 100644 assets/shaders/LunaSimpleScanlines.fsh create mode 100644 assets/shaders/LunaSimpleSharpen.fsh create mode 100644 assets/shaders/LunaTest.fsh delete mode 100644 assets/shaders/LunaV.fsh create mode 100644 assets/shaders/LunaVignette.fsh create mode 100644 assets/shaders/LunaXBR.fsh create mode 100644 assets/shaders/LunaXHQ.fsh create mode 100644 assets/shaders/LunaxBRZf-DU.fsh delete mode 100644 assets/shaders/scaling shaders.ini diff --git a/assets/shaders/Luna.fsh b/assets/shaders/Luna.fsh deleted file mode 100644 index 4a293ba030..0000000000 --- a/assets/shaders/Luna.fsh +++ /dev/null @@ -1,1452 +0,0 @@ -//Note : Recommend to use PPSSPP v1.1.1-183-gb411fc0 or newer for full functionality, there were some bugs in earlier versions. -//Note2 : Upscaling, smoothing and sharpening filters are not set to be mixed between each other since the results are pointless(they counter each other). -// Only last one applies, so pick just one of them, mess around with it's settings and add other effects as needed. -//====================================================================================================================================================================== -//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res -//================ -#define FXAA 0 //ON:1/OFF:0 /default FXAA, orginal info below -//================ -#define GAUSS_SQ 0 //ON:1/OFF:0 /full square gauss filtering -#define Gsmoothing 3.5 //Default: 3.5 /increase for smoother(blurry) graphics -//================ -#define GAUSS_S 0 //ON:1/OFF:0 /simple gauss filtering by Bigpet, slightly different from above /you can find standalone in https://github.com/hrydgard/ppsspp/issues/7242 -//================ -#define Guest_AA4o 1 //ON:1/OFF:0 /alternative to FXAA /taken from http://forums.ppsspp.org/showthread.php?tid=6594&pid=124441#pid124441 -#define scale 7.0 //Default: 7.0 / 4.0 -> smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) -#define filtro 0 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier -//================ -//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing -//================ -#define SHARPEN 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default -#define value 7.5 //Default: 7.5 /higher = more visible effect -//================ -#define S_COM_V2 0 //Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate -#define S_val0 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect -//================ -//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" - //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically -//================ -#define xBR 0 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below -#define VariantB 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details -#define Variantx2 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR -//================ -#define xBRAccuracy 0 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below -#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding -#define CornerB 0 //ON:1/OFF:0 / activate only one -#define CornerD 0 //ON:1/OFF:0 -// CornerC //used as default if no other ones are defined -//================ -#define xHQ 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution -#define scaleoffset 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness -//================ -//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one -//================ -#define Deband 1 //ON:1/OFF:0 /Blurs -#define DeTol 16.0 //Default: 16.0 /tolerance, too high will look glitchy -//================ -#define Frost 0 //ON:1/OFF:0 /Dithering ~ adds noise -#define fTol 32.0 //Default: 32.0 /tolerance, too high will look glitchy -#define fSimple 0 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version -//================ -#define Bilateral 0 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH -//================ -//OTHER FILTERS: //Most effects from here on can be fully mixed without loosing previous effects. Exceptions: Natural Colors, Advanced Cartoon -//================ -#define BLOOM 1 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ -#define MIKU 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress -#define samples 3 //Default: 4 /higher = more glow, worse performance -#define quality 0.14 //Default: 0.18 /lower = smaller glow, better quality -#define Bpower 1.0 //Default: 1.0 /amount of bloom mixed -//================ -#define COLORED 0 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o -#define Cpower 0.5 //Default: 0.5 /strenght of the effect -//================ -#define NATURALC 0 //ON:1/OFF:0 /by popular demand, natular colors, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -#define ncpower 0.5 //Default:0.5 / higher = more natural color, check note line above -//================ -#define ACARTOON 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack -#define th 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 -#define bb 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 -#define pp 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 -#define acpower 0.5 //Default:0.5 / higher = more effect, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -//================ -#define SHADEBOOST 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 -#define saturation 1.0 //Default: 1.0 //negative will look like inverted colors shader -#define brightness 1.0 //Default: 1.0 -#define contrast 1.0 //Default: 1.0 //negative will be... well negative;p -#define red 1.0 //Default: 1.0 -#define green 1.0 //Default: 1.0 -#define blue 1.0 //Default: 1.0 -//Shadeboost presets: //Shadeboost must be activated, presets override options above -#define SEPIA 0 //Moody coolors:) -#define GRAYSCALE 0 //Just for lols? -#define NEGATIVE 0 //As above -#define PSPCOLORS 0 //Makes the colors as on older PSP screens(colder) -//Simple color swap: //Shadeboost must be activated -#define rgbRBG 0 //green <-> blue -#define rgbBGR 0 //red <-> blue -#define rgbBRG 0 //red -> green -> blue -> red -#define rgbGRB 0 //red <-> green -#define rgbGBR 0 //red -> blue -> green -> red -//^All presets and color swap are simple switch ON:1/OFF:0, -//================ -#define GAMMA 1 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 -#define correction 0.75 //Default: 1.0 -//================ -#define SCANLINES 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) -#define SLsize 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high -#define SLcolor 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation -#define SLpower 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, -#define SLV 0 //ON:1/OFF:0 /vertical scanlines -#define noGradient 0 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line -//================ -#define LCD3x 0 //ON:1/OFF:0 //different scanline shader -#define b_sl 16.0 //Default: 16.0 /horizontal lines brightness -#define b_lcd 4.0 //Default: 4.0 /vertical lines brightness -#define sl_size 2.0 //Default: 2.0 /scanline size -//================ -#define VIGNETTE 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings -#define vsize 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values -#define VIpos 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) -#define deVi 0 //ON:1/OFF:0 /reverse vignette -//================ -#define TEST 0 //ON:1/OFF:0 /test mode, applies shaders on half of the screen for easy result comparison and tweaking -#define TESTANIM 0 //ON:1/OFF:0 /as above, animation slides shader from left to right and back /use only one -#define testAspeed 1.0 //animation speed -//================ -//Approximate performance hit -//Free: TEST, TESTANIM -//Light: SHARPEN, COLORED, SHADEBOOST, GAMMA, SCANLINES, LCD3x, VIGNETTE, BLOOM(<= 2 samples) -//Medium: FXAA, GAUSS_SQ, GAUSS_S, S_COM_V2, xHQ, Deband, Frost(fSimple), NATURALC, ACARTOON, BLOOM(== 3 samples) -//Heavy: Guest_AA4o, xBR, Frost, BLOOM(>= 4 samples), xBRAccuracy -//Extremely Heavy: Guest_AA4o(filtro), BLOOM(>= 8 samples), Bilateral -//====================================================================================================================================================================== -//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), -// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken -// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), -// other credits mentioned earlier, any more info / required licenses can be found below. - - - - -/* - FXAA shader, GLSL code adapted from: - http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA - Whitepaper describing the technique: - http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf -*/ - -/* - AA shader 4.o / AA shader 4.o - filtro - - Copyright (C) 2014 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - Hyllian's 5xBR v3.5a Shader - - Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from: - http://forums.ngemu.com/showthread.php?t=76098 - - by guest(r) (guest.r@gmail.com) - License: GNU-GPL - - Shader notes: looks better with sprite games -*/ - -/* - Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) - - Copyright (C) 2011-2015 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. - - Incorporates some of the ideas from SABR shader. Thanks to Joshua Street. -*/ - -/* - Advanced Cartoon shader - - Copyright (C) 2006 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#ifdef GL_ES -precision mediump float; -precision mediump int; -#endif - -uniform sampler2D sampler0; -uniform vec4 u_time; - - -//=========== -// The inverse of the texture dimensions along X and Y -uniform vec2 u_texelDelta; -uniform vec2 u_pixelDelta; -varying vec2 v_texcoord0; - -varying vec4 v_texcoord1; -varying vec4 v_texcoord2; -varying vec4 v_texcoord3; -varying vec4 v_texcoord4; -varying vec2 v_texcoord5; - - -//=========== -//=========== -#if(FXAA==1) -vec3 processFXAA(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float FXAA_SPAN_MAX = 8.0; - float FXAA_REDUCE_MUL = 1.0/8.0; - float FXAA_REDUCE_MIN = (1.0/128.0); - - vec3 rgbNW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, -1.0) * u_texelDelta).xyz; - //#define Pass_Diffuse(v2TexCoord) texture2D(sampler0, v2TexCoord).xyz - //vec3 rgbNW = Pass_Diffuse(v2TexCoord + vec2(-u_texelDelta.x, -u_texelDelta.y)).xyz; - vec3 rgbNE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, -1.0) * u_texelDelta).xyz; - vec3 rgbSW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbSE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbM = texture2D(sampler0, v_texcoord0).xyz; - - vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW, luma); - float lumaNE = dot(rgbNE, luma); - float lumaSW = dot(rgbSW, luma); - float lumaSE = dot(rgbSE, luma); - float lumaM = dot( rgbM, luma); - - float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); - float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); - - vec2 dir; - dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); - dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); - - float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); - - float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); - - dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), - max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta; - - vec3 rgbA = (1.0/2.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (1.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (2.0/3.0 - 0.5)).xyz); - vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (0.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (3.0/3.0 - 0.5)).xyz); - float lumaB = dot(rgbB, luma); - - if((lumaB < lumaMin) || (lumaB > lumaMax)){ - color=rgbA; - } else { - color=rgbB; - } - return color; -} -#endif -#if(GAUSS_SQ==1) -vec3 processGAUSS_SQ(vec3 color){ - float GAUSS_KERNEL_SIZE = 5.0; - //indices - // 00 01 02 03 04 - // 05 06 07 08 09 - // 10 11 12 13 14 - // 15 16 17 18 19 - // 20 21 22 23 24 - - //filter strength, rather smooth - // 01 04 07 04 01 - // 04 16 26 16 04 - // 07 26 41 26 07 - // 04 16 26 16 04 - // 01 04 07 04 01 - - vec2 offset = u_pixelDelta*Gsmoothing/GAUSS_KERNEL_SIZE; - - vec3 cGauss0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-2.0)).xyz; - vec3 cGauss1 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-2.0)).xyz; - vec3 cGauss2 = 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz; - vec3 cGauss3 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-2.0)).xyz; - vec3 cGauss4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-2.0)).xyz; - vec3 cGauss5 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-1.0)).xyz; - vec3 cGauss6 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz; - vec3 cGauss7 = 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz; - vec3 cGauss8 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz; - vec3 cGauss9 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-1.0)).xyz; - vec3 cGauss10= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz; - vec3 cGauss11= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz; - vec3 cGauss12= 41.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz; - vec3 cGauss13= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz; - vec3 cGauss14= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz; - vec3 cGauss15= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 1.0)).xyz; - vec3 cGauss16= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz; - vec3 cGauss17= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz; - vec3 cGauss18= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz; - vec3 cGauss19= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 1.0)).xyz; - vec3 cGauss20= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 2.0)).xyz; - vec3 cGauss21= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 2.0)).xyz; - vec3 cGauss22= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz; - vec3 cGauss23= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 2.0)).xyz; - vec3 cGauss24= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 2.0)).xyz; - - color.xyz = cGauss0 + cGauss1 + cGauss2 + cGauss3 + cGauss4 + cGauss5 + cGauss6 + cGauss7 + cGauss8 + cGauss9 + cGauss10 + cGauss11 + cGauss12 + cGauss13 + cGauss14 + cGauss15 + cGauss16 + cGauss17 + cGauss18 + cGauss19 + cGauss20 + cGauss21 + cGauss22 + cGauss23 + cGauss24; - color.xyz = color.xyz / 273.0; - return color; -} -#endif -#if(GAUSS_S==1) -vec3 processGAUSS_S(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float GAUSSS_SPAN_MAX = 1.5; - - //just a variable to describe the maximu - float GAUSSS_KERNEL_SIZE = 5.0; - //indices - // XX XX 00 XX XX - // XX 01 02 03 XX - // 04 05 06 07 08 - // XX 09 10 11 XX - // XX XX 12 XX XX - - //filter strength, rather smooth - // XX XX 01 XX XX - // XX 03 08 03 XX - // 01 08 10 08 01 - // XX 03 08 03 XX - // XX XX 01 XX XX - - vec2 offsetS = u_pixelDelta*GAUSSS_SPAN_MAX/GAUSSS_KERNEL_SIZE; - - vec3 cGaussS0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-2.0)).xyz; - vec3 cGaussS1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0,-1.0)).xyz; - vec3 cGaussS2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-1.0)).xyz; - vec3 cGaussS3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0,-1.0)).xyz; - vec3 cGaussS4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-2.0, 0.0)).xyz; - vec3 cGaussS5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 0.0)).xyz; - vec3 cGaussS6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 0.0)).xyz; - vec3 cGaussS7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 0.0)).xyz; - vec3 cGaussS8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 2.0, 0.0)).xyz; - vec3 cGaussS9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 1.0)).xyz; - vec3 cGaussS10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 1.0)).xyz; - vec3 cGaussS11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 1.0)).xyz; - vec3 cGaussS12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 2.0)).xyz; - - color = cGaussS0 + cGaussS1 + cGaussS2 + cGaussS3 + cGaussS4 + cGaussS5 + cGaussS6 + cGaussS7 + cGaussS8 + cGaussS9 + cGaussS10 + cGaussS11 + cGaussS12; - color = color / 58.0; - return color; -} -#endif -#if(xBRAccuracy==1 || xBR==1) - -#if(xBRAccuracy==1) - -const float XBR_SCALE = 3.0; -const float lv2_cf = 2.0; -const vec3 rgbw = vec3(14.352, 28.176, 5.472); -const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); -const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25); - -#else -const float coef = 2.0; -const vec3 rgbw = vec3(16.163, 23.351, 8.4772); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); - -#endif - -vec4 df(vec4 A, vec4 B) { - return abs(A-B); -} -#if(xBRAccuracy==1) - -// Compare two vectors and return their components are different. -vec4 diff(vec4 A, vec4 B) { - return vec4(notEqual(A, B)); -} - -// Determine if two vector components are equal based on a threshold. -vec4 eq(vec4 A, vec4 B) { - return (step(df(A, B), eq_threshold)); -} - -// Determine if two vector components are NOT equal based on a threshold. -vec4 neq(vec4 A, vec4 B) { - return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B)); -} -float c_df(vec3 c1, vec3 c2) { - vec3 df = abs(c1 - c2); - return df.r + df.g + df.b; -} -#else -bvec4 _and_(bvec4 A, bvec4 B) { - return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); -} -bvec4 _or_(bvec4 A, bvec4 B) { - return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); -} -bvec4 close(vec4 A, vec4 B) { - return (lessThan(df(A, B), vec4(15.0))); -} -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) { - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} -#endif -vec3 processxBR(vec3 color){ - vec2 pS = 1.0 / u_texelDelta.xy; - vec2 fp = fract(v_texcoord0.xy*pS.xy); - vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy; - vec2 dx = vec2(u_texelDelta.x,0.0); - vec2 dy = vec2(0.0,u_texelDelta.y); - vec2 y2 = dy + dy; vec2 x2 = dx + dx; - -#if(xBRAccuracy==1) - // px = pixel, edr = edge detection rule - vec4 edri, edr, edr_l, edr_u, px; - vec4 irlv0, irlv1, irlv2l, irlv2u; - vec4 fx, fx_l, fx_u; // inequations of straight lines. - - vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_u = delta_l.yxwz; -#else - bvec4 edr, edr_left, edr_up, px; // px = pixel, edr = edge detection rule - bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up; - bvec4 nc; // new_color - bvec4 fx, fx_left, fx_up; // inequations of straight lines. -#endif - - vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy).xyz; - vec3 B = texture2D(sampler0, TexCoord_0 -dy).xyz; - vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy).xyz; - vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz; - vec3 E = texture2D(sampler0, TexCoord_0 ).xyz; - vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz; - vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy).xyz; - vec3 H = texture2D(sampler0, TexCoord_0 +dy).xyz; - vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy).xyz; - vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz; - vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz; - vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz; - vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz; - vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz; - vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz; - vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz; - vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz; - vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz; - vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz; - vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz; - vec3 F4 = texture2D(sampler0, TexCoord_0 +x2 ).xyz; - - vec4 b = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw)); - vec4 c = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw)); - vec4 d = b.yzwx; - vec4 e = vec4(dot(E,rgbw)); - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw)); - vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw)); - vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw)); - vec4 f4 = h5.yzwx; - -#if(xBRAccuracy==1) - // These inequations define the line below which interpolation occurs. - fx = (Ao*fp.y+Bo*fp.x); - fx_l = (Ax*fp.y+Bx*fp.x); - fx_u = (Ay*fp.y+By*fp.x); - - irlv1 = irlv0 = diff(e,f) * diff(e,h); - -#if(CornerA==0) // A takes priority skipping other corners - #define SMOOTH_TIPS - // Corner C also default if no other ones used - irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) ); - int select1 = 0; -#if(CornerB==1) // Corner B - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) ); - select1 = 1; -#endif -#if(CornerD==1) // Corner D - if (select1==0){ - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0))); - } -#endif -#endif - - irlv2l = diff(e,g) * diff(d,g); - irlv2u = diff(e,c) * diff(b,c); - - vec4 fx45i = clamp((fx + delta -Co - Ci)/(2.0*delta ), 0.0, 1.0); - vec4 fx45 = clamp((fx + delta -Co )/(2.0*delta ), 0.0, 1.0); - vec4 fx30 = clamp((fx_l + delta_l -Cx )/(2.0*delta_l), 0.0, 1.0); - vec4 fx60 = clamp((fx_u + delta_u -Cy )/(2.0*delta_u), 0.0, 1.0); - - vec4 w1, w2; - w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw); - w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw); - w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw); - w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw); - - w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw); - w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw); - w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw); - w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw); - - edri = step(w1, w2) * irlv0; - edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1); - - w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw); - w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw); - - edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr; - edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr; - - fx45 = edr * fx45; - fx30 = edr_l * fx30; - fx60 = edr_u * fx60; - fx45i = edri * fx45i; - - w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw); - w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw); - - px = step(w1, w2); - -#ifdef SMOOTH_TIPS - vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i)); -#else - vec4 maximos = max(max(fx30, fx60), fx45); -#endif - - vec3 res1 = E; - res1 = mix(res1, mix(H, F, px.x), maximos.x); - res1 = mix(res1, mix(B, D, px.z), maximos.z); - - vec3 res2 = E; - res2 = mix(res2, mix(F, B, px.y), maximos.y); - res2 = mix(res2, mix(D, H, px.w), maximos.w); - - vec3 res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2))); -#else - // These inequations define the line below which interpolation occurs. - fx = greaterThan(Ao*fp.y+Bo*fp.x,Co); - fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx); - fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy); - - if (VariantB==1){ - bvec4 t1 = _and_( notEqual(e, f), notEqual(e, h) ); - bvec4 t2 = _and_( not(close(f, b)), not(close(h, d)) ); - bvec4 t3 = _and_( _and_( close(e, i), not(close(f, i4)) ), not(close(h, i5)) ); - bvec4 t4 = _or_( close(e, g), close(e, c) ); - interp_restriction_lv1 = _and_( t1, _or_( _or_(t2, t3), t4 ) ); - } else { - interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h))); - } - interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g))); - interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c))); - - edr = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1)); - edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left)); - edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up)); - - nc.x = ( edr.x && (fx.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) ); - nc.y = ( edr.y && (fx.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) ); - nc.z = ( edr.z && (fx.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) ); - nc.w = ( edr.w && (fx.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) ); - - px = lessThanEqual(df(e,f),df(e,h)); - - vec3 res; - if (Variantx2 == 1) { - vec3 E0 = E.xyz; - vec3 E1 = E.xyz; - vec3 E2 = E.xyz; - vec3 E3 = E.xyz; - vec3 P[4]; - P[0] = px.x ? F : H; - P[1] = px.y ? B : F; - P[2] = px.z ? D : B; - P[3] = px.w ? H : D; - if (edr.x) { - if (edr_left.x && edr_up.x) { - E3 = mix(E3 , P[0], 0.833333); - E2 = mix(E2 , P[0], 0.25); - E1 = mix(E1 , P[0], 0.25); - } else if (edr_left.x) { - E3 = mix(E3 , P[0], 0.75); - E2 = mix(E2 , P[0], 0.25); - } else if (edr_up.x) { - E3 = mix(E3 , P[0], 0.75); - E1 = mix(E1 , P[0], 0.25); - } else { - E3 = mix(E3 , P[0], 0.5); - } - } - if (edr.y) { - if (edr_left.y && edr_up.y) { - E1 = mix(E1 , P[1], 0.833333); - E3 = mix(E3 , P[1], 0.25); - E0 = mix(E0 , P[1], 0.25); - } else if (edr_left.y) { - E1 = mix(E1 , P[1], 0.75); - E3 = mix(E3 , P[1], 0.25); - } else if (edr_up.y) { - E1 = mix(E1 , P[1], 0.75); - E0 = mix(E0 , P[1], 0.25); - } else { - E1 = mix(E1 , P[1], 0.5); - } - } - if (edr.z) { - if (edr_left.z && edr_up.z) { - E0 = mix(E0 , P[2], 0.833333); - E1 = mix(E1 , P[2], 0.25); - E2 = mix(E2 , P[2], 0.25); - } else if (edr_left.z) { - E0 = mix(E0 , P[2], 0.75); - E1 = mix(E1 , P[2], 0.25); - } else if (edr_up.z) { - E0 = mix(E0 , P[2], 0.75); - E2 = mix(E2 , P[2], 0.25); - } else { - E0 = mix(E0 , P[2], 0.5); - } - } - if (edr.w) { - if (edr_left.w && edr_up.w) { - E2 = mix(E2 , P[3], 0.833333); - E0 = mix(E0 , P[3], 0.25); - E3 = mix(E3 , P[3], 0.25); - } else if (edr_left.w) { - E2 = mix(E2 , P[3], 0.75); - E0 = mix(E0 , P[3], 0.25); - } else if (edr_up.w) { - E2 = mix(E2 , P[3], 0.75); - E3 = mix(E3 , P[3], 0.25); - } else { - E2 = mix(E2 , P[3], 0.5); - } - } - res = (fp.x < 0.50) ? (fp.y < 0.50 ? E0 : E2) : (fp.y < 0.50 ? E1: E3); - } else { - res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E; - } -#endif - return res; -} -#endif -#if(BLOOM==1) -vec3 processBLOOM(vec3 color, vec3 colorB, int hatsu){ - #define factor 0.002 //Default: 0.002 /just an extra tweak for the bloom slightly higher values might look better in some cases, but too much can cause artifacts - vec4 sum = vec4(0); - int jb; - int diffx = samples - 1; - int ib; - int diffy = samples; - vec3 bloom; - for( ib= -diffy ;ib < diffy; ib++) { - for (jb = -diffx; jb < diffx; jb++) { - sum += texture2D(sampler0, v_texcoord0.xy + vec2(jb, ib)*factor) * quality; - } - } - if(color.r < 0.3 && color.g < 0.3 && color.b < 0.3) { - bloom = sum.xyz*sum.xyz*0.012 + color; - } else { - if(color.r < 0.5 && color.g < 0.5 && color.b < 0.5) { - bloom = sum.xyz*sum.xyz*0.009 + color; - } else { - bloom = sum.xyz*sum.xyz*0.0075 + color; - } - } - color = mix(color, bloom, Bpower); - if(hatsu==1) { - color = mix(colorB, color, 0.5); - } - return color; -} -vec3 processMIKU(vec3 color){ - vec3 mmm = vec3(0.1, 0.1, 0.1); - color = mix(color,mmm, 0.9); - return color; -} -#endif -#if(NATURALC==1) -const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212, - 0.587,-0.275,-0.523, - 0.114,-0.321, 0.311); - -const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0, - 0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523, - 0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149); - -const vec3 val00 = vec3( 1.2, 1.2, 1.2); -vec3 processNATURALC(vec3 color){ - vec3 c0,c1; - - c0 = texture2D(sampler0,v_texcoord1.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord1.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord1.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord1.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord2.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord2.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord2.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord2.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord3.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord3.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord3.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord3.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord4.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord4.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord4.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord4.zw).xyz)*0.125; - c0*=0.153846153846; - - c1=RGBtoYIQ*c0; - - c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz); - - color=mix(color,YIQtoRGB*c1,ncpower); - return color; -} -#endif -#if(SCANLINES==1) -vec3 processSCANLINES(vec3 color){ - int vscan = SLV; - vec3 colorSL=color*SLcolor; - if(vscan==0){ - float rey = (1.0/float(SLsize)/u_pixelDelta.y); - float posSy = v_texcoord0.y*rey; - float lineSy = mod(posSy,2.0); - if (noGradient==1) { - bool clSy = lineSy<1.0; - lineSy = mix(1.0,0.0,float(clSy)); - } - color=color-lineSy; - } else { - float rex = (1.0/float(SLsize)/u_pixelDelta.x); - float posSx = v_texcoord0.x*(rex/1.0); - float lineSx = mod(posSx,2.0); - if (noGradient==1) { - bool clSx = lineSx<1.0; - lineSx = mix(1.0,0.0,float(clSx)); - } - color=color-lineSx; - } - if (noGradient==1) { - color=mix(color,clamp(colorSL,0.0,1.0),SLpower); - } else { - color=mix(color,colorSL,SLpower); - } - return color; -} -#endif -#if(SHARPEN==1) -vec3 processSHARPEN(vec3 color){ - color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*value; - color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*value; - return color; -} -#endif -#if(S_COM_V2==1) -vec3 processS_COM_V2(vec3 color){ - float width = (v_texcoord0.x); - float height = (v_texcoord0.y); - float px = (u_texelDelta.x); - float py = (u_texelDelta.y); - float mean = 0.6; - float dx = (mean * px); - float dy = (mean * py); - float CoefBlur = 2.0; - float CoefOrig = (1.0 + CoefBlur); - float Sharpen_val1 = ((S_val0 - 1.0) / 8.0); - vec3 S_Edge = vec3(0.2,0.2,0.2); - // get original pixel / color - - // compute blurred image (gaussian filter) - vec3 c1 = texture2D(sampler0, v_texcoord0 + vec2(-dx, -dy)).xyz; - vec3 c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -dy)).xyz; - vec3 c3 = texture2D(sampler0, v_texcoord0 + vec2( dx, -dy)).xyz; - vec3 c4 = texture2D(sampler0, v_texcoord0 + vec2(-dx, 0)).xyz; - vec3 c5 = texture2D(sampler0, v_texcoord0 + vec2( dx, 0)).xyz; - vec3 c6 = texture2D(sampler0, v_texcoord0 + vec2(-dx, dy)).xyz; - vec3 c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, dy)).xyz; - vec3 c8 = texture2D(sampler0, v_texcoord0 + vec2( dx, dy)).xyz; - - // gaussian filter - // [ 1, 2, 1 ] - // [ 2, 4, 2 ] - // [ 1, 2, 1 ] - // to normalize the values, we need to divide by the coeff sum - // 1 / (1+2+1+2+4+2+1+2+1) = 1 / 16 = 0.0625 - vec3 flou = (c1 + c3 + c6 + c8 + 2.0 * (c2 + c4 + c5 + c7) + 4.0 * color) * 0.0625; - - // substract blurred image from original image - vec3 corrected = CoefOrig * color - CoefBlur * flou; - - // edge detection - // Get neighbor points - // [ c1, c2, c3 ] - // [ c4, color, c5 ] - // [ c6, c7, c8 ] - c1 = texture2D(sampler0, v_texcoord0 + vec2(-px, -py)).xyz; - c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -py)).xyz; - c3 = texture2D(sampler0, v_texcoord0 + vec2( px, -py)).xyz; - c4 = texture2D(sampler0, v_texcoord0 + vec2(-px, 0)).xyz; - c5 = texture2D(sampler0, v_texcoord0 + vec2( px, 0)).xyz; - c6 = texture2D(sampler0, v_texcoord0 + vec2(-px, py)).xyz; - c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, py)).xyz; - c8 = texture2D(sampler0, v_texcoord0 + vec2( px, py)).xyz; - - // using Sobel filter - // horizontal gradient - // [ -1, 0, 1 ] - // [ -2, 0, 2 ] - // [ -1, 0, 1 ] - vec3 delta1 = (c3 + 2.0 * c5 + c8) - (c1 + 2.0 * c4 + c6); - - // Save some arithmetic operations to ensure PS2 compatibility - c1 += c3; - c6 += c8; - // vertical gradient - // [ -1, - 2, -1 ] - // [ 0, 0, 0 ] - // [ 1, 2, 1 ] - vec3 delta2 = (c6 + 2.0 * c7 ) - (c1 + 2.0 * c2 ); - vec3 checkshc = sqrt(delta1 * delta1 + delta2 * delta2); - // computation - if (checkshc.x > S_Edge.x || checkshc.y > S_Edge.y || checkshc.z > S_Edge.z) { - // if we have an edge, use sharpen - corrected = color * S_val0 - (c1 + c2 + c4 + c5 + c6 + c7 ) * Sharpen_val1; - } - return corrected; -} -#endif -#if(GAMMA==1) -vec3 processGAMMA(vec3 color){ - vec3 gam=vec3(pow(color.r,1.0/abs(correction)),pow(color.g,1.0/abs(correction)),pow(color.b,1.0/abs(correction))); - return gam; -} -#endif -#if(SHADEBOOST==1) -vec3 processSHADEBOOST(vec3 color){ - float sat = saturation; - float brt = brightness; - float con = contrast; - - // Increase or decrease theese values to adjust r, g and b color channels seperately - float AvgLumR = red; - float AvgLumG = green; - float AvgLumB = blue; - - //==========================presets - if(SEPIA==1) { - sat = 0.11; - brt = 0.87; - con = 1.20; - AvgLumR = 1.19930; - AvgLumG = 0.960; - AvgLumB = 0.6754; - } - if(GRAYSCALE==1) { - sat = 0.0; - brt = 1.0; - con = 1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(NEGATIVE==1) { - sat = 1.0; - brt = 1.0; - con = -1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(PSPCOLORS==1) { - sat = 1.0; - brt = 1.0; - con = 1.0; - AvgLumR = 0.9593; - AvgLumG = 1.0739; - AvgLumB = 1.4604; - } - //========================== - const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); - - vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); - vec3 conRGB = vec3(0.5, 0.5, 0.5); - vec3 brtColor = color.rgb * brt; - vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c - vec3 satColor = mix(intensity, brtColor, sat); - vec3 conColor = mix(conRGB, satColor, con); - vec3 mixColor = AvgLumin * conColor; - color.rgb = mixColor; - if(rgbRBG==1) { - color.rgb = color.rbg; - } - if(rgbBGR==1) { - color.rgb = color.bgr; - } - if(rgbBRG==1) { - color.rgb = color.brg; - } - if(rgbGRB==1) { - color.rgb = color.grb; - } - if(rgbGBR==1) { - color.rgb = color.gbr; - } - return color; -} -#endif -#if(COLORED==1) -float overlay(float base, float blend) { - float result = 0.0; - if( base < 0.5 ) { - result = 2.0 * base * blend; - } else { - result = 1.0 - (1.0 - 2.0*(base-0.5)) * (1.0-blend); - } - return result; -} -vec3 processCOLORED(vec3 color){ - vec3 blur = color * 1.22520613262190495; - vec3 newcolor = vec3(overlay(color.r,blur.r), - overlay(color.g,blur.g), - overlay(color.b,blur.b)); - color = mix(color, newcolor, Cpower); - return color; -} -#endif -#if(TEST==1) -vec3 processTEST(vec3 color){ - if(v_texcoord0.x<0.5) { - color.xyz=color.xyz; - } else { - color.xyz=texture2D(sampler0, v_texcoord0.xy).xyz; - } - return color; -} -#endif -#if(TESTANIM==1) -vec3 processTESTANIM(vec3 color){ - float anim=(sin(u_time.x*testAspeed)+0.9)*0.55; - if(v_texcoord0.x tolerance || diff.g > tolerance || diff.b > tolerance; //workaround for the above - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Frost==1) -float rand(vec2 co){ - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); -} -vec3 processFrost(vec3 color) { - float tolerance = fTol/1638.4; - for (int i=1;i<5;i++) { - float p = u_pixelDelta.x * float(i) / rand(vec2(rand(v_texcoord0.xy),rand(v_texcoord0.xy))); - vec3 c1 = texture2D(sampler0,v_texcoord0.xy + vec2( p, p)).xyz; - vec3 c1b = texture2D(sampler0,v_texcoord0.xy + vec2( -p, -p)).xyz; - vec3 c2 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, p)).xyz; - vec3 c2b = texture2D(sampler0,v_texcoord0.xy + vec2( p, -p)).xyz; - vec3 c3 = texture2D(sampler0,v_texcoord0.xy + vec2( p,0.0)).xyz; - vec3 c3b = texture2D(sampler0,v_texcoord0.xy + vec2( -p,0.0)).xyz; - vec3 c4 = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, -p)).xyz; - vec3 c4b = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, p)).xyz; - vec3 avg; - if(fSimple==1) { - avg = (c1 + c2 + c3 + c4)/4.0; - } else { - avg = (c1 + c2 + c3 + c4 + c1b + c2b + c3b + c4b)/8.0; - } - vec3 diff = abs(color - avg); - bool a = diff.r > tolerance || diff.g > tolerance || diff.b > tolerance; - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Guest_AA4o==1) -const vec3 dt = vec3(1.0,1.0,1.0); -vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale; -vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale; -vec3 texture2d (vec2 texcoord) { - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2); -} -vec3 texture2dd (vec2 texcoord) { - - vec3 c11 = texture2D(sampler0, texcoord ).xyz; - vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz; - vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz; - vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz; - vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz; - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float d1=dot(abs(c00-c22),dt)+0.001; - float d2=dot(abs(c20-c02),dt)+0.001; - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2)); - - return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2)); -} -vec3 processGuestAA4o() { - // Calculating texel coordinates - - vec2 size = vec2(480.0,272.0)*scale; - vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scale; - - vec2 OGL2Pos = v_texcoord0 * size; - vec2 fp = fract(OGL2Pos); - vec2 dx = vec2(inv_size.x,0.0); - vec2 dy = vec2(0.0, inv_size.y); - vec2 g1 = vec2(inv_size.x,inv_size.y); - vec2 g2 = vec2(-inv_size.x,inv_size.y); - - vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size; - - // Reading the texels - vec3 C0 = texture2d(pC4 - g1); - vec3 C1 = texture2d(pC4 - dy); - vec3 C2 = texture2d(pC4 - g2); - vec3 C3 = texture2d(pC4 - dx); - vec3 C4 = texture2d(pC4 ); - vec3 C5 = texture2d(pC4 + dx); - vec3 C6 = texture2d(pC4 + g2); - vec3 C7 = texture2d(pC4 + dy); - vec3 C8 = texture2d(pC4 + g1); - - vec3 ul, ur, dl, dr; - float m1, m2; - - m1 = dot(abs(C0-C4),dt)+0.001; - m2 = dot(abs(C1-C3),dt)+0.001; - ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2); - - m1 = dot(abs(C1-C5),dt)+0.001; - m2 = dot(abs(C2-C4),dt)+0.001; - ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2); - - m1 = dot(abs(C3-C7),dt)+0.001; - m2 = dot(abs(C6-C4),dt)+0.001; - dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2); - - m1 = dot(abs(C4-C8),dt)+0.001; - m2 = dot(abs(C5-C7),dt)+0.001; - dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2); - - vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y))); - - if(filtro==1){ - vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)); - - inv_size = vec2(2.0/480.0,2.0/272.0)/scale;; - - dx = vec2(inv_size.x,0.0); - dy = vec2(0.0,inv_size.y); - g1 = vec2( inv_size.x,inv_size.y); - g2 = vec2(-inv_size.x,inv_size.y); - pC4 = v_texcoord0; - - C0 = texture2dd(pC4-g1); - C1 = texture2dd(pC4-dy); - C2 = texture2dd(pC4-g2); - C3 = texture2dd(pC4-dx); - C4 = texture2dd(pC4 ); - C5 = texture2dd(pC4+dx); - C6 = texture2dd(pC4+g2); - C7 = texture2dd(pC4+dy); - C8 = texture2dd(pC4+g1); - - vec3 mn1 = min(min(C0,C1),C2); - vec3 mn2 = min(min(C3,C4),C5); - vec3 mn3 = min(min(C6,C7),C8); - vec3 mx1 = max(max(C0,C1),C2); - vec3 mx2 = max(max(C3,C4),C5); - vec3 mx3 = max(max(C6,C7),C8); - - mn1 = min(min(mn1,mn2),mn3); - mx1 = max(max(mx1,mx2),mx3); - - vec3 dif1 = abs(c11-mn1) + 0.0001*dt; - vec3 dif2 = abs(c11-mx1) + 0.0001*dt; - - float filterparam = 2.0; - - dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam)); - dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam)); - - c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x); - c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y); - c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z); - - result = c11; - } - - return result; -} -#endif -#if(Bilateral==1) - - -#define SIGMA 10.0 -#define BSIGMA 0.1 -#define MSIZE 15 -float normpdf(float x, float sigma) { - return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma; -} - -float normpdf3(vec3 v, float sigma) { - return 0.39894*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma; -} - -vec3 processBilateral(vec3 color) { - const int kSize = (MSIZE-1)/2; - float kernel[MSIZE]; - vec3 final_colour; - - // Create the 1-D kernel - float Zxx = 0.0; - for (int j = 0; j <= kSize; ++j) { - kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA); - } - // sigma 10.0, MSIZE 15 - //someone mentioned performance increase with precompiled kernel, but really don't see that - //const float kernel[MSIZE] = float[MSIZE](0.031225216, 0.033322271, 0.035206333, 0.036826804, 0.038138565, 0.039104044, 0.039695028, 0.039894000, 0.039695028, 0.039104044, 0.038138565, 0.036826804, 0.035206333, 0.033322271, 0.031225216); - vec3 cc; - float factorNB; - float bZ = 1.0/normpdf(0.0, BSIGMA); - // Read out the texels - for (int i=-kSize; i <= kSize; ++i) { - for (int j=-kSize; j <= kSize; ++j) { - cc = texture2D(sampler0, v_texcoord0.xy+vec2(float(i)*u_pixelDelta.x,float(j)*u_pixelDelta.x)).rgb; - factorNB = normpdf3(cc-color, BSIGMA)*bZ*kernel[kSize+j]*kernel[kSize+i]; - Zxx += factorNB; - final_colour += factorNB*cc; - } - } - return final_colour/Zxx; -} -#endif -void main() { - vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; - #if(FXAA==1) - color=processFXAA(color); - #endif - #if(GAUSS_SQ==1) - color=processGAUSS_SQ(color); - #endif - #if(GAUSS_S==1) - color=processGAUSS_S(color); - #endif - #if(Guest_AA4o==1) - color=processGuestAA4o(); - #endif - #if(SHARPEN==1) - color=processSHARPEN(color); - #endif - #if(S_COM_V2==1) - color=processS_COM_V2(color); - #endif - #if(xHQ==1) - color=processxHQ(color); - #endif - #if(xBRAccuracy==1 || xBR==1) - color=processxBR(color); - #endif - #if(Deband==1) - color=processDeband(color); - #endif - #if(Frost==1) - color=processFrost(color); - #endif - #if(Bilateral==1) - color=processBilateral(color); - #endif - #if(NATURALC==1) - color=processNATURALC(color); - #endif - #if(ACARTOON==1) - color=processACARTOON(color); - #endif - #if(BLOOM==1) - vec3 colorB=color; - int hatsu = 0; - #if(MIKU==1) - hatsu = 1; - color=processMIKU(color); - #endif - color=processBLOOM(color, colorB, hatsu); - #endif - #if(COLORED==1) - color=processCOLORED(color); - #endif - #if(SHADEBOOST==1) - color = processSHADEBOOST(color); - #endif - #if(GAMMA==1) - color = processGAMMA(color); - #endif - #if(SCANLINES==1) - color = processSCANLINES(color); - #endif - #if(LCD3x==1) - color = processLCD3x(color); - #endif - #if(VIGNETTE==1) - color = processVIGNETTE(color); - #endif - #if(TEST==1) - color = processTEST(color); - #endif - #if(TESTANIM==1) - color = processTESTANIM(color); - #endif - gl_FragColor.xyz=color; - gl_FragColor.a = 1.0; -} diff --git a/assets/shaders/Luna2.fsh b/assets/shaders/Luna2.fsh deleted file mode 100644 index 1b579f331a..0000000000 --- a/assets/shaders/Luna2.fsh +++ /dev/null @@ -1,1452 +0,0 @@ -//Note : Recommend to use PPSSPP v1.1.1-183-gb411fc0 or newer for full functionality, there were some bugs in earlier versions. -//Note2 : Upscaling, smoothing and sharpening filters are not set to be mixed between each other since the results are pointless(they counter each other). -// Only last one applies, so pick just one of them, mess around with it's settings and add other effects as needed. -//====================================================================================================================================================================== -//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res -//================ -#define FXAA 0 //ON:1/OFF:0 /default FXAA, orginal info below -//================ -#define GAUSS_SQ 0 //ON:1/OFF:0 /full square gauss filtering -#define Gsmoothing 3.5 //Default: 3.5 /increase for smoother(blurry) graphics -//================ -#define GAUSS_S 0 //ON:1/OFF:0 /simple gauss filtering by Bigpet, slightly different from above /you can find standalone in https://github.com/hrydgard/ppsspp/issues/7242 -//================ -#define Guest_AA4o 0 //ON:1/OFF:0 /alternative to FXAA /taken from http://forums.ppsspp.org/showthread.php?tid=6594&pid=124441#pid124441 -#define scale 7.0 //Default: 7.0 / 4.0 -> smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) -#define filtro 0 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier -//================ -//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing -//================ -#define SHARPEN 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default -#define value 7.5 //Default: 7.5 /higher = more visible effect -//================ -#define S_COM_V2 0 //Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate -#define S_val0 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect -//================ -//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" - //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically -//================ -#define xBR 0 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below -#define VariantB 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details -#define Variantx2 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR -//================ -#define xBRAccuracy 1 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below -#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding -#define CornerB 0 //ON:1/OFF:0 / activate only one -#define CornerD 0 //ON:1/OFF:0 -// CornerC //used as default if no other ones are defined -//================ -#define xHQ 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution -#define scaleoffset 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness -//================ -//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one -//================ -#define Deband 0 //ON:1/OFF:0 /Blurs -#define DeTol 16.0 //Default: 16.0 /tolerance, too high will look glitchy -//================ -#define Frost 0 //ON:1/OFF:0 /Dithering ~ adds noise -#define fTol 32.0 //Default: 32.0 /tolerance, too high will look glitchy -#define fSimple 0 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version -//================ -#define Bilateral 0 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH -//================ -//OTHER FILTERS: //Most effects from here on can be fully mixed without loosing previous effects. Exceptions: Natural Colors, Advanced Cartoon -//================ -#define BLOOM 0 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ -#define MIKU 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress -#define samples 3 //Default: 4 /higher = more glow, worse performance -#define quality 0.22 //Default: 0.18 /lower = smaller glow, better quality -#define Bpower 1.0 //Default: 1.0 /amount of bloom mixed -//================ -#define COLORED 1 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o -#define Cpower 0.25 //Default: 0.5 /strenght of the effect -//================ -#define NATURALC 0 //ON:1/OFF:0 /by popular demand, natular colors, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -#define ncpower 0.5 //Default:0.5 / higher = more natural color, check note line above -//================ -#define ACARTOON 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack -#define th 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 -#define bb 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 -#define pp 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 -#define acpower 0.5 //Default:0.5 / higher = more effect, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -//================ -#define SHADEBOOST 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 -#define saturation 1.0 //Default: 1.0 //negative will look like inverted colors shader -#define brightness 1.0 //Default: 1.0 -#define contrast 1.0 //Default: 1.0 //negative will be... well negative;p -#define red 1.0 //Default: 1.0 -#define green 1.0 //Default: 1.0 -#define blue 1.0 //Default: 1.0 -//Shadeboost presets: //Shadeboost must be activated, presets override options above -#define SEPIA 0 //Moody coolors:) -#define GRAYSCALE 0 //Just for lols? -#define NEGATIVE 0 //As above -#define PSPCOLORS 0 //Makes the colors as on older PSP screens(colder) -//Simple color swap: //Shadeboost must be activated -#define rgbRBG 0 //green <-> blue -#define rgbBGR 0 //red <-> blue -#define rgbBRG 0 //red -> green -> blue -> red -#define rgbGRB 0 //red <-> green -#define rgbGBR 0 //red -> blue -> green -> red -//^All presets and color swap are simple switch ON:1/OFF:0, -//================ -#define GAMMA 1 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 -#define correction 0.85 //Default: 1.0 -//================ -#define SCANLINES 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) -#define SLsize 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high -#define SLcolor 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation -#define SLpower 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, -#define SLV 0 //ON:1/OFF:0 /vertical scanlines -#define noGradient 0 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line -//================ -#define LCD3x 0 //ON:1/OFF:0 //different scanline shader -#define b_sl 16.0 //Default: 16.0 /horizontal lines brightness -#define b_lcd 4.0 //Default: 4.0 /vertical lines brightness -#define sl_size 2.0 //Default: 2.0 /scanline size -//================ -#define VIGNETTE 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings -#define vsize 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values -#define VIpos 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) -#define deVi 0 //ON:1/OFF:0 /reverse vignette -//================ -#define TEST 0 //ON:1/OFF:0 /test mode, applies shaders on half of the screen for easy result comparison and tweaking -#define TESTANIM 0 //ON:1/OFF:0 /as above, animation slides shader from left to right and back /use only one -#define testAspeed 1.0 //animation speed -//================ -//Approximate performance hit -//Free: TEST, TESTANIM -//Light: SHARPEN, COLORED, SHADEBOOST, GAMMA, SCANLINES, LCD3x, VIGNETTE, BLOOM(<= 2 samples) -//Medium: FXAA, GAUSS_SQ, GAUSS_S, S_COM_V2, xHQ, Deband, Frost(fSimple), NATURALC, ACARTOON, BLOOM(== 3 samples) -//Heavy: Guest_AA4o, xBR, Frost, BLOOM(>= 4 samples), xBRAccuracy -//Extremely Heavy: Guest_AA4o(filtro), BLOOM(>= 8 samples), Bilateral -//====================================================================================================================================================================== -//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), -// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken -// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), -// other credits mentioned earlier, any more info / required licenses can be found below. - - - - -/* - FXAA shader, GLSL code adapted from: - http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA - Whitepaper describing the technique: - http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf -*/ - -/* - AA shader 4.o / AA shader 4.o - filtro - - Copyright (C) 2014 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - Hyllian's 5xBR v3.5a Shader - - Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from: - http://forums.ngemu.com/showthread.php?t=76098 - - by guest(r) (guest.r@gmail.com) - License: GNU-GPL - - Shader notes: looks better with sprite games -*/ - -/* - Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) - - Copyright (C) 2011-2015 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. - - Incorporates some of the ideas from SABR shader. Thanks to Joshua Street. -*/ - -/* - Advanced Cartoon shader - - Copyright (C) 2006 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#ifdef GL_ES -precision mediump float; -precision mediump int; -#endif - -uniform sampler2D sampler0; -uniform vec4 u_time; - - -//=========== -// The inverse of the texture dimensions along X and Y -uniform vec2 u_texelDelta; -uniform vec2 u_pixelDelta; -varying vec2 v_texcoord0; - -varying vec4 v_texcoord1; -varying vec4 v_texcoord2; -varying vec4 v_texcoord3; -varying vec4 v_texcoord4; -varying vec2 v_texcoord5; - - -//=========== -//=========== -#if(FXAA==1) -vec3 processFXAA(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float FXAA_SPAN_MAX = 8.0; - float FXAA_REDUCE_MUL = 1.0/8.0; - float FXAA_REDUCE_MIN = (1.0/128.0); - - vec3 rgbNW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, -1.0) * u_texelDelta).xyz; - //#define Pass_Diffuse(v2TexCoord) texture2D(sampler0, v2TexCoord).xyz - //vec3 rgbNW = Pass_Diffuse(v2TexCoord + vec2(-u_texelDelta.x, -u_texelDelta.y)).xyz; - vec3 rgbNE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, -1.0) * u_texelDelta).xyz; - vec3 rgbSW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbSE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbM = texture2D(sampler0, v_texcoord0).xyz; - - vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW, luma); - float lumaNE = dot(rgbNE, luma); - float lumaSW = dot(rgbSW, luma); - float lumaSE = dot(rgbSE, luma); - float lumaM = dot( rgbM, luma); - - float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); - float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); - - vec2 dir; - dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); - dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); - - float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); - - float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); - - dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), - max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta; - - vec3 rgbA = (1.0/2.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (1.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (2.0/3.0 - 0.5)).xyz); - vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (0.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (3.0/3.0 - 0.5)).xyz); - float lumaB = dot(rgbB, luma); - - if((lumaB < lumaMin) || (lumaB > lumaMax)){ - color=rgbA; - } else { - color=rgbB; - } - return color; -} -#endif -#if(GAUSS_SQ==1) -vec3 processGAUSS_SQ(vec3 color){ - float GAUSS_KERNEL_SIZE = 5.0; - //indices - // 00 01 02 03 04 - // 05 06 07 08 09 - // 10 11 12 13 14 - // 15 16 17 18 19 - // 20 21 22 23 24 - - //filter strength, rather smooth - // 01 04 07 04 01 - // 04 16 26 16 04 - // 07 26 41 26 07 - // 04 16 26 16 04 - // 01 04 07 04 01 - - vec2 offset = u_pixelDelta*Gsmoothing/GAUSS_KERNEL_SIZE; - - vec3 cGauss0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-2.0)).xyz; - vec3 cGauss1 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-2.0)).xyz; - vec3 cGauss2 = 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz; - vec3 cGauss3 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-2.0)).xyz; - vec3 cGauss4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-2.0)).xyz; - vec3 cGauss5 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-1.0)).xyz; - vec3 cGauss6 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz; - vec3 cGauss7 = 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz; - vec3 cGauss8 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz; - vec3 cGauss9 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-1.0)).xyz; - vec3 cGauss10= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz; - vec3 cGauss11= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz; - vec3 cGauss12= 41.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz; - vec3 cGauss13= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz; - vec3 cGauss14= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz; - vec3 cGauss15= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 1.0)).xyz; - vec3 cGauss16= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz; - vec3 cGauss17= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz; - vec3 cGauss18= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz; - vec3 cGauss19= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 1.0)).xyz; - vec3 cGauss20= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 2.0)).xyz; - vec3 cGauss21= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 2.0)).xyz; - vec3 cGauss22= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz; - vec3 cGauss23= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 2.0)).xyz; - vec3 cGauss24= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 2.0)).xyz; - - color.xyz = cGauss0 + cGauss1 + cGauss2 + cGauss3 + cGauss4 + cGauss5 + cGauss6 + cGauss7 + cGauss8 + cGauss9 + cGauss10 + cGauss11 + cGauss12 + cGauss13 + cGauss14 + cGauss15 + cGauss16 + cGauss17 + cGauss18 + cGauss19 + cGauss20 + cGauss21 + cGauss22 + cGauss23 + cGauss24; - color.xyz = color.xyz / 273.0; - return color; -} -#endif -#if(GAUSS_S==1) -vec3 processGAUSS_S(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float GAUSSS_SPAN_MAX = 1.5; - - //just a variable to describe the maximu - float GAUSSS_KERNEL_SIZE = 5.0; - //indices - // XX XX 00 XX XX - // XX 01 02 03 XX - // 04 05 06 07 08 - // XX 09 10 11 XX - // XX XX 12 XX XX - - //filter strength, rather smooth - // XX XX 01 XX XX - // XX 03 08 03 XX - // 01 08 10 08 01 - // XX 03 08 03 XX - // XX XX 01 XX XX - - vec2 offsetS = u_pixelDelta*GAUSSS_SPAN_MAX/GAUSSS_KERNEL_SIZE; - - vec3 cGaussS0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-2.0)).xyz; - vec3 cGaussS1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0,-1.0)).xyz; - vec3 cGaussS2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-1.0)).xyz; - vec3 cGaussS3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0,-1.0)).xyz; - vec3 cGaussS4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-2.0, 0.0)).xyz; - vec3 cGaussS5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 0.0)).xyz; - vec3 cGaussS6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 0.0)).xyz; - vec3 cGaussS7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 0.0)).xyz; - vec3 cGaussS8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 2.0, 0.0)).xyz; - vec3 cGaussS9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 1.0)).xyz; - vec3 cGaussS10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 1.0)).xyz; - vec3 cGaussS11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 1.0)).xyz; - vec3 cGaussS12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 2.0)).xyz; - - color = cGaussS0 + cGaussS1 + cGaussS2 + cGaussS3 + cGaussS4 + cGaussS5 + cGaussS6 + cGaussS7 + cGaussS8 + cGaussS9 + cGaussS10 + cGaussS11 + cGaussS12; - color = color / 58.0; - return color; -} -#endif -#if(xBRAccuracy==1 || xBR==1) - -#if(xBRAccuracy==1) - -const float XBR_SCALE = 3.0; -const float lv2_cf = 2.0; -const vec3 rgbw = vec3(14.352, 28.176, 5.472); -const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); -const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25); - -#else -const float coef = 2.0; -const vec3 rgbw = vec3(16.163, 23.351, 8.4772); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); - -#endif - -vec4 df(vec4 A, vec4 B) { - return abs(A-B); -} -#if(xBRAccuracy==1) - -// Compare two vectors and return their components are different. -vec4 diff(vec4 A, vec4 B) { - return vec4(notEqual(A, B)); -} - -// Determine if two vector components are equal based on a threshold. -vec4 eq(vec4 A, vec4 B) { - return (step(df(A, B), eq_threshold)); -} - -// Determine if two vector components are NOT equal based on a threshold. -vec4 neq(vec4 A, vec4 B) { - return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B)); -} -float c_df(vec3 c1, vec3 c2) { - vec3 df = abs(c1 - c2); - return df.r + df.g + df.b; -} -#else -bvec4 _and_(bvec4 A, bvec4 B) { - return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); -} -bvec4 _or_(bvec4 A, bvec4 B) { - return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); -} -bvec4 close(vec4 A, vec4 B) { - return (lessThan(df(A, B), vec4(15.0))); -} -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) { - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} -#endif -vec3 processxBR(vec3 color){ - vec2 pS = 1.0 / u_texelDelta.xy; - vec2 fp = fract(v_texcoord0.xy*pS.xy); - vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy; - vec2 dx = vec2(u_texelDelta.x,0.0); - vec2 dy = vec2(0.0,u_texelDelta.y); - vec2 y2 = dy + dy; vec2 x2 = dx + dx; - -#if(xBRAccuracy==1) - // px = pixel, edr = edge detection rule - vec4 edri, edr, edr_l, edr_u, px; - vec4 irlv0, irlv1, irlv2l, irlv2u; - vec4 fx, fx_l, fx_u; // inequations of straight lines. - - vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_u = delta_l.yxwz; -#else - bvec4 edr, edr_left, edr_up, px; // px = pixel, edr = edge detection rule - bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up; - bvec4 nc; // new_color - bvec4 fx, fx_left, fx_up; // inequations of straight lines. -#endif - - vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy).xyz; - vec3 B = texture2D(sampler0, TexCoord_0 -dy).xyz; - vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy).xyz; - vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz; - vec3 E = texture2D(sampler0, TexCoord_0 ).xyz; - vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz; - vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy).xyz; - vec3 H = texture2D(sampler0, TexCoord_0 +dy).xyz; - vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy).xyz; - vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz; - vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz; - vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz; - vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz; - vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz; - vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz; - vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz; - vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz; - vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz; - vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz; - vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz; - vec3 F4 = texture2D(sampler0, TexCoord_0 +x2 ).xyz; - - vec4 b = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw)); - vec4 c = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw)); - vec4 d = b.yzwx; - vec4 e = vec4(dot(E,rgbw)); - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw)); - vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw)); - vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw)); - vec4 f4 = h5.yzwx; - -#if(xBRAccuracy==1) - // These inequations define the line below which interpolation occurs. - fx = (Ao*fp.y+Bo*fp.x); - fx_l = (Ax*fp.y+Bx*fp.x); - fx_u = (Ay*fp.y+By*fp.x); - - irlv1 = irlv0 = diff(e,f) * diff(e,h); - -#if(CornerA==0) // A takes priority skipping other corners - #define SMOOTH_TIPS - // Corner C also default if no other ones used - irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) ); - int select1 = 0; -#if(CornerB==1) // Corner B - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) ); - select1 = 1; -#endif -#if(CornerD==1) // Corner D - if (select1==0){ - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0))); - } -#endif -#endif - - irlv2l = diff(e,g) * diff(d,g); - irlv2u = diff(e,c) * diff(b,c); - - vec4 fx45i = clamp((fx + delta -Co - Ci)/(2.0*delta ), 0.0, 1.0); - vec4 fx45 = clamp((fx + delta -Co )/(2.0*delta ), 0.0, 1.0); - vec4 fx30 = clamp((fx_l + delta_l -Cx )/(2.0*delta_l), 0.0, 1.0); - vec4 fx60 = clamp((fx_u + delta_u -Cy )/(2.0*delta_u), 0.0, 1.0); - - vec4 w1, w2; - w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw); - w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw); - w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw); - w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw); - - w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw); - w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw); - w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw); - w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw); - - edri = step(w1, w2) * irlv0; - edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1); - - w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw); - w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw); - - edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr; - edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr; - - fx45 = edr * fx45; - fx30 = edr_l * fx30; - fx60 = edr_u * fx60; - fx45i = edri * fx45i; - - w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw); - w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw); - - px = step(w1, w2); - -#ifdef SMOOTH_TIPS - vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i)); -#else - vec4 maximos = max(max(fx30, fx60), fx45); -#endif - - vec3 res1 = E; - res1 = mix(res1, mix(H, F, px.x), maximos.x); - res1 = mix(res1, mix(B, D, px.z), maximos.z); - - vec3 res2 = E; - res2 = mix(res2, mix(F, B, px.y), maximos.y); - res2 = mix(res2, mix(D, H, px.w), maximos.w); - - vec3 res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2))); -#else - // These inequations define the line below which interpolation occurs. - fx = greaterThan(Ao*fp.y+Bo*fp.x,Co); - fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx); - fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy); - - if (VariantB==1){ - bvec4 t1 = _and_( notEqual(e, f), notEqual(e, h) ); - bvec4 t2 = _and_( not(close(f, b)), not(close(h, d)) ); - bvec4 t3 = _and_( _and_( close(e, i), not(close(f, i4)) ), not(close(h, i5)) ); - bvec4 t4 = _or_( close(e, g), close(e, c) ); - interp_restriction_lv1 = _and_( t1, _or_( _or_(t2, t3), t4 ) ); - } else { - interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h))); - } - interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g))); - interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c))); - - edr = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1)); - edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left)); - edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up)); - - nc.x = ( edr.x && (fx.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) ); - nc.y = ( edr.y && (fx.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) ); - nc.z = ( edr.z && (fx.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) ); - nc.w = ( edr.w && (fx.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) ); - - px = lessThanEqual(df(e,f),df(e,h)); - - vec3 res; - if (Variantx2 == 1) { - vec3 E0 = E.xyz; - vec3 E1 = E.xyz; - vec3 E2 = E.xyz; - vec3 E3 = E.xyz; - vec3 P[4]; - P[0] = px.x ? F : H; - P[1] = px.y ? B : F; - P[2] = px.z ? D : B; - P[3] = px.w ? H : D; - if (edr.x) { - if (edr_left.x && edr_up.x) { - E3 = mix(E3 , P[0], 0.833333); - E2 = mix(E2 , P[0], 0.25); - E1 = mix(E1 , P[0], 0.25); - } else if (edr_left.x) { - E3 = mix(E3 , P[0], 0.75); - E2 = mix(E2 , P[0], 0.25); - } else if (edr_up.x) { - E3 = mix(E3 , P[0], 0.75); - E1 = mix(E1 , P[0], 0.25); - } else { - E3 = mix(E3 , P[0], 0.5); - } - } - if (edr.y) { - if (edr_left.y && edr_up.y) { - E1 = mix(E1 , P[1], 0.833333); - E3 = mix(E3 , P[1], 0.25); - E0 = mix(E0 , P[1], 0.25); - } else if (edr_left.y) { - E1 = mix(E1 , P[1], 0.75); - E3 = mix(E3 , P[1], 0.25); - } else if (edr_up.y) { - E1 = mix(E1 , P[1], 0.75); - E0 = mix(E0 , P[1], 0.25); - } else { - E1 = mix(E1 , P[1], 0.5); - } - } - if (edr.z) { - if (edr_left.z && edr_up.z) { - E0 = mix(E0 , P[2], 0.833333); - E1 = mix(E1 , P[2], 0.25); - E2 = mix(E2 , P[2], 0.25); - } else if (edr_left.z) { - E0 = mix(E0 , P[2], 0.75); - E1 = mix(E1 , P[2], 0.25); - } else if (edr_up.z) { - E0 = mix(E0 , P[2], 0.75); - E2 = mix(E2 , P[2], 0.25); - } else { - E0 = mix(E0 , P[2], 0.5); - } - } - if (edr.w) { - if (edr_left.w && edr_up.w) { - E2 = mix(E2 , P[3], 0.833333); - E0 = mix(E0 , P[3], 0.25); - E3 = mix(E3 , P[3], 0.25); - } else if (edr_left.w) { - E2 = mix(E2 , P[3], 0.75); - E0 = mix(E0 , P[3], 0.25); - } else if (edr_up.w) { - E2 = mix(E2 , P[3], 0.75); - E3 = mix(E3 , P[3], 0.25); - } else { - E2 = mix(E2 , P[3], 0.5); - } - } - res = (fp.x < 0.50) ? (fp.y < 0.50 ? E0 : E2) : (fp.y < 0.50 ? E1: E3); - } else { - res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E; - } -#endif - return res; -} -#endif -#if(BLOOM==1) -vec3 processBLOOM(vec3 color, vec3 colorB, int hatsu){ - #define factor 0.002 //Default: 0.002 /just an extra tweak for the bloom slightly higher values might look better in some cases, but too much can cause artifacts - vec4 sum = vec4(0); - int jb; - int diffx = samples - 1; - int ib; - int diffy = samples; - vec3 bloom; - for( ib= -diffy ;ib < diffy; ib++) { - for (jb = -diffx; jb < diffx; jb++) { - sum += texture2D(sampler0, v_texcoord0.xy + vec2(jb, ib)*factor) * quality; - } - } - if(color.r < 0.3 && color.g < 0.3 && color.b < 0.3) { - bloom = sum.xyz*sum.xyz*0.012 + color; - } else { - if(color.r < 0.5 && color.g < 0.5 && color.b < 0.5) { - bloom = sum.xyz*sum.xyz*0.009 + color; - } else { - bloom = sum.xyz*sum.xyz*0.0075 + color; - } - } - color = mix(color, bloom, Bpower); - if(hatsu==1) { - color = mix(colorB, color, 0.5); - } - return color; -} -vec3 processMIKU(vec3 color){ - vec3 mmm = vec3(0.1, 0.1, 0.1); - color = mix(color,mmm, 0.9); - return color; -} -#endif -#if(NATURALC==1) -const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212, - 0.587,-0.275,-0.523, - 0.114,-0.321, 0.311); - -const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0, - 0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523, - 0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149); - -const vec3 val00 = vec3( 1.2, 1.2, 1.2); -vec3 processNATURALC(vec3 color){ - vec3 c0,c1; - - c0 = texture2D(sampler0,v_texcoord1.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord1.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord1.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord1.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord2.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord2.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord2.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord2.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord3.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord3.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord3.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord3.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord4.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord4.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord4.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord4.zw).xyz)*0.125; - c0*=0.153846153846; - - c1=RGBtoYIQ*c0; - - c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz); - - color=mix(color,YIQtoRGB*c1,ncpower); - return color; -} -#endif -#if(SCANLINES==1) -vec3 processSCANLINES(vec3 color){ - int vscan = SLV; - vec3 colorSL=color*SLcolor; - if(vscan==0){ - float rey = (1.0/float(SLsize)/u_pixelDelta.y); - float posSy = v_texcoord0.y*rey; - float lineSy = mod(posSy,2.0); - if (noGradient==1) { - bool clSy = lineSy<1.0; - lineSy = mix(1.0,0.0,float(clSy)); - } - color=color-lineSy; - } else { - float rex = (1.0/float(SLsize)/u_pixelDelta.x); - float posSx = v_texcoord0.x*(rex/1.0); - float lineSx = mod(posSx,2.0); - if (noGradient==1) { - bool clSx = lineSx<1.0; - lineSx = mix(1.0,0.0,float(clSx)); - } - color=color-lineSx; - } - if (noGradient==1) { - color=mix(color,clamp(colorSL,0.0,1.0),SLpower); - } else { - color=mix(color,colorSL,SLpower); - } - return color; -} -#endif -#if(SHARPEN==1) -vec3 processSHARPEN(vec3 color){ - color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*value; - color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*value; - return color; -} -#endif -#if(S_COM_V2==1) -vec3 processS_COM_V2(vec3 color){ - float width = (v_texcoord0.x); - float height = (v_texcoord0.y); - float px = (u_texelDelta.x); - float py = (u_texelDelta.y); - float mean = 0.6; - float dx = (mean * px); - float dy = (mean * py); - float CoefBlur = 2.0; - float CoefOrig = (1.0 + CoefBlur); - float Sharpen_val1 = ((S_val0 - 1.0) / 8.0); - vec3 S_Edge = vec3(0.2,0.2,0.2); - // get original pixel / color - - // compute blurred image (gaussian filter) - vec3 c1 = texture2D(sampler0, v_texcoord0 + vec2(-dx, -dy)).xyz; - vec3 c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -dy)).xyz; - vec3 c3 = texture2D(sampler0, v_texcoord0 + vec2( dx, -dy)).xyz; - vec3 c4 = texture2D(sampler0, v_texcoord0 + vec2(-dx, 0)).xyz; - vec3 c5 = texture2D(sampler0, v_texcoord0 + vec2( dx, 0)).xyz; - vec3 c6 = texture2D(sampler0, v_texcoord0 + vec2(-dx, dy)).xyz; - vec3 c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, dy)).xyz; - vec3 c8 = texture2D(sampler0, v_texcoord0 + vec2( dx, dy)).xyz; - - // gaussian filter - // [ 1, 2, 1 ] - // [ 2, 4, 2 ] - // [ 1, 2, 1 ] - // to normalize the values, we need to divide by the coeff sum - // 1 / (1+2+1+2+4+2+1+2+1) = 1 / 16 = 0.0625 - vec3 flou = (c1 + c3 + c6 + c8 + 2.0 * (c2 + c4 + c5 + c7) + 4.0 * color) * 0.0625; - - // substract blurred image from original image - vec3 corrected = CoefOrig * color - CoefBlur * flou; - - // edge detection - // Get neighbor points - // [ c1, c2, c3 ] - // [ c4, color, c5 ] - // [ c6, c7, c8 ] - c1 = texture2D(sampler0, v_texcoord0 + vec2(-px, -py)).xyz; - c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -py)).xyz; - c3 = texture2D(sampler0, v_texcoord0 + vec2( px, -py)).xyz; - c4 = texture2D(sampler0, v_texcoord0 + vec2(-px, 0)).xyz; - c5 = texture2D(sampler0, v_texcoord0 + vec2( px, 0)).xyz; - c6 = texture2D(sampler0, v_texcoord0 + vec2(-px, py)).xyz; - c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, py)).xyz; - c8 = texture2D(sampler0, v_texcoord0 + vec2( px, py)).xyz; - - // using Sobel filter - // horizontal gradient - // [ -1, 0, 1 ] - // [ -2, 0, 2 ] - // [ -1, 0, 1 ] - vec3 delta1 = (c3 + 2.0 * c5 + c8) - (c1 + 2.0 * c4 + c6); - - // Save some arithmetic operations to ensure PS2 compatibility - c1 += c3; - c6 += c8; - // vertical gradient - // [ -1, - 2, -1 ] - // [ 0, 0, 0 ] - // [ 1, 2, 1 ] - vec3 delta2 = (c6 + 2.0 * c7 ) - (c1 + 2.0 * c2 ); - vec3 checkshc = sqrt(delta1 * delta1 + delta2 * delta2); - // computation - if (checkshc.x > S_Edge.x || checkshc.y > S_Edge.y || checkshc.z > S_Edge.z) { - // if we have an edge, use sharpen - corrected = color * S_val0 - (c1 + c2 + c4 + c5 + c6 + c7 ) * Sharpen_val1; - } - return corrected; -} -#endif -#if(GAMMA==1) -vec3 processGAMMA(vec3 color){ - vec3 gam=vec3(pow(color.r,1.0/abs(correction)),pow(color.g,1.0/abs(correction)),pow(color.b,1.0/abs(correction))); - return gam; -} -#endif -#if(SHADEBOOST==1) -vec3 processSHADEBOOST(vec3 color){ - float sat = saturation; - float brt = brightness; - float con = contrast; - - // Increase or decrease theese values to adjust r, g and b color channels seperately - float AvgLumR = red; - float AvgLumG = green; - float AvgLumB = blue; - - //==========================presets - if(SEPIA==1) { - sat = 0.11; - brt = 0.87; - con = 1.20; - AvgLumR = 1.19930; - AvgLumG = 0.960; - AvgLumB = 0.6754; - } - if(GRAYSCALE==1) { - sat = 0.0; - brt = 1.0; - con = 1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(NEGATIVE==1) { - sat = 1.0; - brt = 1.0; - con = -1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(PSPCOLORS==1) { - sat = 1.0; - brt = 1.0; - con = 1.0; - AvgLumR = 0.9593; - AvgLumG = 1.0739; - AvgLumB = 1.4604; - } - //========================== - const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); - - vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); - vec3 conRGB = vec3(0.5, 0.5, 0.5); - vec3 brtColor = color.rgb * brt; - vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c - vec3 satColor = mix(intensity, brtColor, sat); - vec3 conColor = mix(conRGB, satColor, con); - vec3 mixColor = AvgLumin * conColor; - color.rgb = mixColor; - if(rgbRBG==1) { - color.rgb = color.rbg; - } - if(rgbBGR==1) { - color.rgb = color.bgr; - } - if(rgbBRG==1) { - color.rgb = color.brg; - } - if(rgbGRB==1) { - color.rgb = color.grb; - } - if(rgbGBR==1) { - color.rgb = color.gbr; - } - return color; -} -#endif -#if(COLORED==1) -float overlay(float base, float blend) { - float result = 0.0; - if( base < 0.5 ) { - result = 2.0 * base * blend; - } else { - result = 1.0 - (1.0 - 2.0*(base-0.5)) * (1.0-blend); - } - return result; -} -vec3 processCOLORED(vec3 color){ - vec3 blur = color * 1.22520613262190495; - vec3 newcolor = vec3(overlay(color.r,blur.r), - overlay(color.g,blur.g), - overlay(color.b,blur.b)); - color = mix(color, newcolor, Cpower); - return color; -} -#endif -#if(TEST==1) -vec3 processTEST(vec3 color){ - if(v_texcoord0.x<0.5) { - color.xyz=color.xyz; - } else { - color.xyz=texture2D(sampler0, v_texcoord0.xy).xyz; - } - return color; -} -#endif -#if(TESTANIM==1) -vec3 processTESTANIM(vec3 color){ - float anim=(sin(u_time.x*testAspeed)+0.9)*0.55; - if(v_texcoord0.x tolerance || diff.g > tolerance || diff.b > tolerance; //workaround for the above - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Frost==1) -float rand(vec2 co){ - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); -} -vec3 processFrost(vec3 color) { - float tolerance = fTol/1638.4; - for (int i=1;i<5;i++) { - float p = u_pixelDelta.x * float(i) / rand(vec2(rand(v_texcoord0.xy),rand(v_texcoord0.xy))); - vec3 c1 = texture2D(sampler0,v_texcoord0.xy + vec2( p, p)).xyz; - vec3 c1b = texture2D(sampler0,v_texcoord0.xy + vec2( -p, -p)).xyz; - vec3 c2 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, p)).xyz; - vec3 c2b = texture2D(sampler0,v_texcoord0.xy + vec2( p, -p)).xyz; - vec3 c3 = texture2D(sampler0,v_texcoord0.xy + vec2( p,0.0)).xyz; - vec3 c3b = texture2D(sampler0,v_texcoord0.xy + vec2( -p,0.0)).xyz; - vec3 c4 = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, -p)).xyz; - vec3 c4b = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, p)).xyz; - vec3 avg; - if(fSimple==1) { - avg = (c1 + c2 + c3 + c4)/4.0; - } else { - avg = (c1 + c2 + c3 + c4 + c1b + c2b + c3b + c4b)/8.0; - } - vec3 diff = abs(color - avg); - bool a = diff.r > tolerance || diff.g > tolerance || diff.b > tolerance; - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Guest_AA4o==1) -const vec3 dt = vec3(1.0,1.0,1.0); -vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale; -vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale; -vec3 texture2d (vec2 texcoord) { - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2); -} -vec3 texture2dd (vec2 texcoord) { - - vec3 c11 = texture2D(sampler0, texcoord ).xyz; - vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz; - vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz; - vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz; - vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz; - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float d1=dot(abs(c00-c22),dt)+0.001; - float d2=dot(abs(c20-c02),dt)+0.001; - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2)); - - return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2)); -} -vec3 processGuestAA4o() { - // Calculating texel coordinates - - vec2 size = vec2(480.0,272.0)*scale; - vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scale; - - vec2 OGL2Pos = v_texcoord0 * size; - vec2 fp = fract(OGL2Pos); - vec2 dx = vec2(inv_size.x,0.0); - vec2 dy = vec2(0.0, inv_size.y); - vec2 g1 = vec2(inv_size.x,inv_size.y); - vec2 g2 = vec2(-inv_size.x,inv_size.y); - - vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size; - - // Reading the texels - vec3 C0 = texture2d(pC4 - g1); - vec3 C1 = texture2d(pC4 - dy); - vec3 C2 = texture2d(pC4 - g2); - vec3 C3 = texture2d(pC4 - dx); - vec3 C4 = texture2d(pC4 ); - vec3 C5 = texture2d(pC4 + dx); - vec3 C6 = texture2d(pC4 + g2); - vec3 C7 = texture2d(pC4 + dy); - vec3 C8 = texture2d(pC4 + g1); - - vec3 ul, ur, dl, dr; - float m1, m2; - - m1 = dot(abs(C0-C4),dt)+0.001; - m2 = dot(abs(C1-C3),dt)+0.001; - ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2); - - m1 = dot(abs(C1-C5),dt)+0.001; - m2 = dot(abs(C2-C4),dt)+0.001; - ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2); - - m1 = dot(abs(C3-C7),dt)+0.001; - m2 = dot(abs(C6-C4),dt)+0.001; - dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2); - - m1 = dot(abs(C4-C8),dt)+0.001; - m2 = dot(abs(C5-C7),dt)+0.001; - dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2); - - vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y))); - - if(filtro==1){ - vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)); - - inv_size = vec2(2.0/480.0,2.0/272.0)/scale;; - - dx = vec2(inv_size.x,0.0); - dy = vec2(0.0,inv_size.y); - g1 = vec2( inv_size.x,inv_size.y); - g2 = vec2(-inv_size.x,inv_size.y); - pC4 = v_texcoord0; - - C0 = texture2dd(pC4-g1); - C1 = texture2dd(pC4-dy); - C2 = texture2dd(pC4-g2); - C3 = texture2dd(pC4-dx); - C4 = texture2dd(pC4 ); - C5 = texture2dd(pC4+dx); - C6 = texture2dd(pC4+g2); - C7 = texture2dd(pC4+dy); - C8 = texture2dd(pC4+g1); - - vec3 mn1 = min(min(C0,C1),C2); - vec3 mn2 = min(min(C3,C4),C5); - vec3 mn3 = min(min(C6,C7),C8); - vec3 mx1 = max(max(C0,C1),C2); - vec3 mx2 = max(max(C3,C4),C5); - vec3 mx3 = max(max(C6,C7),C8); - - mn1 = min(min(mn1,mn2),mn3); - mx1 = max(max(mx1,mx2),mx3); - - vec3 dif1 = abs(c11-mn1) + 0.0001*dt; - vec3 dif2 = abs(c11-mx1) + 0.0001*dt; - - float filterparam = 2.0; - - dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam)); - dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam)); - - c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x); - c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y); - c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z); - - result = c11; - } - - return result; -} -#endif -#if(Bilateral==1) - - -#define SIGMA 10.0 -#define BSIGMA 0.1 -#define MSIZE 15 -float normpdf(float x, float sigma) { - return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma; -} - -float normpdf3(vec3 v, float sigma) { - return 0.39894*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma; -} - -vec3 processBilateral(vec3 color) { - const int kSize = (MSIZE-1)/2; - float kernel[MSIZE]; - vec3 final_colour; - - // Create the 1-D kernel - float Zxx = 0.0; - for (int j = 0; j <= kSize; ++j) { - kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA); - } - // sigma 10.0, MSIZE 15 - //someone mentioned performance increase with precompiled kernel, but really don't see that - //const float kernel[MSIZE] = float[MSIZE](0.031225216, 0.033322271, 0.035206333, 0.036826804, 0.038138565, 0.039104044, 0.039695028, 0.039894000, 0.039695028, 0.039104044, 0.038138565, 0.036826804, 0.035206333, 0.033322271, 0.031225216); - vec3 cc; - float factorNB; - float bZ = 1.0/normpdf(0.0, BSIGMA); - // Read out the texels - for (int i=-kSize; i <= kSize; ++i) { - for (int j=-kSize; j <= kSize; ++j) { - cc = texture2D(sampler0, v_texcoord0.xy+vec2(float(i)*u_pixelDelta.x,float(j)*u_pixelDelta.x)).rgb; - factorNB = normpdf3(cc-color, BSIGMA)*bZ*kernel[kSize+j]*kernel[kSize+i]; - Zxx += factorNB; - final_colour += factorNB*cc; - } - } - return final_colour/Zxx; -} -#endif -void main() { - vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; - #if(FXAA==1) - color=processFXAA(color); - #endif - #if(GAUSS_SQ==1) - color=processGAUSS_SQ(color); - #endif - #if(GAUSS_S==1) - color=processGAUSS_S(color); - #endif - #if(Guest_AA4o==1) - color=processGuestAA4o(); - #endif - #if(SHARPEN==1) - color=processSHARPEN(color); - #endif - #if(S_COM_V2==1) - color=processS_COM_V2(color); - #endif - #if(xHQ==1) - color=processxHQ(color); - #endif - #if(xBRAccuracy==1 || xBR==1) - color=processxBR(color); - #endif - #if(Deband==1) - color=processDeband(color); - #endif - #if(Frost==1) - color=processFrost(color); - #endif - #if(Bilateral==1) - color=processBilateral(color); - #endif - #if(NATURALC==1) - color=processNATURALC(color); - #endif - #if(ACARTOON==1) - color=processACARTOON(color); - #endif - #if(BLOOM==1) - vec3 colorB=color; - int hatsu = 0; - #if(MIKU==1) - hatsu = 1; - color=processMIKU(color); - #endif - color=processBLOOM(color, colorB, hatsu); - #endif - #if(COLORED==1) - color=processCOLORED(color); - #endif - #if(SHADEBOOST==1) - color = processSHADEBOOST(color); - #endif - #if(GAMMA==1) - color = processGAMMA(color); - #endif - #if(SCANLINES==1) - color = processSCANLINES(color); - #endif - #if(LCD3x==1) - color = processLCD3x(color); - #endif - #if(VIGNETTE==1) - color = processVIGNETTE(color); - #endif - #if(TEST==1) - color = processTEST(color); - #endif - #if(TESTANIM==1) - color = processTESTANIM(color); - #endif - gl_FragColor.xyz=color; - gl_FragColor.a = 1.0; -} diff --git a/assets/shaders/Luna2M.fsh b/assets/shaders/Luna2M.fsh deleted file mode 100644 index 0244b95d3e..0000000000 --- a/assets/shaders/Luna2M.fsh +++ /dev/null @@ -1,1376 +0,0 @@ -//Note : Recommend to use PPSSPP v1.1.1-183-gb411fc0 or newer for full functionality, there were some bugs in earlier versions. -//Note2 : Upscaling, smoothing and sharpening filters are not set to be mixed between each other since the results are pointless(they counter each other). -// Only last one applies, so pick just one of them, mess around with it's settings and add other effects as needed. -//====================================================================================================================================================================== -//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res -//================ -#define FXAA 0 //ON:1/OFF:0 /default FXAA, orginal info below -//================ -#define GAUSS_SQ 0 //ON:1/OFF:0 /full square gauss filtering -#define Gsmoothing 3.5 //Default: 3.5 /increase for smoother(blurry) graphics -//================ -#define GAUSS_S 0 //ON:1/OFF:0 /simple gauss filtering by Bigpet, slightly different from above /you can find standalone in https://github.com/hrydgard/ppsspp/issues/7242 -//================ -#define Guest_AA4o 0 //ON:1/OFF:0 /alternative to FXAA /taken from http://forums.ppsspp.org/showthread.php?tid=6594&pid=124441#pid124441 -#define scale 7.0 //Default: 7.0 / 4.0 -> smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) -#define filtro 0 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier -//================ -//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing -//================ -#define SHARPEN 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default -#define value 7.5 //Default: 7.5 /higher = more visible effect -//================ -#define S_COM_V2 0 //Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate -#define S_val0 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect -//================ -//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" - //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically -//================ -#define xBR 1 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below -#define VariantB 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details -#define Variantx2 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR -//================ -#define xBRAccuracy 0 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below -#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding -#define CornerB 0 //ON:1/OFF:0 / activate only one -#define CornerD 0 //ON:1/OFF:0 -// CornerC //used as default if no other ones are defined -//================ -#define xHQ 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution -#define scaleoffset 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness -//================ -//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one -//================ -#define Deband 0 //ON:1/OFF:0 /Blurs -#define DeTol 16.0 //Default: 16.0 /tolerance, too high will look glitchy -//================ -#define Frost 0 //ON:1/OFF:0 /Dithering ~ adds noise -#define fTol 32.0 //Default: 32.0 /tolerance, too high will look glitchy -#define fSimple 1 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version -//================ -#define Bilateral 0 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH -//================ -//OTHER FILTERS: //Most effects from here on can be fully mixed without loosing previous effects. Exceptions: Natural Colors, Advanced Cartoon -//================ -#define BLOOM 0 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ -#define MIKU 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress -#define samples 3 //Default: 4 /higher = more glow, worse performance -#define quality 0.22 //Default: 0.18 /lower = smaller glow, better quality -#define Bpower 1.0 //Default: 1.0 /amount of bloom mixed -//================ -#define COLORED 0 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o -#define Cpower 0.5 //Default: 0.5 /strenght of the effect -//================ -#define ACARTOON 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack -#define th 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 -#define bb 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 -#define pp 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 -#define acpower 0.5 //Default:0.5 / higher = more effect, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -//================ -#define SHADEBOOST 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 -#define saturation 1.0 //Default: 1.0 //negative will look like inverted colors shader -#define brightness 1.0 //Default: 1.0 -#define contrast 1.0 //Default: 1.0 //negative will be... well negative;p -#define red 1.0 //Default: 1.0 -#define green 1.0 //Default: 1.0 -#define blue 1.0 //Default: 1.0 -//Shadeboost presets: //Shadeboost must be activated, presets override options above -#define SEPIA 0 //Moody coolors:) -#define GRAYSCALE 0 //Just for lols? -#define NEGATIVE 0 //As above -#define PSPCOLORS 0 //Makes the colors as on older PSP screens(colder) -//Simple color swap: //Shadeboost must be activated -#define rgbRBG 0 //green <-> blue -#define rgbBGR 0 //red <-> blue -#define rgbBRG 0 //red -> green -> blue -> red -#define rgbGRB 0 //red <-> green -#define rgbGBR 0 //red -> blue -> green -> red -//^All presets and color swap are simple switch ON:1/OFF:0, -//================ -#define GAMMA 0 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 -#define correction 0.85 //Default: 1.0 -//================ -#define SCANLINES 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) -#define SLsize 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high -#define SLcolor 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation -#define SLpower 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, -#define SLV 0 //ON:1/OFF:0 /vertical scanlines -#define noGradient 0 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line -//================ -#define VIGNETTE 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings -#define vsize 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values -#define VIpos 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) -#define deVi 0 //ON:1/OFF:0 /reverse vignette -//================ -#define TEST 0 //ON:1/OFF:0 /test mode, applies shaders on half of the screen for easy result comparison and tweaking -#define TESTANIM 0 //ON:1/OFF:0 /as above, animation slides shader from left to right and back /use only one -#define testAspeed 1.0 //animation speed -//================ -//Approximate performance hit -//Free: TEST, TESTANIM -//Light: SHARPEN, COLORED, SHADEBOOST, GAMMA, SCANLINES, VIGNETTE, BLOOM(<= 2 samples) -//Medium: FXAA, GAUSS_SQ, GAUSS_S, S_COM_V2, xHQ, Deband, Frost(fSimple), ACARTOON, BLOOM(== 3 samples) -//Heavy: Guest_AA4o, xBR, Frost, BLOOM(>= 4 samples), xBRAccuracy -//Extremely Heavy: Guest_AA4o(filtro), BLOOM(>= 8 samples), Bilateral -//====================================================================================================================================================================== -//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), -// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken -// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), -// other credits mentioned earlier, any more info / required licenses can be found below. - - - - -/* - FXAA shader, GLSL code adapted from: - http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA - Whitepaper describing the technique: - http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf -*/ - -/* - AA shader 4.o / AA shader 4.o - filtro - - Copyright (C) 2014 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - Hyllian's 5xBR v3.5a Shader - - Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from: - http://forums.ngemu.com/showthread.php?t=76098 - - by guest(r) (guest.r@gmail.com) - License: GNU-GPL - - Shader notes: looks better with sprite games -*/ - -/* - Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) - - Copyright (C) 2011-2015 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. - - Incorporates some of the ideas from SABR shader. Thanks to Joshua Street. -*/ - -/* - Advanced Cartoon shader - - Copyright (C) 2006 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#ifdef GL_ES -precision mediump float; -precision mediump int; -#endif - -uniform sampler2D sampler0; -uniform vec4 u_time; - - -//=========== -// The inverse of the texture dimensions along X and Y -uniform vec2 u_texelDelta; -uniform vec2 u_pixelDelta; -varying vec2 v_texcoord0; - -//=========== -//=========== -#if(FXAA==1) -vec3 processFXAA(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float FXAA_SPAN_MAX = 8.0; - float FXAA_REDUCE_MUL = 1.0/8.0; - float FXAA_REDUCE_MIN = (1.0/128.0); - - vec3 rgbNW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, -1.0) * u_texelDelta).xyz; - //#define Pass_Diffuse(v2TexCoord) texture2D(sampler0, v2TexCoord).xyz - //vec3 rgbNW = Pass_Diffuse(v2TexCoord + vec2(-u_texelDelta.x, -u_texelDelta.y)).xyz; - vec3 rgbNE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, -1.0) * u_texelDelta).xyz; - vec3 rgbSW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbSE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbM = texture2D(sampler0, v_texcoord0).xyz; - - vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW, luma); - float lumaNE = dot(rgbNE, luma); - float lumaSW = dot(rgbSW, luma); - float lumaSE = dot(rgbSE, luma); - float lumaM = dot( rgbM, luma); - - float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); - float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); - - vec2 dir; - dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); - dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); - - float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); - - float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); - - dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), - max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta; - - vec3 rgbA = (1.0/2.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (1.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (2.0/3.0 - 0.5)).xyz); - vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (0.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (3.0/3.0 - 0.5)).xyz); - float lumaB = dot(rgbB, luma); - - if((lumaB < lumaMin) || (lumaB > lumaMax)){ - color=rgbA; - } else { - color=rgbB; - } - return color; -} -#endif -#if(GAUSS_SQ==1) -vec3 processGAUSS_SQ(vec3 color){ - float GAUSS_KERNEL_SIZE = 5.0; - //indices - // 00 01 02 03 04 - // 05 06 07 08 09 - // 10 11 12 13 14 - // 15 16 17 18 19 - // 20 21 22 23 24 - - //filter strength, rather smooth - // 01 04 07 04 01 - // 04 16 26 16 04 - // 07 26 41 26 07 - // 04 16 26 16 04 - // 01 04 07 04 01 - - vec2 offset = u_pixelDelta*Gsmoothing/GAUSS_KERNEL_SIZE; - - vec3 cGauss0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-2.0)).xyz; - vec3 cGauss1 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-2.0)).xyz; - vec3 cGauss2 = 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz; - vec3 cGauss3 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-2.0)).xyz; - vec3 cGauss4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-2.0)).xyz; - vec3 cGauss5 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-1.0)).xyz; - vec3 cGauss6 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz; - vec3 cGauss7 = 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz; - vec3 cGauss8 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz; - vec3 cGauss9 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-1.0)).xyz; - vec3 cGauss10= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz; - vec3 cGauss11= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz; - vec3 cGauss12= 41.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz; - vec3 cGauss13= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz; - vec3 cGauss14= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz; - vec3 cGauss15= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 1.0)).xyz; - vec3 cGauss16= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz; - vec3 cGauss17= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz; - vec3 cGauss18= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz; - vec3 cGauss19= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 1.0)).xyz; - vec3 cGauss20= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 2.0)).xyz; - vec3 cGauss21= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 2.0)).xyz; - vec3 cGauss22= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz; - vec3 cGauss23= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 2.0)).xyz; - vec3 cGauss24= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 2.0)).xyz; - - color.xyz = cGauss0 + cGauss1 + cGauss2 + cGauss3 + cGauss4 + cGauss5 + cGauss6 + cGauss7 + cGauss8 + cGauss9 + cGauss10 + cGauss11 + cGauss12 + cGauss13 + cGauss14 + cGauss15 + cGauss16 + cGauss17 + cGauss18 + cGauss19 + cGauss20 + cGauss21 + cGauss22 + cGauss23 + cGauss24; - color.xyz = color.xyz / 273.0; - return color; -} -#endif -#if(GAUSS_S==1) -vec3 processGAUSS_S(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float GAUSSS_SPAN_MAX = 1.5; - - //just a variable to describe the maximu - float GAUSSS_KERNEL_SIZE = 5.0; - //indices - // XX XX 00 XX XX - // XX 01 02 03 XX - // 04 05 06 07 08 - // XX 09 10 11 XX - // XX XX 12 XX XX - - //filter strength, rather smooth - // XX XX 01 XX XX - // XX 03 08 03 XX - // 01 08 10 08 01 - // XX 03 08 03 XX - // XX XX 01 XX XX - - vec2 offsetS = u_pixelDelta*GAUSSS_SPAN_MAX/GAUSSS_KERNEL_SIZE; - - vec3 cGaussS0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-2.0)).xyz; - vec3 cGaussS1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0,-1.0)).xyz; - vec3 cGaussS2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-1.0)).xyz; - vec3 cGaussS3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0,-1.0)).xyz; - vec3 cGaussS4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-2.0, 0.0)).xyz; - vec3 cGaussS5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 0.0)).xyz; - vec3 cGaussS6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 0.0)).xyz; - vec3 cGaussS7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 0.0)).xyz; - vec3 cGaussS8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 2.0, 0.0)).xyz; - vec3 cGaussS9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 1.0)).xyz; - vec3 cGaussS10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 1.0)).xyz; - vec3 cGaussS11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 1.0)).xyz; - vec3 cGaussS12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 2.0)).xyz; - - color = cGaussS0 + cGaussS1 + cGaussS2 + cGaussS3 + cGaussS4 + cGaussS5 + cGaussS6 + cGaussS7 + cGaussS8 + cGaussS9 + cGaussS10 + cGaussS11 + cGaussS12; - color = color / 58.0; - return color; -} -#endif -#if(xBRAccuracy==1 || xBR==1) - -#if(xBRAccuracy==1) - -const float XBR_SCALE = 3.0; -const float lv2_cf = 2.0; -const vec3 rgbw = vec3(14.352, 28.176, 5.472); -const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); -const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25); - -#else -const float coef = 2.0; -const vec3 rgbw = vec3(16.163, 23.351, 8.4772); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); - -#endif - -vec4 df(vec4 A, vec4 B) { - return abs(A-B); -} -#if(xBRAccuracy==1) - -// Compare two vectors and return their components are different. -vec4 diff(vec4 A, vec4 B) { - return vec4(notEqual(A, B)); -} - -// Determine if two vector components are equal based on a threshold. -vec4 eq(vec4 A, vec4 B) { - return (step(df(A, B), eq_threshold)); -} - -// Determine if two vector components are NOT equal based on a threshold. -vec4 neq(vec4 A, vec4 B) { - return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B)); -} -float c_df(vec3 c1, vec3 c2) { - vec3 df = abs(c1 - c2); - return df.r + df.g + df.b; -} -#else -bvec4 _and_(bvec4 A, bvec4 B) { - return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); -} -bvec4 _or_(bvec4 A, bvec4 B) { - return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); -} -bvec4 close(vec4 A, vec4 B) { - return (lessThan(df(A, B), vec4(15.0))); -} -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) { - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} -#endif -vec3 processxBR(vec3 color){ - vec2 pS = 1.0 / u_texelDelta.xy; - vec2 fp = fract(v_texcoord0.xy*pS.xy); - vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy; - vec2 dx = vec2(u_texelDelta.x,0.0); - vec2 dy = vec2(0.0,u_texelDelta.y); - vec2 y2 = dy + dy; vec2 x2 = dx + dx; - -#if(xBRAccuracy==1) - // px = pixel, edr = edge detection rule - vec4 edri, edr, edr_l, edr_u, px; - vec4 irlv0, irlv1, irlv2l, irlv2u; - vec4 fx, fx_l, fx_u; // inequations of straight lines. - - vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_u = delta_l.yxwz; -#else - bvec4 edr, edr_left, edr_up, px; // px = pixel, edr = edge detection rule - bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up; - bvec4 nc; // new_color - bvec4 fx, fx_left, fx_up; // inequations of straight lines. -#endif - - vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy).xyz; - vec3 B = texture2D(sampler0, TexCoord_0 -dy).xyz; - vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy).xyz; - vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz; - vec3 E = texture2D(sampler0, TexCoord_0 ).xyz; - vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz; - vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy).xyz; - vec3 H = texture2D(sampler0, TexCoord_0 +dy).xyz; - vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy).xyz; - vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz; - vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz; - vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz; - vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz; - vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz; - vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz; - vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz; - vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz; - vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz; - vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz; - vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz; - vec3 F4 = texture2D(sampler0, TexCoord_0 +x2 ).xyz; - - vec4 b = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw)); - vec4 c = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw)); - vec4 d = b.yzwx; - vec4 e = vec4(dot(E,rgbw)); - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw)); - vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw)); - vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw)); - vec4 f4 = h5.yzwx; - -#if(xBRAccuracy==1) - // These inequations define the line below which interpolation occurs. - fx = (Ao*fp.y+Bo*fp.x); - fx_l = (Ax*fp.y+Bx*fp.x); - fx_u = (Ay*fp.y+By*fp.x); - - irlv1 = irlv0 = diff(e,f) * diff(e,h); - -#if(CornerA==0) // A takes priority skipping other corners - #define SMOOTH_TIPS - // Corner C also default if no other ones used - irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) ); - int select1 = 0; -#if(CornerB==1) // Corner B - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) ); - select1 = 1; -#endif -#if(CornerD==1) // Corner D - if (select1==0){ - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0))); - } -#endif -#endif - - irlv2l = diff(e,g) * diff(d,g); - irlv2u = diff(e,c) * diff(b,c); - - vec4 fx45i = clamp((fx + delta -Co - Ci)/(2.0*delta ), 0.0, 1.0); - vec4 fx45 = clamp((fx + delta -Co )/(2.0*delta ), 0.0, 1.0); - vec4 fx30 = clamp((fx_l + delta_l -Cx )/(2.0*delta_l), 0.0, 1.0); - vec4 fx60 = clamp((fx_u + delta_u -Cy )/(2.0*delta_u), 0.0, 1.0); - - vec4 w1, w2; - w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw); - w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw); - w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw); - w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw); - - w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw); - w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw); - w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw); - w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw); - - edri = step(w1, w2) * irlv0; - edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1); - - w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw); - w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw); - - edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr; - edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr; - - fx45 = edr * fx45; - fx30 = edr_l * fx30; - fx60 = edr_u * fx60; - fx45i = edri * fx45i; - - w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw); - w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw); - - px = step(w1, w2); - -#ifdef SMOOTH_TIPS - vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i)); -#else - vec4 maximos = max(max(fx30, fx60), fx45); -#endif - - vec3 res1 = E; - res1 = mix(res1, mix(H, F, px.x), maximos.x); - res1 = mix(res1, mix(B, D, px.z), maximos.z); - - vec3 res2 = E; - res2 = mix(res2, mix(F, B, px.y), maximos.y); - res2 = mix(res2, mix(D, H, px.w), maximos.w); - - vec3 res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2))); -#else - // These inequations define the line below which interpolation occurs. - fx = greaterThan(Ao*fp.y+Bo*fp.x,Co); - fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx); - fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy); - - if (VariantB==1){ - bvec4 t1 = _and_( notEqual(e, f), notEqual(e, h) ); - bvec4 t2 = _and_( not(close(f, b)), not(close(h, d)) ); - bvec4 t3 = _and_( _and_( close(e, i), not(close(f, i4)) ), not(close(h, i5)) ); - bvec4 t4 = _or_( close(e, g), close(e, c) ); - interp_restriction_lv1 = _and_( t1, _or_( _or_(t2, t3), t4 ) ); - } else { - interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h))); - } - interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g))); - interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c))); - - edr = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1)); - edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left)); - edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up)); - - nc.x = ( edr.x && (fx.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) ); - nc.y = ( edr.y && (fx.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) ); - nc.z = ( edr.z && (fx.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) ); - nc.w = ( edr.w && (fx.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) ); - - px = lessThanEqual(df(e,f),df(e,h)); - - vec3 res; - if (Variantx2 == 1) { - vec3 E0 = E.xyz; - vec3 E1 = E.xyz; - vec3 E2 = E.xyz; - vec3 E3 = E.xyz; - vec3 P[4]; - P[0] = px.x ? F : H; - P[1] = px.y ? B : F; - P[2] = px.z ? D : B; - P[3] = px.w ? H : D; - if (edr.x) { - if (edr_left.x && edr_up.x) { - E3 = mix(E3 , P[0], 0.833333); - E2 = mix(E2 , P[0], 0.25); - E1 = mix(E1 , P[0], 0.25); - } else if (edr_left.x) { - E3 = mix(E3 , P[0], 0.75); - E2 = mix(E2 , P[0], 0.25); - } else if (edr_up.x) { - E3 = mix(E3 , P[0], 0.75); - E1 = mix(E1 , P[0], 0.25); - } else { - E3 = mix(E3 , P[0], 0.5); - } - } - if (edr.y) { - if (edr_left.y && edr_up.y) { - E1 = mix(E1 , P[1], 0.833333); - E3 = mix(E3 , P[1], 0.25); - E0 = mix(E0 , P[1], 0.25); - } else if (edr_left.y) { - E1 = mix(E1 , P[1], 0.75); - E3 = mix(E3 , P[1], 0.25); - } else if (edr_up.y) { - E1 = mix(E1 , P[1], 0.75); - E0 = mix(E0 , P[1], 0.25); - } else { - E1 = mix(E1 , P[1], 0.5); - } - } - if (edr.z) { - if (edr_left.z && edr_up.z) { - E0 = mix(E0 , P[2], 0.833333); - E1 = mix(E1 , P[2], 0.25); - E2 = mix(E2 , P[2], 0.25); - } else if (edr_left.z) { - E0 = mix(E0 , P[2], 0.75); - E1 = mix(E1 , P[2], 0.25); - } else if (edr_up.z) { - E0 = mix(E0 , P[2], 0.75); - E2 = mix(E2 , P[2], 0.25); - } else { - E0 = mix(E0 , P[2], 0.5); - } - } - if (edr.w) { - if (edr_left.w && edr_up.w) { - E2 = mix(E2 , P[3], 0.833333); - E0 = mix(E0 , P[3], 0.25); - E3 = mix(E3 , P[3], 0.25); - } else if (edr_left.w) { - E2 = mix(E2 , P[3], 0.75); - E0 = mix(E0 , P[3], 0.25); - } else if (edr_up.w) { - E2 = mix(E2 , P[3], 0.75); - E3 = mix(E3 , P[3], 0.25); - } else { - E2 = mix(E2 , P[3], 0.5); - } - } - res = (fp.x < 0.50) ? (fp.y < 0.50 ? E0 : E2) : (fp.y < 0.50 ? E1: E3); - } else { - res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E; - } -#endif - return res; -} -#endif -#if(BLOOM==1) -vec3 processBLOOM(vec3 color, vec3 colorB, int hatsu){ - #define factor 0.002 //Default: 0.002 /just an extra tweak for the bloom slightly higher values might look better in some cases, but too much can cause artifacts - vec4 sum = vec4(0); - int jb; - int diffx = samples - 1; - int ib; - int diffy = samples; - vec3 bloom; - for( ib= -diffy ;ib < diffy; ib++) { - for (jb = -diffx; jb < diffx; jb++) { - sum += texture2D(sampler0, v_texcoord0.xy + vec2(jb, ib)*factor) * quality; - } - } - if(color.r < 0.3 && color.g < 0.3 && color.b < 0.3) { - bloom = sum.xyz*sum.xyz*0.012 + color; - } else { - if(color.r < 0.5 && color.g < 0.5 && color.b < 0.5) { - bloom = sum.xyz*sum.xyz*0.009 + color; - } else { - bloom = sum.xyz*sum.xyz*0.0075 + color; - } - } - color = mix(color, bloom, Bpower); - if(hatsu==1) { - color = mix(colorB, color, 0.5); - } - return color; -} -vec3 processMIKU(vec3 color){ - vec3 mmm = vec3(0.1, 0.1, 0.1); - color = mix(color,mmm, 0.9); - return color; -} -#endif -#if(SCANLINES==1) -vec3 processSCANLINES(vec3 color){ - int vscan = SLV; - vec3 colorSL=color*SLcolor; - if(vscan==0){ - float rey = (1.0/float(SLsize)/u_pixelDelta.y); - float posSy = v_texcoord0.y*rey; - float lineSy = mod(posSy,2.0); - if (noGradient==1) { - bool clSy = lineSy<1.0; - lineSy = mix(1.0,0.0,float(clSy)); - } - color=color-lineSy; - } else { - float rex = (1.0/float(SLsize)/u_pixelDelta.x); - float posSx = v_texcoord0.x*(rex/1.0); - float lineSx = mod(posSx,2.0); - if (noGradient==1) { - bool clSx = lineSx<1.0; - lineSx = mix(1.0,0.0,float(clSx)); - } - color=color-lineSx; - } - if (noGradient==1) { - color=mix(color,clamp(colorSL,0.0,1.0),SLpower); - } else { - color=mix(color,colorSL,SLpower); - } - return color; -} -#endif -#if(SHARPEN==1) -vec3 processSHARPEN(vec3 color){ - color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*value; - color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*value; - return color; -} -#endif -#if(S_COM_V2==1) -vec3 processS_COM_V2(vec3 color){ - float width = (v_texcoord0.x); - float height = (v_texcoord0.y); - float px = (u_texelDelta.x); - float py = (u_texelDelta.y); - float mean = 0.6; - float dx = (mean * px); - float dy = (mean * py); - float CoefBlur = 2.0; - float CoefOrig = (1.0 + CoefBlur); - float Sharpen_val1 = ((S_val0 - 1.0) / 8.0); - vec3 S_Edge = vec3(0.2,0.2,0.2); - // get original pixel / color - - // compute blurred image (gaussian filter) - vec3 c1 = texture2D(sampler0, v_texcoord0 + vec2(-dx, -dy)).xyz; - vec3 c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -dy)).xyz; - vec3 c3 = texture2D(sampler0, v_texcoord0 + vec2( dx, -dy)).xyz; - vec3 c4 = texture2D(sampler0, v_texcoord0 + vec2(-dx, 0)).xyz; - vec3 c5 = texture2D(sampler0, v_texcoord0 + vec2( dx, 0)).xyz; - vec3 c6 = texture2D(sampler0, v_texcoord0 + vec2(-dx, dy)).xyz; - vec3 c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, dy)).xyz; - vec3 c8 = texture2D(sampler0, v_texcoord0 + vec2( dx, dy)).xyz; - - // gaussian filter - // [ 1, 2, 1 ] - // [ 2, 4, 2 ] - // [ 1, 2, 1 ] - // to normalize the values, we need to divide by the coeff sum - // 1 / (1+2+1+2+4+2+1+2+1) = 1 / 16 = 0.0625 - vec3 flou = (c1 + c3 + c6 + c8 + 2.0 * (c2 + c4 + c5 + c7) + 4.0 * color) * 0.0625; - - // substract blurred image from original image - vec3 corrected = CoefOrig * color - CoefBlur * flou; - - // edge detection - // Get neighbor points - // [ c1, c2, c3 ] - // [ c4, color, c5 ] - // [ c6, c7, c8 ] - c1 = texture2D(sampler0, v_texcoord0 + vec2(-px, -py)).xyz; - c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -py)).xyz; - c3 = texture2D(sampler0, v_texcoord0 + vec2( px, -py)).xyz; - c4 = texture2D(sampler0, v_texcoord0 + vec2(-px, 0)).xyz; - c5 = texture2D(sampler0, v_texcoord0 + vec2( px, 0)).xyz; - c6 = texture2D(sampler0, v_texcoord0 + vec2(-px, py)).xyz; - c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, py)).xyz; - c8 = texture2D(sampler0, v_texcoord0 + vec2( px, py)).xyz; - - // using Sobel filter - // horizontal gradient - // [ -1, 0, 1 ] - // [ -2, 0, 2 ] - // [ -1, 0, 1 ] - vec3 delta1 = (c3 + 2.0 * c5 + c8) - (c1 + 2.0 * c4 + c6); - - // Save some arithmetic operations to ensure PS2 compatibility - c1 += c3; - c6 += c8; - // vertical gradient - // [ -1, - 2, -1 ] - // [ 0, 0, 0 ] - // [ 1, 2, 1 ] - vec3 delta2 = (c6 + 2.0 * c7 ) - (c1 + 2.0 * c2 ); - vec3 checkshc = sqrt(delta1 * delta1 + delta2 * delta2); - // computation - if (checkshc.x > S_Edge.x || checkshc.y > S_Edge.y || checkshc.z > S_Edge.z) { - // if we have an edge, use sharpen - corrected = color * S_val0 - (c1 + c2 + c4 + c5 + c6 + c7 ) * Sharpen_val1; - } - return corrected; -} -#endif -#if(GAMMA==1) -vec3 processGAMMA(vec3 color){ - vec3 gam=vec3(pow(color.r,1.0/abs(correction)),pow(color.g,1.0/abs(correction)),pow(color.b,1.0/abs(correction))); - return gam; -} -#endif -#if(SHADEBOOST==1) -vec3 processSHADEBOOST(vec3 color){ - float sat = saturation; - float brt = brightness; - float con = contrast; - - // Increase or decrease theese values to adjust r, g and b color channels seperately - float AvgLumR = red; - float AvgLumG = green; - float AvgLumB = blue; - - //==========================presets - if(SEPIA==1) { - sat = 0.11; - brt = 0.87; - con = 1.20; - AvgLumR = 1.19930; - AvgLumG = 0.960; - AvgLumB = 0.6754; - } - if(GRAYSCALE==1) { - sat = 0.0; - brt = 1.0; - con = 1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(NEGATIVE==1) { - sat = 1.0; - brt = 1.0; - con = -1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(PSPCOLORS==1) { - sat = 1.0; - brt = 1.0; - con = 1.0; - AvgLumR = 0.9593; - AvgLumG = 1.0739; - AvgLumB = 1.4604; - } - //========================== - const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); - - vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); - vec3 conRGB = vec3(0.5, 0.5, 0.5); - vec3 brtColor = color.rgb * brt; - vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c - vec3 satColor = mix(intensity, brtColor, sat); - vec3 conColor = mix(conRGB, satColor, con); - vec3 mixColor = AvgLumin * conColor; - color.rgb = mixColor; - if(rgbRBG==1) { - color.rgb = color.rbg; - } - if(rgbBGR==1) { - color.rgb = color.bgr; - } - if(rgbBRG==1) { - color.rgb = color.brg; - } - if(rgbGRB==1) { - color.rgb = color.grb; - } - if(rgbGBR==1) { - color.rgb = color.gbr; - } - return color; -} -#endif -#if(COLORED==1) -float overlay(float base, float blend) { - float result = 0.0; - if( base < 0.5 ) { - result = 2.0 * base * blend; - } else { - result = 1.0 - (1.0 - 2.0*(base-0.5)) * (1.0-blend); - } - return result; -} -vec3 processCOLORED(vec3 color){ - vec3 blur = color * 1.22520613262190495; - vec3 newcolor = vec3(overlay(color.r,blur.r), - overlay(color.g,blur.g), - overlay(color.b,blur.b)); - color = mix(color, newcolor, Cpower); - return color; -} -#endif -#if(TEST==1) -vec3 processTEST(vec3 color){ - if(v_texcoord0.x<0.5) { - color.xyz=color.xyz; - } else { - color.xyz=texture2D(sampler0, v_texcoord0.xy).xyz; - } - return color; -} -#endif -#if(TESTANIM==1) -vec3 processTESTANIM(vec3 color){ - float anim=(sin(u_time.x*testAspeed)+0.9)*0.55; - if(v_texcoord0.x tolerance || diff.g > tolerance || diff.b > tolerance; //workaround for the above - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Frost==1) -float rand(vec2 co){ - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); -} -vec3 processFrost(vec3 color) { - float tolerance = fTol/1638.4; - for (int i=1;i<5;i++) { - float p = u_pixelDelta.x * float(i) / rand(vec2(rand(v_texcoord0.xy),rand(v_texcoord0.xy))); - vec3 c1 = texture2D(sampler0,v_texcoord0.xy + vec2( p, p)).xyz; - vec3 c1b = texture2D(sampler0,v_texcoord0.xy + vec2( -p, -p)).xyz; - vec3 c2 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, p)).xyz; - vec3 c2b = texture2D(sampler0,v_texcoord0.xy + vec2( p, -p)).xyz; - vec3 c3 = texture2D(sampler0,v_texcoord0.xy + vec2( p,0.0)).xyz; - vec3 c3b = texture2D(sampler0,v_texcoord0.xy + vec2( -p,0.0)).xyz; - vec3 c4 = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, -p)).xyz; - vec3 c4b = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, p)).xyz; - vec3 avg; - if(fSimple==1) { - avg = (c1 + c2 + c3 + c4)/4.0; - } else { - avg = (c1 + c2 + c3 + c4 + c1b + c2b + c3b + c4b)/8.0; - } - vec3 diff = abs(color - avg); - bool a = diff.r > tolerance || diff.g > tolerance || diff.b > tolerance; - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Guest_AA4o==1) -const vec3 dt = vec3(1.0,1.0,1.0); -vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale; -vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale; -vec3 texture2d (vec2 texcoord) { - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2); -} -vec3 texture2dd (vec2 texcoord) { - - vec3 c11 = texture2D(sampler0, texcoord ).xyz; - vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz; - vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz; - vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz; - vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz; - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float d1=dot(abs(c00-c22),dt)+0.001; - float d2=dot(abs(c20-c02),dt)+0.001; - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2)); - - return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2)); -} -vec3 processGuestAA4o() { - // Calculating texel coordinates - - vec2 size = vec2(480.0,272.0)*scale; - vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scale; - - vec2 OGL2Pos = v_texcoord0 * size; - vec2 fp = fract(OGL2Pos); - vec2 dx = vec2(inv_size.x,0.0); - vec2 dy = vec2(0.0, inv_size.y); - vec2 g1 = vec2(inv_size.x,inv_size.y); - vec2 g2 = vec2(-inv_size.x,inv_size.y); - - vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size; - - // Reading the texels - vec3 C0 = texture2d(pC4 - g1); - vec3 C1 = texture2d(pC4 - dy); - vec3 C2 = texture2d(pC4 - g2); - vec3 C3 = texture2d(pC4 - dx); - vec3 C4 = texture2d(pC4 ); - vec3 C5 = texture2d(pC4 + dx); - vec3 C6 = texture2d(pC4 + g2); - vec3 C7 = texture2d(pC4 + dy); - vec3 C8 = texture2d(pC4 + g1); - - vec3 ul, ur, dl, dr; - float m1, m2; - - m1 = dot(abs(C0-C4),dt)+0.001; - m2 = dot(abs(C1-C3),dt)+0.001; - ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2); - - m1 = dot(abs(C1-C5),dt)+0.001; - m2 = dot(abs(C2-C4),dt)+0.001; - ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2); - - m1 = dot(abs(C3-C7),dt)+0.001; - m2 = dot(abs(C6-C4),dt)+0.001; - dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2); - - m1 = dot(abs(C4-C8),dt)+0.001; - m2 = dot(abs(C5-C7),dt)+0.001; - dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2); - - vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y))); - - if(filtro==1){ - vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)); - - inv_size = vec2(2.0/480.0,2.0/272.0)/scale;; - - dx = vec2(inv_size.x,0.0); - dy = vec2(0.0,inv_size.y); - g1 = vec2( inv_size.x,inv_size.y); - g2 = vec2(-inv_size.x,inv_size.y); - pC4 = v_texcoord0; - - C0 = texture2dd(pC4-g1); - C1 = texture2dd(pC4-dy); - C2 = texture2dd(pC4-g2); - C3 = texture2dd(pC4-dx); - C4 = texture2dd(pC4 ); - C5 = texture2dd(pC4+dx); - C6 = texture2dd(pC4+g2); - C7 = texture2dd(pC4+dy); - C8 = texture2dd(pC4+g1); - - vec3 mn1 = min(min(C0,C1),C2); - vec3 mn2 = min(min(C3,C4),C5); - vec3 mn3 = min(min(C6,C7),C8); - vec3 mx1 = max(max(C0,C1),C2); - vec3 mx2 = max(max(C3,C4),C5); - vec3 mx3 = max(max(C6,C7),C8); - - mn1 = min(min(mn1,mn2),mn3); - mx1 = max(max(mx1,mx2),mx3); - - vec3 dif1 = abs(c11-mn1) + 0.0001*dt; - vec3 dif2 = abs(c11-mx1) + 0.0001*dt; - - float filterparam = 2.0; - - dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam)); - dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam)); - - c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x); - c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y); - c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z); - - result = c11; - } - - return result; -} -#endif -#if(Bilateral==1) - - -#define SIGMA 10.0 -#define BSIGMA 0.1 -#define MSIZE 15 -float normpdf(float x, float sigma) { - return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma; -} - -float normpdf3(vec3 v, float sigma) { - return 0.39894*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma; -} - -vec3 processBilateral(vec3 color) { - const int kSize = (MSIZE-1)/2; - float kernel[MSIZE]; - vec3 final_colour; - - // Create the 1-D kernel - float Zxx = 0.0; - for (int j = 0; j <= kSize; ++j) { - kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA); - } - // sigma 10.0, MSIZE 15 - //someone mentioned performance increase with precompiled kernel, but really don't see that - //const float kernel[MSIZE] = float[MSIZE](0.031225216, 0.033322271, 0.035206333, 0.036826804, 0.038138565, 0.039104044, 0.039695028, 0.039894000, 0.039695028, 0.039104044, 0.038138565, 0.036826804, 0.035206333, 0.033322271, 0.031225216); - vec3 cc; - float factorNB; - float bZ = 1.0/normpdf(0.0, BSIGMA); - // Read out the texels - for (int i=-kSize; i <= kSize; ++i) { - for (int j=-kSize; j <= kSize; ++j) { - cc = texture2D(sampler0, v_texcoord0.xy+vec2(float(i)*u_pixelDelta.x,float(j)*u_pixelDelta.x)).rgb; - factorNB = normpdf3(cc-color, BSIGMA)*bZ*kernel[kSize+j]*kernel[kSize+i]; - Zxx += factorNB; - final_colour += factorNB*cc; - } - } - return final_colour/Zxx; -} -#endif -void main() { - vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; - #if(FXAA==1) - color=processFXAA(color); - #endif - #if(GAUSS_SQ==1) - color=processGAUSS_SQ(color); - #endif - #if(GAUSS_S==1) - color=processGAUSS_S(color); - #endif - #if(Guest_AA4o==1) - color=processGuestAA4o(); - #endif - #if(SHARPEN==1) - color=processSHARPEN(color); - #endif - #if(S_COM_V2==1) - color=processS_COM_V2(color); - #endif - #if(xHQ==1) - color=processxHQ(color); - #endif - #if(xBRAccuracy==1 || xBR==1) - color=processxBR(color); - #endif - #if(Deband==1) - color=processDeband(color); - #endif - #if(Frost==1) - color=processFrost(color); - #endif - #if(Bilateral==1) - color=processBilateral(color); - #endif - #if(ACARTOON==1) - color=processACARTOON(color); - #endif - #if(BLOOM==1) - vec3 colorB=color; - int hatsu = 0; - #if(MIKU==1) - hatsu = 1; - color=processMIKU(color); - #endif - color=processBLOOM(color, colorB, hatsu); - #endif - #if(COLORED==1) - color=processCOLORED(color); - #endif - #if(SHADEBOOST==1) - color = processSHADEBOOST(color); - #endif - #if(GAMMA==1) - color = processGAMMA(color); - #endif - #if(SCANLINES==1) - color = processSCANLINES(color); - #endif - #if(VIGNETTE==1) - color = processVIGNETTE(color); - #endif - #if(TEST==1) - color = processTEST(color); - #endif - #if(TESTANIM==1) - color = processTESTANIM(color); - #endif - gl_FragColor.xyz=color; - gl_FragColor.a = 1.0; -} diff --git a/assets/shaders/LunaM.vsh b/assets/shaders/LunaAll.vsh similarity index 100% rename from assets/shaders/LunaM.vsh rename to assets/shaders/LunaAll.vsh diff --git a/assets/shaders/LunaBilateral.fsh b/assets/shaders/LunaBilateral.fsh new file mode 100644 index 0000000000..5fbe108718 --- /dev/null +++ b/assets/shaders/LunaBilateral.fsh @@ -0,0 +1,109 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one +//================ +//#define Bilateral 0 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one +//================ +//#define Bilateralv 0 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: Deband, Frost(fSimple) +//Heavy: Frost +//Extremely Heavy: Bilateral +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + + +#define SIGMA 10.0 +#define BSIGMA 0.1 +#define MSIZE 15 +float normpdf(float x, float sigma) { + float vulkanWorkaround = 0.39894; + if (u_setting.y == 1.0) { + vulkanWorkaround = 0.39894*10.0; + } + return vulkanWorkaround * exp(-0.5 * x * x / (sigma * sigma)) / sigma; +} + +float normpdf3(vec3 v, float sigma) { + float vulkanWorkaround = 0.39894; + if (u_setting.y == 1.0) { + vulkanWorkaround = 0.39894*10.0; + } + return vulkanWorkaround*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma; +} + +vec3 processBilateral(vec3 color) { + const int kSize = (MSIZE-1)/2; + float kernel[MSIZE]; + vec3 final_colour; + + // Create the 1-D kernel + float Zxx = 0.0; + for (int j = 0; j <= kSize; ++j) { + kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA); + } + // sigma 10.0, MSIZE 15 + //someone mentioned performance increase with precompiled kernel, but really don't see that + //const float kernel[MSIZE] = float[MSIZE](0.031225216, 0.033322271, 0.035206333, 0.036826804, 0.038138565, 0.039104044, 0.039695028, 0.039894000, 0.039695028, 0.039104044, 0.038138565, 0.036826804, 0.035206333, 0.033322271, 0.031225216); + vec3 cc; + float factorNB; + float bZ = 1.0/normpdf(0.0, BSIGMA); + // Read out the texels + for (int i=-kSize; i <= kSize; ++i) { + for (int j=-kSize; j <= kSize; ++j) { + cc = texture2D(sampler0, v_texcoord0.xy+vec2(float(i)*u_pixelDelta.x,float(j)*u_pixelDelta.x)).rgb; + factorNB = normpdf3(cc-color, BSIGMA)*bZ*kernel[kSize+j]*kernel[kSize+i]; + Zxx += factorNB; + final_colour += factorNB*cc; + } + } + return final_colour/Zxx; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processBilateral(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaBloom.fsh b/assets/shaders/LunaBloom.fsh new file mode 100644 index 0000000000..33f14c20f7 --- /dev/null +++ b/assets/shaders/LunaBloom.fsh @@ -0,0 +1,114 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//OTHER FILTERS: +//================ +//#define BLOOM 0 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ +//#define MIKU 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress +//#define samples 3 //Default: 4 /higher = more glow, worse performance +//#define quality 0.14 //Default: 0.18 /lower = smaller glow, better quality +//#define Bpower 1.0 //Default: 1.0 /amount of bloom mixed +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//OTHER FILTERS: +//================ +//#define BLOOMv 0 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ +//#define MIKUv 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress +//#define samplesv 3 //Default: 4 /higher = more glow, worse performance +//#define qualityv 0.14 //Default: 0.18 /lower = smaller glow, better quality +//#define Bpowerv 1.0 //Default: 1.0 /amount of bloom mixed +//================ +//Approximate performance hit +//Free: +//Light: VIGNETTE, BLOOM(<= 2 samples) +//Medium: ACARTOON, BLOOM(== 3 samples) +//Heavy: BLOOM(>= 4 samples) +//Extremely Heavy: BLOOM(>= 8 samples) +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +vec3 processBLOOM(vec3 color, vec3 colorB, int hatsu){ + #define factor 0.002 //Default: 0.002 /just an extra tweak for the bloom slightly higher values might look better in some cases, but too much can cause artifacts + vec4 sum = vec4(0); + int jb; + int samplesBloom = int(u_setting.y); + float qualityBloom = u_setting.z; + float BpowerBloom = 1.0; + + int diffx = samplesBloom - 1; + int ib; + int diffy = samplesBloom; + vec3 bloom; + for( ib= -diffy ;ib < diffy; ib++) { + for (jb = -diffx; jb < diffx; jb++) { + sum += texture2D(sampler0, v_texcoord0.xy + vec2(jb, ib)*factor) * qualityBloom; + } + } + if(color.r < 0.3 && color.g < 0.3 && color.b < 0.3) { + bloom = sum.xyz*sum.xyz*0.012 + color; + } else { + if(color.r < 0.5 && color.g < 0.5 && color.b < 0.5) { + bloom = sum.xyz*sum.xyz*0.009 + color; + } else { + bloom = sum.xyz*sum.xyz*0.0075 + color; + } + } + color = mix(color, bloom, BpowerBloom); + if(hatsu==1) { + color = mix(colorB, color, 0.5); + } + return color; +} +vec3 processMIKU(vec3 color){ + vec3 mmm = vec3(0.1, 0.1, 0.1); + color = mix(color,mmm, 0.9); + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + vec3 colorB=color; + int hatsu = 0; + if(u_setting.w==1.0) { + hatsu = 1; + color=processMIKU(color); + } + color=processBLOOM(color, colorB, hatsu); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaCartoon.fsh b/assets/shaders/LunaCartoon.fsh new file mode 100644 index 0000000000..a3f4bdfc35 --- /dev/null +++ b/assets/shaders/LunaCartoon.fsh @@ -0,0 +1,134 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//OTHER FILTERS: +//================ +//#define ACARTOON 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack +//#define th 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 +//#define bb 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 +//#define pp 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 +//#define acpower 1.0 //Default:1.0 / reduce for more subtle effect +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//OTHER FILTERS: +//================ +//#define ACARTOONv 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack +//#define thv 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 +//#define bbv 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 +//#define ppv 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 +//#define acpowerv 1.0 //Default: 1.0 / reduce for more subtle effect +//================ +//Approximate performance hit +//Free: +//Light: VIGNETTE, BLOOM(<= 2 samples) +//Medium: ACARTOON, BLOOM(== 3 samples) +//Heavy: BLOOM(>= 4 samples) +//Extremely Heavy: BLOOM(>= 8 samples) +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +/* + Advanced Cartoon shader + + Copyright (C) 2006 guest(r) - guest.r@gmail.com + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +vec3 processACARTOON(vec3 color){ + float x = u_pixelDelta.x; + float y = u_pixelDelta.y; + vec2 dg1 = vec2( x,y); + vec2 dg2 = vec2(-x,y); + vec2 acdx = vec2(x,0.0); + vec2 acdy = vec2(0.0,y); + + float thACARTOON = u_setting.y; + float bbACARTOON = u_setting.z; + float ppACARTOON = u_setting.w; + float acpowerACARTOON = 1.0; + + vec3 c00 = texture2D(sampler0, v_texcoord0.xy - dg1).xyz; + vec3 c10 = texture2D(sampler0, v_texcoord0.xy - acdy).xyz; + vec3 c20 = texture2D(sampler0, v_texcoord0.xy + dg2).xyz; + vec3 c01 = texture2D(sampler0, v_texcoord0.xy - acdx).xyz; + vec3 c11 = texture2D(sampler0, v_texcoord0.xy).xyz; + vec3 c21 = texture2D(sampler0, v_texcoord0.xy + acdx).xyz; + vec3 c02 = texture2D(sampler0, v_texcoord0.xy - dg2).xyz; + vec3 c12 = texture2D(sampler0, v_texcoord0.xy + acdy).xyz; + vec3 c22 = texture2D(sampler0, v_texcoord0.xy + dg1).xyz; + vec3 dt = vec3(1.0,1.0,1.0); + + float d1=dot(abs(c00-c22),dt); + float d2=dot(abs(c20-c02),dt); + float hl=dot(abs(c01-c21),dt); + float vl=dot(abs(c10-c12),dt); + + c11 = (c11+ 0.5*(c01+c10+c21+c12)+ 0.25*(c00+c22+c20+c02))/4.0; + float d =bbACARTOON*pow(max(d1+d2+hl+vl-thACARTOON,0.0),ppACARTOON)/(dot(c11,dt)+0.50); + + float lc = 5.0*length(c11); + lc = 0.2*(floor(lc) + pow(fract(lc),4.0)); + c11 = 4.0*normalize(c11); + vec3 frct = fract(c11); frct*=frct; + c11 = floor(c11) + frct*frct; + c11 = 0.25*(c11)*lc; lc*=0.577; + c11 = mix(c11,lc*dt,lc); + color.xyz = mix(color,(1.15-d)*c11,acpowerACARTOON); + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processACARTOON(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaChainShaders.ini b/assets/shaders/LunaChainShaders.ini new file mode 100644 index 0000000000..baf85f4d1f --- /dev/null +++ b/assets/shaders/LunaChainShaders.ini @@ -0,0 +1,646 @@ +# You can have multiple ini files if you want, it doesn't matter. +[LunaTest] +Visible=True +Name=Test Shader +Author=LunaMoo +Fragment=LunaTest.fsh +Vertex=LunaAll.vsh +SettingName1=Static or animated +SettingDefaultValue1=0.0 +SettingMaxValue1=1.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Animation speed +SettingDefaultValue2=1.0 +SettingMaxValue2=5.0 +SettingMinValue2=0.25 +SettingStep2=0.25 +[LunaXBR] +Visible=True +Name=xBR +Author=LunaMoo +Fragment=LunaXBR.fsh +Vertex=LunaAll.vsh +Upscaling=True +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Version +SettingDefaultValue2=1.0 +SettingMaxValue2=2.0 +SettingMinValue2=1.0 +SettingStep2=1.0 +SettingName3=Variant +SettingDefaultValue3=3.0 +SettingMaxValue3=4.0 +SettingMinValue3=1.0 +SettingStep3=1.0 +[LunaXHQ] +Visible=True +Name=xHQ +Author=LunaMoo +Fragment=LunaXHQ.fsh +Vertex=LunaAll.vsh +Upscaling=True +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Scale Offset +SettingDefaultValue2=1.0 +SettingMaxValue2=1.5 +SettingMinValue2=0.5 +SettingStep2=0.1 +[LunaXBRZf] +Visible=True +Name=Scalable xBRZ for HiRes +Author=LunaMoo +Fragment=LunaxBRZf-DU.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=X scale (0.799 Wide/1.0 Normal for SFA3MAX) +SettingDefaultValue2=0.799 +SettingMaxValue2=2.0 +SettingMinValue2=0.1 +SettingStep2=0.001 +SettingName3=Y scale (0.831 for SFA3MAX) +SettingDefaultValue3=0.831 +SettingMaxValue3=2.0 +SettingMinValue3=0.1 +SettingStep3=0.001 +[LunaFXAA] +Visible=True +Name=FXAA +Author=LunaMoo +Fragment=LunaFXAA.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +[LunaGAUSS_SQ] +Visible=True +Name=Full GAUSS with SSAA x3 +Author=LunaMoo +Fragment=LunaGAUSS_SQ.fsh +Vertex=LunaAll.vsh +OutputResolution=True +SSAA=3 +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Smoothing +SettingDefaultValue2=3.5 +SettingMaxValue2=6.0 +SettingMinValue2=1.0 +SettingStep2=0.1 +[LunaGAUSS_S] +Visible=True +Name=Simple GAUSS with SSAA x2 +Author=LunaMoo +Fragment=LunaGAUSS_S.fsh +Vertex=LunaAll.vsh +OutputResolution=True +SSAA=2 +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +[LunaGuestAA4o] +Visible=True +Name=Guest AA4o +Author=LunaMoo +Fragment=LunaGuest_AA4o.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Scale +SettingDefaultValue2=7.0 +SettingMaxValue2=8.0 +SettingMinValue2=2.0 +SettingStep2=0.5 +SettingName3=Apply heavy filtering +SettingDefaultValue3=0.0 +SettingMaxValue3=1.0 +SettingMinValue3=0.0 +SettingStep3=1.0 +[LunaSimpleSharpen] +Visible=True +Name=Simple Sharpen +Author=LunaMoo +Fragment=LunaSimpleSharpen.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Power +SettingDefaultValue2=7.5 +SettingMaxValue2=15.0 +SettingMinValue2=2.0 +SettingStep2=0.5 +[LunaComplexSharpen] +Visible=True +Name=Complex Sharpen +Author=LunaMoo +Fragment=LunaComplexSharpen.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Power +SettingDefaultValue2=5.0 +SettingMaxValue2=10.0 +SettingMinValue2=-10.0 +SettingStep2=0.5 +[LunaDeband] +Visible=True +Name=Simple debanding filter +Author=LunaMoo +Fragment=LunaDeband.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Tolerance +SettingDefaultValue2=16.0 +SettingMaxValue2=64.0 +SettingMinValue2=1.0 +SettingStep2=1.0 +[LunaFrost] +Visible=True +Name=Frost debanding filter +Author=LunaMoo +Fragment=LunaFrost.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Tolerance +SettingDefaultValue2=32.0 +SettingMaxValue2=128.0 +SettingMinValue2=1.0 +SettingStep2=1.0 +SettingName3=Reduce samples for performance +SettingDefaultValue3=0.0 +SettingMaxValue3=1.0 +SettingMinValue3=0.0 +SettingStep3=1.0 +SettingName4=Ordered +SettingDefaultValue4=0.0 +SettingMaxValue4=1.0 +SettingMinValue4=0.0 +SettingStep4=1.0 +[LunaBilateral] +Visible=True +Name=Bilateral filtering +Author=LunaMoo +Fragment=LunaBilateral.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Vulkan Backend Workaround +SettingDefaultValue2=1.0 +SettingMaxValue2=1.0 +SettingMinValue2=0.0 +SettingStep2=1.0 +[LunaSimpleScanlines] +Visible=True +Name=Simple scanlines +Author=LunaMoo +Fragment=LunaSimpleScanlines.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Line size +SettingDefaultValue2=1.0 +SettingMaxValue2=4.0 +SettingMinValue2=1.0 +SettingStep2=1.0 +SettingName3=Line brightness +SettingDefaultValue3=0.8 +SettingMaxValue3=1.0 +SettingMinValue3=0.1 +SettingStep3=0.1 +SettingName4=Display Brightness +SettingDefaultValue4=1.2 +SettingMaxValue4=2.0 +SettingMinValue4=1.0 +SettingStep4=0.1 +[LunaLCD3x] +Visible=True +Name=LCD3x +Author=LunaMoo +Fragment=LunaLCD3x.fsh +Vertex=LunaScan.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Line size +SettingDefaultValue2=2.0 +SettingMaxValue2=4.0 +SettingMinValue2=1.0 +SettingStep2=1.0 +SettingName3=Horizontal line brightness +SettingDefaultValue3=16.0 +SettingMaxValue3=32.0 +SettingMinValue3=1.0 +SettingStep3=1.0 +SettingName4=Vertical line brightness +SettingDefaultValue4=4.0 +SettingMaxValue4=8.0 +SettingMinValue4=1.0 +SettingStep4=1.0 +[LunaCartoon] +Visible=True +Name=Cartoon +Author=LunaMoo +Fragment=LunaCartoon.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Outline sensitivity +SettingDefaultValue2=0.10 +SettingMaxValue2=0.5 +SettingMinValue2=0.01 +SettingStep2=0.01 +SettingName3=Outline strenght +SettingDefaultValue3=0.45 +SettingMaxValue3=2.0 +SettingMinValue3=0.1 +SettingStep3=0.1 +SettingName4=Outline blackening +SettingDefaultValue4=1.50 +SettingMaxValue4=2.0 +SettingMinValue4=0.25 +SettingStep4=0.25 +[LunaBloom] +Visible=True +Name=Bloom +Author=LunaMoo +Fragment=LunaBloom.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Samples +SettingDefaultValue2=3.0 +SettingMaxValue2=8.0 +SettingMinValue2=2.0 +SettingStep2=1.0 +SettingName3=Quality (distance between samples) +SettingDefaultValue3=0.14 +SettingMaxValue3=1.0 +SettingMinValue3=0.05 +SettingStep3=0.01 +SettingName4=Miku(Darkened / Anime Bloom) +SettingDefaultValue4=0.0 +SettingMaxValue4=1.0 +SettingMinValue4=0.0 +SettingStep4=1.0 +[LunaVignette] +Visible=True +Name=Vignette +Author=LunaMoo +Fragment=LunaVignette.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Size +SettingDefaultValue2=1.2 +SettingMaxValue2=2.0 +SettingMinValue2=0.5 +SettingStep2=0.1 +SettingName3=Position +SettingDefaultValue3=0.0 +SettingMaxValue3=0.5 +SettingMinValue3=-0.5 +SettingStep3=0.01 +SettingName4=Reverse effect +SettingDefaultValue4=0.0 +SettingMaxValue4=1.0 +SettingMinValue4=0.0 +SettingStep4=1.0 +[LunaColored] +Visible=True +Name=Colored +Author=LunaMoo +Fragment=LunaColored.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Power +SettingDefaultValue2=1.0 +SettingMaxValue2=1.0 +SettingMinValue2=0.4 +SettingStep2=0.1 +[LunaNaturalColors] +Visible=True +Name=Natural Colors +Author=LunaMoo +Fragment=LunaNaturalColors.fsh +Vertex=LunaColor.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Power +SettingDefaultValue2=1.0 +SettingMaxValue2=1.0 +SettingMinValue2=0.4 +SettingStep2=0.1 +[LunaGamma] +Visible=True +Name=Gamma +Author=LunaMoo +Fragment=LunaGamma.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Correction +SettingDefaultValue2=1.0 +SettingMaxValue2=2.0 +SettingMinValue2=0.2 +SettingStep2=0.1 +[LunaShadeboostA] +Visible=True +Name=ShadeboostA +Author=LunaMoo +Fragment=LunaShadeboostA.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Saturation +SettingDefaultValue2=1.0 +SettingMaxValue2=2.0 +SettingMinValue2=0.2 +SettingStep2=0.1 +SettingName3=Brightness +SettingDefaultValue3=1.0 +SettingMaxValue3=2.0 +SettingMinValue3=0.2 +SettingStep3=0.1 +SettingName4=Contrast +SettingDefaultValue4=1.0 +SettingMaxValue4=2.0 +SettingMinValue4=0.2 +SettingStep4=0.1 +[LunaShadeboostB] +Visible=True +Name=ShadeboostB +Author=LunaMoo +Fragment=LunaShadeboostB.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Red +SettingDefaultValue2=1.0 +SettingMaxValue2=2.0 +SettingMinValue2=0.0 +SettingStep2=0.1 +SettingName3=Green +SettingDefaultValue3=1.0 +SettingMaxValue3=2.0 +SettingMinValue3=0.0 +SettingStep3=0.1 +SettingName4=Blue +SettingDefaultValue4=1.0 +SettingMaxValue4=2.0 +SettingMinValue4=0.0 +SettingStep4=0.1 +[LunaShadeboostC] +Visible=True +Name=ShadeboostC +Author=LunaMoo +Fragment=LunaShadeboostC.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Swap green <-> blue +SettingDefaultValue2=0.0 +SettingMaxValue2=1.0 +SettingMinValue2=0.0 +SettingStep2=1.0 +SettingName3=Swap red <-> blue +SettingDefaultValue3=0.0 +SettingMaxValue3=1.0 +SettingMinValue3=0.0 +SettingStep3=1.0 +SettingName4=Swap red -> green -> blue -> red +SettingDefaultValue4=0.0 +SettingMaxValue4=1.0 +SettingMinValue4=0.0 +SettingStep4=1.0 +[LunaShadeboostD] +Visible=True +Name=ShadeboostD +Author=LunaMoo +Fragment=LunaShadeboostD.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Swap red <-> green +SettingDefaultValue2=0.0 +SettingMaxValue2=1.0 +SettingMinValue2=0.0 +SettingStep2=1.0 +SettingName3=Swap red -> blue -> green -> red +SettingDefaultValue3=0.0 +SettingMaxValue3=1.0 +SettingMinValue3=0.0 +SettingStep3=1.0 +SettingName4=Apply bluish tint(Old PSP colors) +SettingDefaultValue4=0.0 +SettingMaxValue4=1.0 +SettingMinValue4=0.0 +SettingStep4=1.0 +[LunaShadeboostE] +Visible=True +Name=ShadeboostE +Author=LunaMoo +Fragment=LunaShadeboostE.fsh +Vertex=LunaAll.vsh +OutputResolution=True +60fps=True +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=Apply sepia preset +SettingDefaultValue2=0.0 +SettingMaxValue2=1.0 +SettingMinValue2=0.0 +SettingStep2=1.0 +SettingName3=Apply grayscale preset +SettingDefaultValue3=0.0 +SettingMaxValue3=1.0 +SettingMinValue3=0.0 +SettingStep3=1.0 +SettingName4=Apply negative preset +SettingDefaultValue4=0.0 +SettingMaxValue4=1.0 +SettingMinValue4=0.0 +SettingStep4=1.0 +[LunaCustomAspectRatio] +Name=Custom Aspect Ratio +Author=LunaMoo +Fragment=LunaCustomAspectRatio.fsh +Vertex=LunaAll.vsh +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=2.0 +SettingMinValue1=0.0 +SettingStep1=1.0 +SettingName2=X +SettingDefaultValue2=16.0 +SettingMaxValue2=48.0 +SettingMinValue2=0.5 +SettingStep2=0.05 +SettingName3=Y +SettingDefaultValue3=9.0 +SettingMaxValue3=24.0 +SettingMinValue3=0.5 +SettingStep3=0.05 +[LunaPixelate] +Name=Pixelate +Author=LunaMoo +Fragment=LunaPixelate.fsh +Vertex=LunaAll.vsh +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=8.0 +SettingMinValue1=2.0 +SettingStep1=1.0 +SettingName2=Factor +SettingDefaultValue2=2.0 +SettingMaxValue2=64.0 +SettingMinValue2=1.0 +SettingStep2=1.0 +[LunaColorReduction] +Name=Color Reduction +Author=LunaMoo +Fragment=LunaColorReduction.fsh +Vertex=LunaAll.vsh +SettingName1=Apply to game/video/all +SettingDefaultValue1=2.0 +SettingMaxValue1=8.0 +SettingMinValue1=2.0 +SettingStep1=1.0 +SettingName2=R +SettingDefaultValue2=32.0 +SettingMaxValue2=256.0 +SettingMinValue2=1.0 +SettingStep2=1.0 +SettingName3=G +SettingDefaultValue3=64.0 +SettingMaxValue3=256.0 +SettingMinValue3=1.0 +SettingStep3=1.0 +SettingName4=B +SettingDefaultValue4=32.0 +SettingMaxValue4=256.0 +SettingMinValue4=1.0 +SettingStep4=1.0 \ No newline at end of file diff --git a/assets/shaders/Luna.vsh b/assets/shaders/LunaColor.vsh similarity index 89% rename from assets/shaders/Luna.vsh rename to assets/shaders/LunaColor.vsh index a3bebc18fa..0aa8dc2b36 100644 --- a/assets/shaders/Luna.vsh +++ b/assets/shaders/LunaColor.vsh @@ -7,7 +7,6 @@ varying vec4 v_texcoord1; varying vec4 v_texcoord2; varying vec4 v_texcoord3; varying vec4 v_texcoord4; -varying vec2 v_texcoord5; void main() { v_texcoord0 = a_texcoord0 + 0.000001; //HLSL precision workaround @@ -16,5 +15,4 @@ void main() { v_texcoord2=a_texcoord0.xyxy+vec4( 0.5,-0.5, 1.5,-1.5)*u_texelDelta.xyxy; v_texcoord3=a_texcoord0.xyxy+vec4(-0.5, 0.5,-1.5, 1.5)*u_texelDelta.xyxy; v_texcoord4=a_texcoord0.xyxy+vec4( 0.5, 0.5, 1.5, 1.5)*u_texelDelta.xyxy; - v_texcoord5 = 3.141592654 * (1.0/u_pixelDelta); } diff --git a/assets/shaders/LunaColorReduction.fsh b/assets/shaders/LunaColorReduction.fsh new file mode 100644 index 0000000000..e613c8f5b3 --- /dev/null +++ b/assets/shaders/LunaColorReduction.fsh @@ -0,0 +1,29 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +varying vec2 v_texcoord0; +uniform vec4 u_setting; +uniform vec2 u_pixelDelta; + + +vec3 processColorReduction(vec3 color) { + + vec3 colorRes = vec3(u_setting.y, u_setting.z, u_setting.w); + color = floor(color.rgb * colorRes) / (colorRes - 1.0); + color = min(color, 1.0); + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processColorReduction(color); + } + + gl_FragColor.xyz=color.xyz; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaColored.fsh b/assets/shaders/LunaColored.fsh new file mode 100644 index 0000000000..5f5db17557 --- /dev/null +++ b/assets/shaders/LunaColored.fsh @@ -0,0 +1,87 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//#define COLORED 0 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o +//#define Cpower 0.5 //Default: 0.5 /strenght of the effect +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define COLOREDv 0 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o +//#define Cpowerv 0.5 //Default: 0.5 /strenght of the effect +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +float overlay(float base, float blend) { + float result = 0.0; + if( base < 0.5 ) { + result = 2.0 * base * blend; + } else { + result = 1.0 - (1.0 - 2.0*(base-0.5)) * (1.0-blend); + } + return result; +} +vec3 processCOLORED(vec3 color){ + float CpowerCOLORED = u_setting.y; + + vec3 blur = color * 1.22520613262190495; + vec3 newcolor = vec3(overlay(color.r,blur.r), + overlay(color.g,blur.g), + overlay(color.b,blur.b)); + color = mix(color, newcolor, CpowerCOLORED); + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processCOLORED(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaComplexSharpen.fsh b/assets/shaders/LunaComplexSharpen.fsh new file mode 100644 index 0000000000..a4b9f0cdfd --- /dev/null +++ b/assets/shaders/LunaComplexSharpen.fsh @@ -0,0 +1,137 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing +//================ +//#define S_COM_V2 1 //ON:1/OFF:0 /Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate +//#define S_val0 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing +//================ +//#define S_COM_V2v 1 //ON:1/OFF:0 /Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate +//#define S_val0v 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect +//================ +//Approximate performance hit +//Free: +//Light: SHARPEN +//Medium: S_COM_V2 +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + +//=========== +//=========== + +vec3 processS_COM_V2(vec3 color){ + float S_val0S_COM_V2 = u_setting.y; + + float width = (v_texcoord0.x); + float height = (v_texcoord0.y); + float px = (u_texelDelta.x); + float py = (u_texelDelta.y); + float mean = 0.6; + float dx = (mean * px); + float dy = (mean * py); + float CoefBlur = 2.0; + float CoefOrig = (1.0 + CoefBlur); + float Sharpen_val1 = ((S_val0S_COM_V2 - 1.0) / 8.0); + vec3 S_Edge = vec3(0.2,0.2,0.2); + // get original pixel / color + + // compute blurred image (gaussian filter) + vec3 c1 = texture2D(sampler0, v_texcoord0 + vec2(-dx, -dy)).xyz; + vec3 c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -dy)).xyz; + vec3 c3 = texture2D(sampler0, v_texcoord0 + vec2( dx, -dy)).xyz; + vec3 c4 = texture2D(sampler0, v_texcoord0 + vec2(-dx, 0)).xyz; + vec3 c5 = texture2D(sampler0, v_texcoord0 + vec2( dx, 0)).xyz; + vec3 c6 = texture2D(sampler0, v_texcoord0 + vec2(-dx, dy)).xyz; + vec3 c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, dy)).xyz; + vec3 c8 = texture2D(sampler0, v_texcoord0 + vec2( dx, dy)).xyz; + + // gaussian filter + // [ 1, 2, 1 ] + // [ 2, 4, 2 ] + // [ 1, 2, 1 ] + // to normalize the values, we need to divide by the coeff sum + // 1 / (1+2+1+2+4+2+1+2+1) = 1 / 16 = 0.0625 + vec3 flou = (c1 + c3 + c6 + c8 + 2.0 * (c2 + c4 + c5 + c7) + 4.0 * color) * 0.0625; + + // substract blurred image from original image + vec3 corrected = CoefOrig * color - CoefBlur * flou; + + // edge detection + // Get neighbor points + // [ c1, c2, c3 ] + // [ c4, color, c5 ] + // [ c6, c7, c8 ] + c1 = texture2D(sampler0, v_texcoord0 + vec2(-px, -py)).xyz; + c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -py)).xyz; + c3 = texture2D(sampler0, v_texcoord0 + vec2( px, -py)).xyz; + c4 = texture2D(sampler0, v_texcoord0 + vec2(-px, 0)).xyz; + c5 = texture2D(sampler0, v_texcoord0 + vec2( px, 0)).xyz; + c6 = texture2D(sampler0, v_texcoord0 + vec2(-px, py)).xyz; + c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, py)).xyz; + c8 = texture2D(sampler0, v_texcoord0 + vec2( px, py)).xyz; + + // using Sobel filter + // horizontal gradient + // [ -1, 0, 1 ] + // [ -2, 0, 2 ] + // [ -1, 0, 1 ] + vec3 delta1 = (c3 + 2.0 * c5 + c8) - (c1 + 2.0 * c4 + c6); + + // Save some arithmetic operations to ensure PS2 compatibility + c1 += c3; + c6 += c8; + // vertical gradient + // [ -1, - 2, -1 ] + // [ 0, 0, 0 ] + // [ 1, 2, 1 ] + vec3 delta2 = (c6 + 2.0 * c7 ) - (c1 + 2.0 * c2 ); + vec3 checkshc = sqrt(delta1 * delta1 + delta2 * delta2); + // computation + if (checkshc.x > S_Edge.x || checkshc.y > S_Edge.y || checkshc.z > S_Edge.z) { + // if we have an edge, use sharpen + corrected = color * S_val0S_COM_V2 - (c1 + c2 + c4 + c5 + c6 + c7 ) * Sharpen_val1; + } + return corrected; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processS_COM_V2(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaCustomAspectRatio.fsh b/assets/shaders/LunaCustomAspectRatio.fsh new file mode 100644 index 0000000000..e098d15024 --- /dev/null +++ b/assets/shaders/LunaCustomAspectRatio.fsh @@ -0,0 +1,47 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +varying vec2 v_texcoord0; +uniform vec4 u_setting; + + +vec3 processAspectRatio() { + + float zoomByX = 16.0 / u_setting.y; + float zoomByY = 9.0 / u_setting.z; + float zoomByXY = 1.0; + + if (zoomByX < zoomByY) { + zoomByXY = zoomByX; + } else { + zoomByXY = zoomByY; + } + + float xdivision = 1.0 / (u_setting.y / 16.0 * zoomByXY); + float ydivision = 1.0 / (u_setting.z / 9.0 * zoomByXY); + + vec3 color = texture2D(sampler0, vec2(v_texcoord0.x * xdivision - (0.5 + xdivision / 2.0 - 1.0), v_texcoord0.y * ydivision - (0.5 + ydivision / 2.0 - 1.0))).xyz; + + // Remove color bleed outside of the game scene caused by shrinking + float rangex = (0.5 + (xdivision / 2.0 - 1.0)) / xdivision; + float rangey = (0.5 + (ydivision / 2.0 - 1.0)) / ydivision; + if (v_texcoord0.x < rangex || v_texcoord0.x > 1.0 - rangex || v_texcoord0.y < rangey || v_texcoord0.y > 1.0 - rangey) { + color.xyz = vec3(0.0,0.0,0.0).xyz; + } + + return color.xyz; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processAspectRatio(); + } + + gl_FragColor.xyz=color.xyz; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaDeband.fsh b/assets/shaders/LunaDeband.fsh new file mode 100644 index 0000000000..49a721fce4 --- /dev/null +++ b/assets/shaders/LunaDeband.fsh @@ -0,0 +1,81 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one +//================ +//#define Deband 0 //ON:1/OFF:0 /Blurs +//#define DeTol 16.0 //Default: 16.0 /tolerance, too high will look glitchy +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one +//================ +//#define Debandv 0 //ON:1/OFF:0 /Blurs +//#define DeTolv 16.0 //Default: 16.0 /tolerance, too high will look glitchy +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: Deband, Frost(fSimple) +//Heavy: Frost +//Extremely Heavy: Bilateral +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + +vec3 processDeband(vec3 color) { + float tolerance = u_setting.y/1638.4; + + for (int i=1;i<5;i++) { + float p = u_texelDelta.x * float(i); + vec3 c1 = texture2D(sampler0,v_texcoord0.xy + vec2( p, p)).xyz; + vec3 c2 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, -p)).xyz; + vec3 c3 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, p)).xyz; + vec3 c4 = texture2D(sampler0,v_texcoord0.xy + vec2( p, -p)).xyz; + vec3 avg = (c1 + c2 + c3 + c4)/4.0; + vec3 diff = abs(color - avg); + //color = mix(avg, color, greaterThan(diff, vec3(tolerance))); //doesn't work on old devices + bool a = diff.r > tolerance || diff.g > tolerance || diff.b > tolerance; //workaround for the above + color = mix(avg, color, float(a)); + } + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processDeband(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaFXAA.fsh b/assets/shaders/LunaFXAA.fsh new file mode 100644 index 0000000000..7a4f049581 --- /dev/null +++ b/assets/shaders/LunaFXAA.fsh @@ -0,0 +1,125 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define FXAA 0 //ON:1/OFF:0 /default FXAA, orginal info below +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define FXAAv 0 //ON:1/OFF:0 /default FXAA, orginal info below +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: FXAA, GAUSS_SQ, GAUSS_S +//Heavy: Guest_AA4o +//Extremely Heavy: Guest_AA4o(filtro) +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + +/* + FXAA shader, GLSL code adapted from: + http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA + Whitepaper describing the technique: + http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf +*/ + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + +vec3 processFXAA(vec3 color){ + //The parameters are hardcoded for now, but could be + //made into uniforms to control fromt he program. + float FXAA_SPAN_MAX = 8.0; + float FXAA_REDUCE_MUL = 1.0/8.0; + float FXAA_REDUCE_MIN = (1.0/128.0); + + vec3 rgbNW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, -1.0) * u_texelDelta).xyz; + //#define Pass_Diffuse(v2TexCoord) texture2D(sampler0, v2TexCoord).xyz + //vec3 rgbNW = Pass_Diffuse(v2TexCoord + vec2(-u_texelDelta.x, -u_texelDelta.y)).xyz; + vec3 rgbNE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, -1.0) * u_texelDelta).xyz; + vec3 rgbSW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, +1.0) * u_texelDelta).xyz; + vec3 rgbSE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, +1.0) * u_texelDelta).xyz; + vec3 rgbM = texture2D(sampler0, v_texcoord0).xyz; + + vec3 luma = vec3(0.299, 0.587, 0.114); + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot( rgbM, luma); + + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); + + float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); + + dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), + max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta; + + vec3 rgbA = (1.0/2.0) * ( + texture2D(sampler0, v_texcoord0 + dir * (1.0/3.0 - 0.5)).xyz + + texture2D(sampler0, v_texcoord0 + dir * (2.0/3.0 - 0.5)).xyz); + vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( + texture2D(sampler0, v_texcoord0 + dir * (0.0/3.0 - 0.5)).xyz + + texture2D(sampler0, v_texcoord0 + dir * (3.0/3.0 - 0.5)).xyz); + float lumaB = dot(rgbB, luma); + + if((lumaB < lumaMin) || (lumaB > lumaMax)){ + color=rgbA; + } else { + color=rgbB; + } + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processFXAA(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaFrost.fsh b/assets/shaders/LunaFrost.fsh new file mode 100644 index 0000000000..381f9cc7ab --- /dev/null +++ b/assets/shaders/LunaFrost.fsh @@ -0,0 +1,96 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one +//================ +//#define Frost 0 //ON:1/OFF:0 /Dithering ~ adds noise +//#define fTol 32.0 //Default: 32.0 /tolerance, too high will look glitchy +//#define fSimple 0 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one +//================ +//#define Frostv 0 //ON:1/OFF:0 /Dithering ~ adds noise +//#define fTolv 32.0 //Default: 32.0 /tolerance, too high will look glitchy +//#define fSimplev 1 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: Deband, Frost(fSimple) +//Heavy: Frost +//Extremely Heavy: Bilateral +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + +float rand(vec2 co){ + return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); +} +vec3 processFrost(vec3 color) { + float tolerance = u_setting.y/1638.4; + + for (int i=1;i<5;i++) { + float p = u_pixelDelta.x * float(i) / rand(vec2(rand(v_texcoord0.xy),rand(v_texcoord0.xy))); + vec3 c1 = texture2D(sampler0,v_texcoord0.xy + vec2( p, p)).xyz; + vec3 c1b = texture2D(sampler0,v_texcoord0.xy + vec2( -p, -p)).xyz; + vec3 c2 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, p)).xyz; + vec3 c2b = texture2D(sampler0,v_texcoord0.xy + vec2( p, -p)).xyz; + vec3 c3 = texture2D(sampler0,v_texcoord0.xy + vec2( p,0.0)).xyz; + vec3 c3b = texture2D(sampler0,v_texcoord0.xy + vec2( -p,0.0)).xyz; + vec3 c4 = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, -p)).xyz; + vec3 c4b = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, p)).xyz; + vec3 avg = vec3(0.0, 0.0, 0.0); + if(u_setting.w!=1.0 || mod(v_texcoord0.x / u_pixelDelta.x , 2.0) >= 1.0) { + if(u_setting.z==1.0) { + avg = (c1 + c2 + c3 + c4)/4.0; + } else { + avg = (c1 + c2 + c3 + c4 + c1b + c2b + c3b + c4b)/8.0; + } + } + vec3 diff = abs(color - avg); + bool a = diff.r > tolerance || diff.g > tolerance || diff.b > tolerance; + color = mix(avg, color, float(a)); + } + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processFrost(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaGAUSS_S.fsh b/assets/shaders/LunaGAUSS_S.fsh new file mode 100644 index 0000000000..a60196e341 --- /dev/null +++ b/assets/shaders/LunaGAUSS_S.fsh @@ -0,0 +1,106 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define GAUSS_S 1 //ON:1/OFF:0 /simple gauss filtering by Bigpet, slightly different from above /you can find standalone in https://github.com/hrydgard/ppsspp/issues/7242 +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define GAUSS_Sv 0 //ON:1/OFF:0 /simple gauss filtering by Bigpet, slightly different from above /you can find standalone in https://github.com/hrydgard/ppsspp/issues/7242 +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: FXAA, GAUSS_SQ, GAUSS_S +//Heavy: Guest_AA4o +//Extremely Heavy: Guest_AA4o(filtro) +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + +vec3 processGAUSS_S(vec3 color){ + //The parameters are hardcoded for now, but could be + //made into uniforms to control fromt he program. + float GAUSSS_SPAN_MAX = 1.5; + + //just a variable to describe the maximu + float GAUSSS_KERNEL_SIZE = 5.0; + //indices + // XX XX 00 XX XX + // XX 01 02 03 XX + // 04 05 06 07 08 + // XX 09 10 11 XX + // XX XX 12 XX XX + + //filter strength, rather smooth + // XX XX 01 XX XX + // XX 03 08 03 XX + // 01 08 10 08 01 + // XX 03 08 03 XX + // XX XX 01 XX XX + + vec2 offsetS = u_pixelDelta*GAUSSS_SPAN_MAX/GAUSSS_KERNEL_SIZE; + + vec3 cGaussS0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-2.0)).xyz; + vec3 cGaussS1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0,-1.0)).xyz; + vec3 cGaussS2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-1.0)).xyz; + vec3 cGaussS3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0,-1.0)).xyz; + vec3 cGaussS4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-2.0, 0.0)).xyz; + vec3 cGaussS5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 0.0)).xyz; + vec3 cGaussS6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 0.0)).xyz; + vec3 cGaussS7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 0.0)).xyz; + vec3 cGaussS8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 2.0, 0.0)).xyz; + vec3 cGaussS9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 1.0)).xyz; + vec3 cGaussS10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 1.0)).xyz; + vec3 cGaussS11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 1.0)).xyz; + vec3 cGaussS12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 2.0)).xyz; + + color = cGaussS0 + cGaussS1 + cGaussS2 + cGaussS3 + cGaussS4 + cGaussS5 + cGaussS6 + cGaussS7 + cGaussS8 + cGaussS9 + cGaussS10 + cGaussS11 + cGaussS12; + color = color / 58.0; + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processGAUSS_S(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaGAUSS_SQ.fsh b/assets/shaders/LunaGAUSS_SQ.fsh new file mode 100644 index 0000000000..37c22c3ff4 --- /dev/null +++ b/assets/shaders/LunaGAUSS_SQ.fsh @@ -0,0 +1,117 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define GAUSS_SQ 0 //ON:1/OFF:0 /full square gauss filtering +//#define Gsmoothing 3.5 //Default: 3.5 /increase for smoother(blurry) graphics +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define GAUSS_SQv 0 //ON:1/OFF:0 /full square gauss filtering +//#define Gsmoothingv 3.5 //Default: 3.5 /increase for smoother(blurry) graphics +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: FXAA, GAUSS_SQ, GAUSS_S +//Heavy: Guest_AA4o +//Extremely Heavy: Guest_AA4o(filtro) +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + +vec3 processGAUSS_SQ(vec3 color){ + float GAUSS_KERNEL_SIZE = 5.0; + //indices + // 00 01 02 03 04 + // 05 06 07 08 09 + // 10 11 12 13 14 + // 15 16 17 18 19 + // 20 21 22 23 24 + + //filter strength, rather smooth + // 01 04 07 04 01 + // 04 16 26 16 04 + // 07 26 41 26 07 + // 04 16 26 16 04 + // 01 04 07 04 01 + + vec2 offset = u_pixelDelta*u_setting.y/GAUSS_KERNEL_SIZE; + if (u_video==1.0){ + offset = u_pixelDelta*u_setting.y/GAUSS_KERNEL_SIZE; + } + + vec3 cGauss0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-2.0)).xyz; + vec3 cGauss1 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-2.0)).xyz; + vec3 cGauss2 = 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz; + vec3 cGauss3 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-2.0)).xyz; + vec3 cGauss4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-2.0)).xyz; + vec3 cGauss5 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-1.0)).xyz; + vec3 cGauss6 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz; + vec3 cGauss7 = 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz; + vec3 cGauss8 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz; + vec3 cGauss9 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-1.0)).xyz; + vec3 cGauss10= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz; + vec3 cGauss11= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz; + vec3 cGauss12= 41.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz; + vec3 cGauss13= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz; + vec3 cGauss14= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz; + vec3 cGauss15= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 1.0)).xyz; + vec3 cGauss16= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz; + vec3 cGauss17= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz; + vec3 cGauss18= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz; + vec3 cGauss19= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 1.0)).xyz; + vec3 cGauss20= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 2.0)).xyz; + vec3 cGauss21= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 2.0)).xyz; + vec3 cGauss22= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz; + vec3 cGauss23= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 2.0)).xyz; + vec3 cGauss24= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 2.0)).xyz; + + color.xyz = cGauss0 + cGauss1 + cGauss2 + cGauss3 + cGauss4 + cGauss5 + cGauss6 + cGauss7 + cGauss8 + cGauss9 + cGauss10 + cGauss11 + cGauss12 + cGauss13 + cGauss14 + cGauss15 + cGauss16 + cGauss17 + cGauss18 + cGauss19 + cGauss20 + cGauss21 + cGauss22 + cGauss23 + cGauss24; + color.xyz = color.xyz / 273.0; + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processGAUSS_SQ(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaGamma.fsh b/assets/shaders/LunaGamma.fsh new file mode 100644 index 0000000000..319d574a45 --- /dev/null +++ b/assets/shaders/LunaGamma.fsh @@ -0,0 +1,74 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//#define GAMMA 0 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 +//#define correction 0.75 //Default: 1.0 +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define GAMMAv 0 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 +//#define correctionv 0.75 //Default: 1.0 +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +vec3 processGAMMA(vec3 color){ + float correctionGAMMA = u_setting.y; + + vec3 gam=vec3(pow(color.r,1.0/abs(correctionGAMMA)),pow(color.g,1.0/abs(correctionGAMMA)),pow(color.b,1.0/abs(correctionGAMMA))); + return gam; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processGAMMA(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaGuest_AA4o.fsh b/assets/shaders/LunaGuest_AA4o.fsh new file mode 100644 index 0000000000..e833f9290c --- /dev/null +++ b/assets/shaders/LunaGuest_AA4o.fsh @@ -0,0 +1,227 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define Guest_AA4o 0 //ON:1/OFF:0 /alternative to FXAA /taken from http://forums.ppsspp.org/showthread.php?tid=6594&pid=124441#pid124441 +//#define scale 7.0 //Default: 7.0 / 4.0 -> smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) +//#define filtro 0 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res +//================ +//#define Guest_AA4ov 1 //ON:1/OFF:0 /alternative to FXAA /taken from http://forums.ppsspp.org/showthread.php?tid=6594&pid=124441#pid124441 +//#define scalev 3.0 //Default: 7.0 / 4.0 -> smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) +//#define filtrov 1 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier + +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: FXAA, GAUSS_SQ, GAUSS_S +//Heavy: Guest_AA4o +//Extremely Heavy: Guest_AA4o(filtro) +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +/* + AA shader 4.o / AA shader 4.o - filtro + + Copyright (C) 2014 guest(r) - guest.r@gmail.com + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + + +const vec3 dt = vec3(1.0,1.0,1.0); +vec3 texture2d (vec2 texcoord) { + float scaleGuest_AA4o = u_setting.y; + + vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scaleGuest_AA4o; + vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scaleGuest_AA4o; + vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; + vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; + vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; + vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; + + float m1=dot(abs(s00-s22),dt)+0.001; + float m2=dot(abs(s02-s20),dt)+0.001; + + return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2); +} +vec3 texture2dd (vec2 texcoord) { + float scaleGuest_AA4o = u_setting.y; + + vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scaleGuest_AA4o; + vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scaleGuest_AA4o; + vec3 c11 = texture2D(sampler0, texcoord ).xyz; + vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz; + vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz; + vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz; + vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz; + vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; + vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; + vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; + vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; + + float d1=dot(abs(c00-c22),dt)+0.001; + float d2=dot(abs(c20-c02),dt)+0.001; + float m1=dot(abs(s00-s22),dt)+0.001; + float m2=dot(abs(s02-s20),dt)+0.001; + + vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2)); + + return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2)); +} +vec3 processGuestAA4o() { + float scaleGuest_AA4o = u_setting.y; + + // Calculating texel coordinates + + vec2 size = vec2(480.0,272.0)*scaleGuest_AA4o; + vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scaleGuest_AA4o; + + vec2 OGL2Pos = v_texcoord0 * size; + vec2 fp = fract(OGL2Pos); + vec2 dx = vec2(inv_size.x,0.0); + vec2 dy = vec2(0.0, inv_size.y); + vec2 g1 = vec2(inv_size.x,inv_size.y); + vec2 g2 = vec2(-inv_size.x,inv_size.y); + + vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size; + + // Reading the texels + vec3 C0 = texture2d(pC4 - g1); + vec3 C1 = texture2d(pC4 - dy); + vec3 C2 = texture2d(pC4 - g2); + vec3 C3 = texture2d(pC4 - dx); + vec3 C4 = texture2d(pC4 ); + vec3 C5 = texture2d(pC4 + dx); + vec3 C6 = texture2d(pC4 + g2); + vec3 C7 = texture2d(pC4 + dy); + vec3 C8 = texture2d(pC4 + g1); + + vec3 ul, ur, dl, dr; + float m1, m2; + + m1 = dot(abs(C0-C4),dt)+0.001; + m2 = dot(abs(C1-C3),dt)+0.001; + ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2); + + m1 = dot(abs(C1-C5),dt)+0.001; + m2 = dot(abs(C2-C4),dt)+0.001; + ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2); + + m1 = dot(abs(C3-C7),dt)+0.001; + m2 = dot(abs(C6-C4),dt)+0.001; + dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2); + + m1 = dot(abs(C4-C8),dt)+0.001; + m2 = dot(abs(C5-C7),dt)+0.001; + dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2); + + vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y))); + + if(u_setting.z==1.0){ + vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)); + + inv_size = vec2(2.0/480.0,2.0/272.0)/scaleGuest_AA4o;; + + dx = vec2(inv_size.x,0.0); + dy = vec2(0.0,inv_size.y); + g1 = vec2( inv_size.x,inv_size.y); + g2 = vec2(-inv_size.x,inv_size.y); + pC4 = v_texcoord0; + + C0 = texture2dd(pC4-g1); + C1 = texture2dd(pC4-dy); + C2 = texture2dd(pC4-g2); + C3 = texture2dd(pC4-dx); + C4 = texture2dd(pC4 ); + C5 = texture2dd(pC4+dx); + C6 = texture2dd(pC4+g2); + C7 = texture2dd(pC4+dy); + C8 = texture2dd(pC4+g1); + + vec3 mn1 = min(min(C0,C1),C2); + vec3 mn2 = min(min(C3,C4),C5); + vec3 mn3 = min(min(C6,C7),C8); + vec3 mx1 = max(max(C0,C1),C2); + vec3 mx2 = max(max(C3,C4),C5); + vec3 mx3 = max(max(C6,C7),C8); + + mn1 = min(min(mn1,mn2),mn3); + mx1 = max(max(mx1,mx2),mx3); + + vec3 dif1 = abs(c11-mn1) + 0.0001*dt; + vec3 dif2 = abs(c11-mx1) + 0.0001*dt; + + float filterparam = 2.0; + + dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam)); + dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam)); + + c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x); + c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y); + c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z); + + result = c11; + } + + return result; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processGuestAA4o(); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaLCD3x.fsh b/assets/shaders/LunaLCD3x.fsh new file mode 100644 index 0000000000..670b78a75a --- /dev/null +++ b/assets/shaders/LunaLCD3x.fsh @@ -0,0 +1,84 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SCANLINE FILTERS: +//================ +//#define LCD3x 0 //ON:1/OFF:0 //different scanline shader +//#define b_sl 16.0 //Default: 16.0 /horizontal lines brightness +//#define b_lcd 4.0 //Default: 4.0 /vertical lines brightness +//#define sl_size 2.0 //Default: 2.0 /scanline size +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//OTHER FILTERS: +//================ +//#define LCD3xv 0 //ON:1/OFF:0 //different scanline shader +//#define b_slv 16.0 //Default: 16.0 /horizontal lines brightness +//#define b_lcdv 4.0 //Default: 4.0 /vertical lines brightness +//#define sl_sizev 2.0 //Default: 2.0 /scanline size +//================ +//Approximate performance hit +//Free: +//Light: SCANLINES, LCD3x +//Medium: +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + +varying vec2 v_texcoord1; + + +//=========== +//=========== + +vec3 processLCD3x(vec3 color){ + const vec3 offsets = 3.141592654 * vec3(1.0/2.0,1.0/2.0 - 2.0/3.0,1.0/2.0-4.0/3.0); + + float b_slLCD3x = u_setting.z; + float b_lcdLCD3x = u_setting.w; + float sl_sizeLCD3x = u_setting.y; + + vec2 angle = v_texcoord0.xy * v_texcoord1 / sl_sizeLCD3x; + + float yfactor = (b_slLCD3x + sin(angle.y)) / (b_slLCD3x + 1.0); + vec3 xfactors = (b_lcdLCD3x + sin(angle.x + offsets)) / (b_lcdLCD3x + 1.0); + + color.rgb = yfactor * xfactors * color.rgb; + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processLCD3x(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaM.fsh b/assets/shaders/LunaM.fsh deleted file mode 100644 index 65de19b647..0000000000 --- a/assets/shaders/LunaM.fsh +++ /dev/null @@ -1,1376 +0,0 @@ -//Note : Recommend to use PPSSPP v1.1.1-183-gb411fc0 or newer for full functionality, there were some bugs in earlier versions. -//Note2 : Upscaling, smoothing and sharpening filters are not set to be mixed between each other since the results are pointless(they counter each other). -// Only last one applies, so pick just one of them, mess around with it's settings and add other effects as needed. -//====================================================================================================================================================================== -//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res -//================ -#define FXAA 0 //ON:1/OFF:0 /default FXAA, orginal info below -//================ -#define GAUSS_SQ 0 //ON:1/OFF:0 /full square gauss filtering -#define Gsmoothing 3.5 //Default: 3.5 /increase for smoother(blurry) graphics -//================ -#define GAUSS_S 1 //ON:1/OFF:0 /simple gauss filtering by Bigpet, slightly different from above /you can find standalone in https://github.com/hrydgard/ppsspp/issues/7242 -//================ -#define Guest_AA4o 0 //ON:1/OFF:0 /alternative to FXAA /taken from http://forums.ppsspp.org/showthread.php?tid=6594&pid=124441#pid124441 -#define scale 7.0 //Default: 7.0 / 4.0 -> smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) -#define filtro 0 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier -//================ -//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing -//================ -#define SHARPEN 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default -#define value 7.5 //Default: 7.5 /higher = more visible effect -//================ -#define S_COM_V2 0 //Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate -#define S_val0 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect -//================ -//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" - //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically -//================ -#define xBR 0 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below -#define VariantB 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details -#define Variantx2 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR -//================ -#define xBRAccuracy 0 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below -#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding -#define CornerB 0 //ON:1/OFF:0 / activate only one -#define CornerD 0 //ON:1/OFF:0 -// CornerC //used as default if no other ones are defined -//================ -#define xHQ 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution -#define scaleoffset 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness -//================ -//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one -//================ -#define Deband 0 //ON:1/OFF:0 /Blurs -#define DeTol 16.0 //Default: 16.0 /tolerance, too high will look glitchy -//================ -#define Frost 0 //ON:1/OFF:0 /Dithering ~ adds noise -#define fTol 32.0 //Default: 32.0 /tolerance, too high will look glitchy -#define fSimple 1 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version -//================ -#define Bilateral 0 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH -//================ -//OTHER FILTERS: //Most effects from here on can be fully mixed without loosing previous effects. Exceptions: Natural Colors, Advanced Cartoon -//================ -#define BLOOM 1 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ -#define MIKU 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress -#define samples 2 //Default: 4 /higher = more glow, worse performance -#define quality 0.20 //Default: 0.18 /lower = smaller glow, better quality -#define Bpower 1.0 //Default: 1.0 /amount of bloom mixed -//================ -#define COLORED 1 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o -#define Cpower 0.25 //Default: 0.5 /strenght of the effect -//================ -#define ACARTOON 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack -#define th 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 -#define bb 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 -#define pp 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 -#define acpower 0.5 //Default:0.5 / higher = more effect, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -//================ -#define SHADEBOOST 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 -#define saturation 1.0 //Default: 1.0 //negative will look like inverted colors shader -#define brightness 1.0 //Default: 1.0 -#define contrast 1.0 //Default: 1.0 //negative will be... well negative;p -#define red 1.0 //Default: 1.0 -#define green 1.0 //Default: 1.0 -#define blue 1.0 //Default: 1.0 -//Shadeboost presets: //Shadeboost must be activated, presets override options above -#define SEPIA 0 //Moody coolors:) -#define GRAYSCALE 0 //Just for lols? -#define NEGATIVE 0 //As above -#define PSPCOLORS 0 //Makes the colors as on older PSP screens(colder) -//Simple color swap: //Shadeboost must be activated -#define rgbRBG 0 //green <-> blue -#define rgbBGR 0 //red <-> blue -#define rgbBRG 0 //red -> green -> blue -> red -#define rgbGRB 0 //red <-> green -#define rgbGBR 0 //red -> blue -> green -> red -//^All presets and color swap are simple switch ON:1/OFF:0, -//================ -#define GAMMA 0 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 -#define correction 0.85 //Default: 1.0 -//================ -#define SCANLINES 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) -#define SLsize 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high -#define SLcolor 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation -#define SLpower 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, -#define SLV 0 //ON:1/OFF:0 /vertical scanlines -#define noGradient 0 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line -//================ -#define VIGNETTE 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings -#define vsize 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values -#define VIpos 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) -#define deVi 0 //ON:1/OFF:0 /reverse vignette -//================ -#define TEST 0 //ON:1/OFF:0 /test mode, applies shaders on half of the screen for easy result comparison and tweaking -#define TESTANIM 0 //ON:1/OFF:0 /as above, animation slides shader from left to right and back /use only one -#define testAspeed 1.0 //animation speed -//================ -//Approximate performance hit -//Free: TEST, TESTANIM -//Light: SHARPEN, COLORED, SHADEBOOST, GAMMA, SCANLINES, VIGNETTE, BLOOM(<= 2 samples) -//Medium: FXAA, GAUSS_SQ, GAUSS_S, S_COM_V2, xHQ, Deband, Frost(fSimple), ACARTOON, BLOOM(== 3 samples) -//Heavy: Guest_AA4o, xBR, Frost, BLOOM(>= 4 samples), xBRAccuracy -//Extremely Heavy: Guest_AA4o(filtro), BLOOM(>= 8 samples), Bilateral -//====================================================================================================================================================================== -//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), -// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken -// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), -// other credits mentioned earlier, any more info / required licenses can be found below. - - - - -/* - FXAA shader, GLSL code adapted from: - http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA - Whitepaper describing the technique: - http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf -*/ - -/* - AA shader 4.o / AA shader 4.o - filtro - - Copyright (C) 2014 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - Hyllian's 5xBR v3.5a Shader - - Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from: - http://forums.ngemu.com/showthread.php?t=76098 - - by guest(r) (guest.r@gmail.com) - License: GNU-GPL - - Shader notes: looks better with sprite games -*/ - -/* - Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) - - Copyright (C) 2011-2015 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. - - Incorporates some of the ideas from SABR shader. Thanks to Joshua Street. -*/ - -/* - Advanced Cartoon shader - - Copyright (C) 2006 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#ifdef GL_ES -precision mediump float; -precision mediump int; -#endif - -uniform sampler2D sampler0; -uniform vec4 u_time; - - -//=========== -// The inverse of the texture dimensions along X and Y -uniform vec2 u_texelDelta; -uniform vec2 u_pixelDelta; -varying vec2 v_texcoord0; - -//=========== -//=========== -#if(FXAA==1) -vec3 processFXAA(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float FXAA_SPAN_MAX = 8.0; - float FXAA_REDUCE_MUL = 1.0/8.0; - float FXAA_REDUCE_MIN = (1.0/128.0); - - vec3 rgbNW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, -1.0) * u_texelDelta).xyz; - //#define Pass_Diffuse(v2TexCoord) texture2D(sampler0, v2TexCoord).xyz - //vec3 rgbNW = Pass_Diffuse(v2TexCoord + vec2(-u_texelDelta.x, -u_texelDelta.y)).xyz; - vec3 rgbNE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, -1.0) * u_texelDelta).xyz; - vec3 rgbSW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbSE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbM = texture2D(sampler0, v_texcoord0).xyz; - - vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW, luma); - float lumaNE = dot(rgbNE, luma); - float lumaSW = dot(rgbSW, luma); - float lumaSE = dot(rgbSE, luma); - float lumaM = dot( rgbM, luma); - - float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); - float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); - - vec2 dir; - dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); - dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); - - float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); - - float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); - - dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), - max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta; - - vec3 rgbA = (1.0/2.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (1.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (2.0/3.0 - 0.5)).xyz); - vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (0.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (3.0/3.0 - 0.5)).xyz); - float lumaB = dot(rgbB, luma); - - if((lumaB < lumaMin) || (lumaB > lumaMax)){ - color=rgbA; - } else { - color=rgbB; - } - return color; -} -#endif -#if(GAUSS_SQ==1) -vec3 processGAUSS_SQ(vec3 color){ - float GAUSS_KERNEL_SIZE = 5.0; - //indices - // 00 01 02 03 04 - // 05 06 07 08 09 - // 10 11 12 13 14 - // 15 16 17 18 19 - // 20 21 22 23 24 - - //filter strength, rather smooth - // 01 04 07 04 01 - // 04 16 26 16 04 - // 07 26 41 26 07 - // 04 16 26 16 04 - // 01 04 07 04 01 - - vec2 offset = u_pixelDelta*Gsmoothing/GAUSS_KERNEL_SIZE; - - vec3 cGauss0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-2.0)).xyz; - vec3 cGauss1 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-2.0)).xyz; - vec3 cGauss2 = 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz; - vec3 cGauss3 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-2.0)).xyz; - vec3 cGauss4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-2.0)).xyz; - vec3 cGauss5 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-1.0)).xyz; - vec3 cGauss6 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz; - vec3 cGauss7 = 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz; - vec3 cGauss8 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz; - vec3 cGauss9 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-1.0)).xyz; - vec3 cGauss10= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz; - vec3 cGauss11= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz; - vec3 cGauss12= 41.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz; - vec3 cGauss13= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz; - vec3 cGauss14= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz; - vec3 cGauss15= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 1.0)).xyz; - vec3 cGauss16= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz; - vec3 cGauss17= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz; - vec3 cGauss18= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz; - vec3 cGauss19= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 1.0)).xyz; - vec3 cGauss20= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 2.0)).xyz; - vec3 cGauss21= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 2.0)).xyz; - vec3 cGauss22= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz; - vec3 cGauss23= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 2.0)).xyz; - vec3 cGauss24= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 2.0)).xyz; - - color.xyz = cGauss0 + cGauss1 + cGauss2 + cGauss3 + cGauss4 + cGauss5 + cGauss6 + cGauss7 + cGauss8 + cGauss9 + cGauss10 + cGauss11 + cGauss12 + cGauss13 + cGauss14 + cGauss15 + cGauss16 + cGauss17 + cGauss18 + cGauss19 + cGauss20 + cGauss21 + cGauss22 + cGauss23 + cGauss24; - color.xyz = color.xyz / 273.0; - return color; -} -#endif -#if(GAUSS_S==1) -vec3 processGAUSS_S(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float GAUSSS_SPAN_MAX = 1.5; - - //just a variable to describe the maximu - float GAUSSS_KERNEL_SIZE = 5.0; - //indices - // XX XX 00 XX XX - // XX 01 02 03 XX - // 04 05 06 07 08 - // XX 09 10 11 XX - // XX XX 12 XX XX - - //filter strength, rather smooth - // XX XX 01 XX XX - // XX 03 08 03 XX - // 01 08 10 08 01 - // XX 03 08 03 XX - // XX XX 01 XX XX - - vec2 offsetS = u_pixelDelta*GAUSSS_SPAN_MAX/GAUSSS_KERNEL_SIZE; - - vec3 cGaussS0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-2.0)).xyz; - vec3 cGaussS1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0,-1.0)).xyz; - vec3 cGaussS2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-1.0)).xyz; - vec3 cGaussS3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0,-1.0)).xyz; - vec3 cGaussS4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-2.0, 0.0)).xyz; - vec3 cGaussS5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 0.0)).xyz; - vec3 cGaussS6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 0.0)).xyz; - vec3 cGaussS7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 0.0)).xyz; - vec3 cGaussS8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 2.0, 0.0)).xyz; - vec3 cGaussS9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 1.0)).xyz; - vec3 cGaussS10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 1.0)).xyz; - vec3 cGaussS11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 1.0)).xyz; - vec3 cGaussS12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 2.0)).xyz; - - color = cGaussS0 + cGaussS1 + cGaussS2 + cGaussS3 + cGaussS4 + cGaussS5 + cGaussS6 + cGaussS7 + cGaussS8 + cGaussS9 + cGaussS10 + cGaussS11 + cGaussS12; - color = color / 58.0; - return color; -} -#endif -#if(xBRAccuracy==1 || xBR==1) - -#if(xBRAccuracy==1) - -const float XBR_SCALE = 3.0; -const float lv2_cf = 2.0; -const vec3 rgbw = vec3(14.352, 28.176, 5.472); -const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); -const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25); - -#else -const float coef = 2.0; -const vec3 rgbw = vec3(16.163, 23.351, 8.4772); - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); - -#endif - -vec4 df(vec4 A, vec4 B) { - return abs(A-B); -} -#if(xBRAccuracy==1) - -// Compare two vectors and return their components are different. -vec4 diff(vec4 A, vec4 B) { - return vec4(notEqual(A, B)); -} - -// Determine if two vector components are equal based on a threshold. -vec4 eq(vec4 A, vec4 B) { - return (step(df(A, B), eq_threshold)); -} - -// Determine if two vector components are NOT equal based on a threshold. -vec4 neq(vec4 A, vec4 B) { - return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B)); -} -float c_df(vec3 c1, vec3 c2) { - vec3 df = abs(c1 - c2); - return df.r + df.g + df.b; -} -#else -bvec4 _and_(bvec4 A, bvec4 B) { - return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); -} -bvec4 _or_(bvec4 A, bvec4 B) { - return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); -} -bvec4 close(vec4 A, vec4 B) { - return (lessThan(df(A, B), vec4(15.0))); -} -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) { - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} -#endif -vec3 processxBR(vec3 color){ - vec2 pS = 1.0 / u_texelDelta.xy; - vec2 fp = fract(v_texcoord0.xy*pS.xy); - vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy; - vec2 dx = vec2(u_texelDelta.x,0.0); - vec2 dy = vec2(0.0,u_texelDelta.y); - vec2 y2 = dy + dy; vec2 x2 = dx + dx; - -#if(xBRAccuracy==1) - // px = pixel, edr = edge detection rule - vec4 edri, edr, edr_l, edr_u, px; - vec4 irlv0, irlv1, irlv2l, irlv2u; - vec4 fx, fx_l, fx_u; // inequations of straight lines. - - vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_u = delta_l.yxwz; -#else - bvec4 edr, edr_left, edr_up, px; // px = pixel, edr = edge detection rule - bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up; - bvec4 nc; // new_color - bvec4 fx, fx_left, fx_up; // inequations of straight lines. -#endif - - vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy).xyz; - vec3 B = texture2D(sampler0, TexCoord_0 -dy).xyz; - vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy).xyz; - vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz; - vec3 E = texture2D(sampler0, TexCoord_0 ).xyz; - vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz; - vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy).xyz; - vec3 H = texture2D(sampler0, TexCoord_0 +dy).xyz; - vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy).xyz; - vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz; - vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz; - vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz; - vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz; - vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz; - vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz; - vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz; - vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz; - vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz; - vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz; - vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz; - vec3 F4 = texture2D(sampler0, TexCoord_0 +x2 ).xyz; - - vec4 b = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw)); - vec4 c = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw)); - vec4 d = b.yzwx; - vec4 e = vec4(dot(E,rgbw)); - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw)); - vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw)); - vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw)); - vec4 f4 = h5.yzwx; - -#if(xBRAccuracy==1) - // These inequations define the line below which interpolation occurs. - fx = (Ao*fp.y+Bo*fp.x); - fx_l = (Ax*fp.y+Bx*fp.x); - fx_u = (Ay*fp.y+By*fp.x); - - irlv1 = irlv0 = diff(e,f) * diff(e,h); - -#if(CornerA==0) // A takes priority skipping other corners - #define SMOOTH_TIPS - // Corner C also default if no other ones used - irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) ); - int select1 = 0; -#if(CornerB==1) // Corner B - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) ); - select1 = 1; -#endif -#if(CornerD==1) // Corner D - if (select1==0){ - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0))); - } -#endif -#endif - - irlv2l = diff(e,g) * diff(d,g); - irlv2u = diff(e,c) * diff(b,c); - - vec4 fx45i = clamp((fx + delta -Co - Ci)/(2.0*delta ), 0.0, 1.0); - vec4 fx45 = clamp((fx + delta -Co )/(2.0*delta ), 0.0, 1.0); - vec4 fx30 = clamp((fx_l + delta_l -Cx )/(2.0*delta_l), 0.0, 1.0); - vec4 fx60 = clamp((fx_u + delta_u -Cy )/(2.0*delta_u), 0.0, 1.0); - - vec4 w1, w2; - w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw); - w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw); - w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw); - w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw); - - w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw); - w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw); - w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw); - w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw); - - edri = step(w1, w2) * irlv0; - edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1); - - w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw); - w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw); - - edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr; - edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr; - - fx45 = edr * fx45; - fx30 = edr_l * fx30; - fx60 = edr_u * fx60; - fx45i = edri * fx45i; - - w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw); - w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw); - - px = step(w1, w2); - -#ifdef SMOOTH_TIPS - vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i)); -#else - vec4 maximos = max(max(fx30, fx60), fx45); -#endif - - vec3 res1 = E; - res1 = mix(res1, mix(H, F, px.x), maximos.x); - res1 = mix(res1, mix(B, D, px.z), maximos.z); - - vec3 res2 = E; - res2 = mix(res2, mix(F, B, px.y), maximos.y); - res2 = mix(res2, mix(D, H, px.w), maximos.w); - - vec3 res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2))); -#else - // These inequations define the line below which interpolation occurs. - fx = greaterThan(Ao*fp.y+Bo*fp.x,Co); - fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx); - fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy); - - if (VariantB==1){ - bvec4 t1 = _and_( notEqual(e, f), notEqual(e, h) ); - bvec4 t2 = _and_( not(close(f, b)), not(close(h, d)) ); - bvec4 t3 = _and_( _and_( close(e, i), not(close(f, i4)) ), not(close(h, i5)) ); - bvec4 t4 = _or_( close(e, g), close(e, c) ); - interp_restriction_lv1 = _and_( t1, _or_( _or_(t2, t3), t4 ) ); - } else { - interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h))); - } - interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g))); - interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c))); - - edr = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1)); - edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left)); - edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up)); - - nc.x = ( edr.x && (fx.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) ); - nc.y = ( edr.y && (fx.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) ); - nc.z = ( edr.z && (fx.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) ); - nc.w = ( edr.w && (fx.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) ); - - px = lessThanEqual(df(e,f),df(e,h)); - - vec3 res; - if (Variantx2 == 1) { - vec3 E0 = E.xyz; - vec3 E1 = E.xyz; - vec3 E2 = E.xyz; - vec3 E3 = E.xyz; - vec3 P[4]; - P[0] = px.x ? F : H; - P[1] = px.y ? B : F; - P[2] = px.z ? D : B; - P[3] = px.w ? H : D; - if (edr.x) { - if (edr_left.x && edr_up.x) { - E3 = mix(E3 , P[0], 0.833333); - E2 = mix(E2 , P[0], 0.25); - E1 = mix(E1 , P[0], 0.25); - } else if (edr_left.x) { - E3 = mix(E3 , P[0], 0.75); - E2 = mix(E2 , P[0], 0.25); - } else if (edr_up.x) { - E3 = mix(E3 , P[0], 0.75); - E1 = mix(E1 , P[0], 0.25); - } else { - E3 = mix(E3 , P[0], 0.5); - } - } - if (edr.y) { - if (edr_left.y && edr_up.y) { - E1 = mix(E1 , P[1], 0.833333); - E3 = mix(E3 , P[1], 0.25); - E0 = mix(E0 , P[1], 0.25); - } else if (edr_left.y) { - E1 = mix(E1 , P[1], 0.75); - E3 = mix(E3 , P[1], 0.25); - } else if (edr_up.y) { - E1 = mix(E1 , P[1], 0.75); - E0 = mix(E0 , P[1], 0.25); - } else { - E1 = mix(E1 , P[1], 0.5); - } - } - if (edr.z) { - if (edr_left.z && edr_up.z) { - E0 = mix(E0 , P[2], 0.833333); - E1 = mix(E1 , P[2], 0.25); - E2 = mix(E2 , P[2], 0.25); - } else if (edr_left.z) { - E0 = mix(E0 , P[2], 0.75); - E1 = mix(E1 , P[2], 0.25); - } else if (edr_up.z) { - E0 = mix(E0 , P[2], 0.75); - E2 = mix(E2 , P[2], 0.25); - } else { - E0 = mix(E0 , P[2], 0.5); - } - } - if (edr.w) { - if (edr_left.w && edr_up.w) { - E2 = mix(E2 , P[3], 0.833333); - E0 = mix(E0 , P[3], 0.25); - E3 = mix(E3 , P[3], 0.25); - } else if (edr_left.w) { - E2 = mix(E2 , P[3], 0.75); - E0 = mix(E0 , P[3], 0.25); - } else if (edr_up.w) { - E2 = mix(E2 , P[3], 0.75); - E3 = mix(E3 , P[3], 0.25); - } else { - E2 = mix(E2 , P[3], 0.5); - } - } - res = (fp.x < 0.50) ? (fp.y < 0.50 ? E0 : E2) : (fp.y < 0.50 ? E1: E3); - } else { - res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E; - } -#endif - return res; -} -#endif -#if(BLOOM==1) -vec3 processBLOOM(vec3 color, vec3 colorB, int hatsu){ - #define factor 0.002 //Default: 0.002 /just an extra tweak for the bloom slightly higher values might look better in some cases, but too much can cause artifacts - vec4 sum = vec4(0); - int jb; - int diffx = samples - 1; - int ib; - int diffy = samples; - vec3 bloom; - for( ib= -diffy ;ib < diffy; ib++) { - for (jb = -diffx; jb < diffx; jb++) { - sum += texture2D(sampler0, v_texcoord0.xy + vec2(jb, ib)*factor) * quality; - } - } - if(color.r < 0.3 && color.g < 0.3 && color.b < 0.3) { - bloom = sum.xyz*sum.xyz*0.012 + color; - } else { - if(color.r < 0.5 && color.g < 0.5 && color.b < 0.5) { - bloom = sum.xyz*sum.xyz*0.009 + color; - } else { - bloom = sum.xyz*sum.xyz*0.0075 + color; - } - } - color = mix(color, bloom, Bpower); - if(hatsu==1) { - color = mix(colorB, color, 0.5); - } - return color; -} -vec3 processMIKU(vec3 color){ - vec3 mmm = vec3(0.1, 0.1, 0.1); - color = mix(color,mmm, 0.9); - return color; -} -#endif -#if(SCANLINES==1) -vec3 processSCANLINES(vec3 color){ - int vscan = SLV; - vec3 colorSL=color*SLcolor; - if(vscan==0){ - float rey = (1.0/float(SLsize)/u_pixelDelta.y); - float posSy = v_texcoord0.y*rey; - float lineSy = mod(posSy,2.0); - if (noGradient==1) { - bool clSy = lineSy<1.0; - lineSy = mix(1.0,0.0,float(clSy)); - } - color=color-lineSy; - } else { - float rex = (1.0/float(SLsize)/u_pixelDelta.x); - float posSx = v_texcoord0.x*(rex/1.0); - float lineSx = mod(posSx,2.0); - if (noGradient==1) { - bool clSx = lineSx<1.0; - lineSx = mix(1.0,0.0,float(clSx)); - } - color=color-lineSx; - } - if (noGradient==1) { - color=mix(color,clamp(colorSL,0.0,1.0),SLpower); - } else { - color=mix(color,colorSL,SLpower); - } - return color; -} -#endif -#if(SHARPEN==1) -vec3 processSHARPEN(vec3 color){ - color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*value; - color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*value; - return color; -} -#endif -#if(S_COM_V2==1) -vec3 processS_COM_V2(vec3 color){ - float width = (v_texcoord0.x); - float height = (v_texcoord0.y); - float px = (u_texelDelta.x); - float py = (u_texelDelta.y); - float mean = 0.6; - float dx = (mean * px); - float dy = (mean * py); - float CoefBlur = 2.0; - float CoefOrig = (1.0 + CoefBlur); - float Sharpen_val1 = ((S_val0 - 1.0) / 8.0); - vec3 S_Edge = vec3(0.2,0.2,0.2); - // get original pixel / color - - // compute blurred image (gaussian filter) - vec3 c1 = texture2D(sampler0, v_texcoord0 + vec2(-dx, -dy)).xyz; - vec3 c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -dy)).xyz; - vec3 c3 = texture2D(sampler0, v_texcoord0 + vec2( dx, -dy)).xyz; - vec3 c4 = texture2D(sampler0, v_texcoord0 + vec2(-dx, 0)).xyz; - vec3 c5 = texture2D(sampler0, v_texcoord0 + vec2( dx, 0)).xyz; - vec3 c6 = texture2D(sampler0, v_texcoord0 + vec2(-dx, dy)).xyz; - vec3 c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, dy)).xyz; - vec3 c8 = texture2D(sampler0, v_texcoord0 + vec2( dx, dy)).xyz; - - // gaussian filter - // [ 1, 2, 1 ] - // [ 2, 4, 2 ] - // [ 1, 2, 1 ] - // to normalize the values, we need to divide by the coeff sum - // 1 / (1+2+1+2+4+2+1+2+1) = 1 / 16 = 0.0625 - vec3 flou = (c1 + c3 + c6 + c8 + 2.0 * (c2 + c4 + c5 + c7) + 4.0 * color) * 0.0625; - - // substract blurred image from original image - vec3 corrected = CoefOrig * color - CoefBlur * flou; - - // edge detection - // Get neighbor points - // [ c1, c2, c3 ] - // [ c4, color, c5 ] - // [ c6, c7, c8 ] - c1 = texture2D(sampler0, v_texcoord0 + vec2(-px, -py)).xyz; - c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -py)).xyz; - c3 = texture2D(sampler0, v_texcoord0 + vec2( px, -py)).xyz; - c4 = texture2D(sampler0, v_texcoord0 + vec2(-px, 0)).xyz; - c5 = texture2D(sampler0, v_texcoord0 + vec2( px, 0)).xyz; - c6 = texture2D(sampler0, v_texcoord0 + vec2(-px, py)).xyz; - c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, py)).xyz; - c8 = texture2D(sampler0, v_texcoord0 + vec2( px, py)).xyz; - - // using Sobel filter - // horizontal gradient - // [ -1, 0, 1 ] - // [ -2, 0, 2 ] - // [ -1, 0, 1 ] - vec3 delta1 = (c3 + 2.0 * c5 + c8) - (c1 + 2.0 * c4 + c6); - - // Save some arithmetic operations to ensure PS2 compatibility - c1 += c3; - c6 += c8; - // vertical gradient - // [ -1, - 2, -1 ] - // [ 0, 0, 0 ] - // [ 1, 2, 1 ] - vec3 delta2 = (c6 + 2.0 * c7 ) - (c1 + 2.0 * c2 ); - vec3 checkshc = sqrt(delta1 * delta1 + delta2 * delta2); - // computation - if (checkshc.x > S_Edge.x || checkshc.y > S_Edge.y || checkshc.z > S_Edge.z) { - // if we have an edge, use sharpen - corrected = color * S_val0 - (c1 + c2 + c4 + c5 + c6 + c7 ) * Sharpen_val1; - } - return corrected; -} -#endif -#if(GAMMA==1) -vec3 processGAMMA(vec3 color){ - vec3 gam=vec3(pow(color.r,1.0/abs(correction)),pow(color.g,1.0/abs(correction)),pow(color.b,1.0/abs(correction))); - return gam; -} -#endif -#if(SHADEBOOST==1) -vec3 processSHADEBOOST(vec3 color){ - float sat = saturation; - float brt = brightness; - float con = contrast; - - // Increase or decrease theese values to adjust r, g and b color channels seperately - float AvgLumR = red; - float AvgLumG = green; - float AvgLumB = blue; - - //==========================presets - if(SEPIA==1) { - sat = 0.11; - brt = 0.87; - con = 1.20; - AvgLumR = 1.19930; - AvgLumG = 0.960; - AvgLumB = 0.6754; - } - if(GRAYSCALE==1) { - sat = 0.0; - brt = 1.0; - con = 1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(NEGATIVE==1) { - sat = 1.0; - brt = 1.0; - con = -1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if(PSPCOLORS==1) { - sat = 1.0; - brt = 1.0; - con = 1.0; - AvgLumR = 0.9593; - AvgLumG = 1.0739; - AvgLumB = 1.4604; - } - //========================== - const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); - - vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); - vec3 conRGB = vec3(0.5, 0.5, 0.5); - vec3 brtColor = color.rgb * brt; - vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c - vec3 satColor = mix(intensity, brtColor, sat); - vec3 conColor = mix(conRGB, satColor, con); - vec3 mixColor = AvgLumin * conColor; - color.rgb = mixColor; - if(rgbRBG==1) { - color.rgb = color.rbg; - } - if(rgbBGR==1) { - color.rgb = color.bgr; - } - if(rgbBRG==1) { - color.rgb = color.brg; - } - if(rgbGRB==1) { - color.rgb = color.grb; - } - if(rgbGBR==1) { - color.rgb = color.gbr; - } - return color; -} -#endif -#if(COLORED==1) -float overlay(float base, float blend) { - float result = 0.0; - if( base < 0.5 ) { - result = 2.0 * base * blend; - } else { - result = 1.0 - (1.0 - 2.0*(base-0.5)) * (1.0-blend); - } - return result; -} -vec3 processCOLORED(vec3 color){ - vec3 blur = color * 1.22520613262190495; - vec3 newcolor = vec3(overlay(color.r,blur.r), - overlay(color.g,blur.g), - overlay(color.b,blur.b)); - color = mix(color, newcolor, Cpower); - return color; -} -#endif -#if(TEST==1) -vec3 processTEST(vec3 color){ - if(v_texcoord0.x<0.5) { - color.xyz=color.xyz; - } else { - color.xyz=texture2D(sampler0, v_texcoord0.xy).xyz; - } - return color; -} -#endif -#if(TESTANIM==1) -vec3 processTESTANIM(vec3 color){ - float anim=(sin(u_time.x*testAspeed)+0.9)*0.55; - if(v_texcoord0.x tolerance || diff.g > tolerance || diff.b > tolerance; //workaround for the above - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Frost==1) -float rand(vec2 co){ - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); -} -vec3 processFrost(vec3 color) { - float tolerance = fTol/1638.4; - for (int i=1;i<5;i++) { - float p = u_pixelDelta.x * float(i) / rand(vec2(rand(v_texcoord0.xy),rand(v_texcoord0.xy))); - vec3 c1 = texture2D(sampler0,v_texcoord0.xy + vec2( p, p)).xyz; - vec3 c1b = texture2D(sampler0,v_texcoord0.xy + vec2( -p, -p)).xyz; - vec3 c2 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, p)).xyz; - vec3 c2b = texture2D(sampler0,v_texcoord0.xy + vec2( p, -p)).xyz; - vec3 c3 = texture2D(sampler0,v_texcoord0.xy + vec2( p,0.0)).xyz; - vec3 c3b = texture2D(sampler0,v_texcoord0.xy + vec2( -p,0.0)).xyz; - vec3 c4 = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, -p)).xyz; - vec3 c4b = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, p)).xyz; - vec3 avg; - if(fSimple==1) { - avg = (c1 + c2 + c3 + c4)/4.0; - } else { - avg = (c1 + c2 + c3 + c4 + c1b + c2b + c3b + c4b)/8.0; - } - vec3 diff = abs(color - avg); - bool a = diff.r > tolerance || diff.g > tolerance || diff.b > tolerance; - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Guest_AA4o==1) -const vec3 dt = vec3(1.0,1.0,1.0); -vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale; -vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale; -vec3 texture2d (vec2 texcoord) { - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2); -} -vec3 texture2dd (vec2 texcoord) { - - vec3 c11 = texture2D(sampler0, texcoord ).xyz; - vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz; - vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz; - vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz; - vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz; - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float d1=dot(abs(c00-c22),dt)+0.001; - float d2=dot(abs(c20-c02),dt)+0.001; - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2)); - - return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2)); -} -vec3 processGuestAA4o() { - // Calculating texel coordinates - - vec2 size = vec2(480.0,272.0)*scale; - vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scale; - - vec2 OGL2Pos = v_texcoord0 * size; - vec2 fp = fract(OGL2Pos); - vec2 dx = vec2(inv_size.x,0.0); - vec2 dy = vec2(0.0, inv_size.y); - vec2 g1 = vec2(inv_size.x,inv_size.y); - vec2 g2 = vec2(-inv_size.x,inv_size.y); - - vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size; - - // Reading the texels - vec3 C0 = texture2d(pC4 - g1); - vec3 C1 = texture2d(pC4 - dy); - vec3 C2 = texture2d(pC4 - g2); - vec3 C3 = texture2d(pC4 - dx); - vec3 C4 = texture2d(pC4 ); - vec3 C5 = texture2d(pC4 + dx); - vec3 C6 = texture2d(pC4 + g2); - vec3 C7 = texture2d(pC4 + dy); - vec3 C8 = texture2d(pC4 + g1); - - vec3 ul, ur, dl, dr; - float m1, m2; - - m1 = dot(abs(C0-C4),dt)+0.001; - m2 = dot(abs(C1-C3),dt)+0.001; - ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2); - - m1 = dot(abs(C1-C5),dt)+0.001; - m2 = dot(abs(C2-C4),dt)+0.001; - ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2); - - m1 = dot(abs(C3-C7),dt)+0.001; - m2 = dot(abs(C6-C4),dt)+0.001; - dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2); - - m1 = dot(abs(C4-C8),dt)+0.001; - m2 = dot(abs(C5-C7),dt)+0.001; - dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2); - - vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y))); - - if(filtro==1){ - vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)); - - inv_size = vec2(2.0/480.0,2.0/272.0)/scale;; - - dx = vec2(inv_size.x,0.0); - dy = vec2(0.0,inv_size.y); - g1 = vec2( inv_size.x,inv_size.y); - g2 = vec2(-inv_size.x,inv_size.y); - pC4 = v_texcoord0; - - C0 = texture2dd(pC4-g1); - C1 = texture2dd(pC4-dy); - C2 = texture2dd(pC4-g2); - C3 = texture2dd(pC4-dx); - C4 = texture2dd(pC4 ); - C5 = texture2dd(pC4+dx); - C6 = texture2dd(pC4+g2); - C7 = texture2dd(pC4+dy); - C8 = texture2dd(pC4+g1); - - vec3 mn1 = min(min(C0,C1),C2); - vec3 mn2 = min(min(C3,C4),C5); - vec3 mn3 = min(min(C6,C7),C8); - vec3 mx1 = max(max(C0,C1),C2); - vec3 mx2 = max(max(C3,C4),C5); - vec3 mx3 = max(max(C6,C7),C8); - - mn1 = min(min(mn1,mn2),mn3); - mx1 = max(max(mx1,mx2),mx3); - - vec3 dif1 = abs(c11-mn1) + 0.0001*dt; - vec3 dif2 = abs(c11-mx1) + 0.0001*dt; - - float filterparam = 2.0; - - dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam)); - dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam)); - - c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x); - c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y); - c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z); - - result = c11; - } - - return result; -} -#endif -#if(Bilateral==1) - - -#define SIGMA 10.0 -#define BSIGMA 0.1 -#define MSIZE 15 -float normpdf(float x, float sigma) { - return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma; -} - -float normpdf3(vec3 v, float sigma) { - return 0.39894*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma; -} - -vec3 processBilateral(vec3 color) { - const int kSize = (MSIZE-1)/2; - float kernel[MSIZE]; - vec3 final_colour; - - // Create the 1-D kernel - float Zxx = 0.0; - for (int j = 0; j <= kSize; ++j) { - kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA); - } - // sigma 10.0, MSIZE 15 - //someone mentioned performance increase with precompiled kernel, but really don't see that - //const float kernel[MSIZE] = float[MSIZE](0.031225216, 0.033322271, 0.035206333, 0.036826804, 0.038138565, 0.039104044, 0.039695028, 0.039894000, 0.039695028, 0.039104044, 0.038138565, 0.036826804, 0.035206333, 0.033322271, 0.031225216); - vec3 cc; - float factorNB; - float bZ = 1.0/normpdf(0.0, BSIGMA); - // Read out the texels - for (int i=-kSize; i <= kSize; ++i) { - for (int j=-kSize; j <= kSize; ++j) { - cc = texture2D(sampler0, v_texcoord0.xy+vec2(float(i)*u_pixelDelta.x,float(j)*u_pixelDelta.x)).rgb; - factorNB = normpdf3(cc-color, BSIGMA)*bZ*kernel[kSize+j]*kernel[kSize+i]; - Zxx += factorNB; - final_colour += factorNB*cc; - } - } - return final_colour/Zxx; -} -#endif -void main() { - vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; - #if(FXAA==1) - color=processFXAA(color); - #endif - #if(GAUSS_SQ==1) - color=processGAUSS_SQ(color); - #endif - #if(GAUSS_S==1) - color=processGAUSS_S(color); - #endif - #if(Guest_AA4o==1) - color=processGuestAA4o(); - #endif - #if(SHARPEN==1) - color=processSHARPEN(color); - #endif - #if(S_COM_V2==1) - color=processS_COM_V2(color); - #endif - #if(xHQ==1) - color=processxHQ(color); - #endif - #if(xBRAccuracy==1 || xBR==1) - color=processxBR(color); - #endif - #if(Deband==1) - color=processDeband(color); - #endif - #if(Frost==1) - color=processFrost(color); - #endif - #if(Bilateral==1) - color=processBilateral(color); - #endif - #if(ACARTOON==1) - color=processACARTOON(color); - #endif - #if(BLOOM==1) - vec3 colorB=color; - int hatsu = 0; - #if(MIKU==1) - hatsu = 1; - color=processMIKU(color); - #endif - color=processBLOOM(color, colorB, hatsu); - #endif - #if(COLORED==1) - color=processCOLORED(color); - #endif - #if(SHADEBOOST==1) - color = processSHADEBOOST(color); - #endif - #if(GAMMA==1) - color = processGAMMA(color); - #endif - #if(SCANLINES==1) - color = processSCANLINES(color); - #endif - #if(VIGNETTE==1) - color = processVIGNETTE(color); - #endif - #if(TEST==1) - color = processTEST(color); - #endif - #if(TESTANIM==1) - color = processTESTANIM(color); - #endif - gl_FragColor.xyz=color; - gl_FragColor.a = 1.0; -} diff --git a/assets/shaders/LunaNaturalColors.fsh b/assets/shaders/LunaNaturalColors.fsh new file mode 100644 index 0000000000..cff260ae2a --- /dev/null +++ b/assets/shaders/LunaNaturalColors.fsh @@ -0,0 +1,114 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//#define NATURALC 0 //ON:1/OFF:0 /by popular demand, natular colors, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects +//#define ncpower 1.0 //Default: 1.0 / reduce for more subtle effect +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define NATURALCv 0 //ON:1/OFF:0 /by popular demand, natular colors, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects +//#define ncpowerv 1.0 //Default: 1.0 / reduce for more subtle effect +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + +varying vec4 v_texcoord1; +varying vec4 v_texcoord2; +varying vec4 v_texcoord3; +varying vec4 v_texcoord4; + + +//=========== +//=========== + +const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212, + 0.587,-0.275,-0.523, + 0.114,-0.321, 0.311); + +const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0, + 0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523, + 0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149); + +const vec3 val00 = vec3( 1.2, 1.2, 1.2); +vec3 processNATURALC(vec3 color){ + vec3 c0,c1; + + c0 = texture2D(sampler0,v_texcoord1.xy).xyz; + c0+=(texture2D(sampler0,v_texcoord1.zy).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord1.xw).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord1.zw).xyz)*0.125; + + c0+= texture2D(sampler0,v_texcoord2.xy).xyz; + c0+=(texture2D(sampler0,v_texcoord2.zy).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord2.xw).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord2.zw).xyz)*0.125; + + c0+= texture2D(sampler0,v_texcoord3.xy).xyz; + c0+=(texture2D(sampler0,v_texcoord3.zy).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord3.xw).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord3.zw).xyz)*0.125; + + c0+= texture2D(sampler0,v_texcoord4.xy).xyz; + c0+=(texture2D(sampler0,v_texcoord4.zy).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord4.xw).xyz)*0.25; + c0+=(texture2D(sampler0,v_texcoord4.zw).xyz)*0.125; + c0*=0.153846153846; + + c1=RGBtoYIQ*c0; + + c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz); + + float ncpowerNATURALC = u_setting.y; + + color=mix(color,YIQtoRGB*c1,ncpowerNATURALC); + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processNATURALC(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaPixelate.fsh b/assets/shaders/LunaPixelate.fsh new file mode 100644 index 0000000000..b23b5595a3 --- /dev/null +++ b/assets/shaders/LunaPixelate.fsh @@ -0,0 +1,31 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +varying vec2 v_texcoord0; +uniform vec4 u_setting; + +vec3 processPixelate() { + + float factorX = 1.0 / (480.0 / u_setting.y); + float factorY = 1.0 / (272.0 / u_setting.y); + + float x = floor(v_texcoord0.x / factorX) * factorX; + float y = floor(v_texcoord0.y / factorY) * factorY; + + vec3 color = texture2D(sampler0, vec2(x, y)).xyz; + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processPixelate(); + } + + gl_FragColor.xyz=color.xyz; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaScan.vsh b/assets/shaders/LunaScan.vsh new file mode 100644 index 0000000000..953f2feb64 --- /dev/null +++ b/assets/shaders/LunaScan.vsh @@ -0,0 +1,12 @@ +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +attribute vec4 a_position; +attribute vec2 a_texcoord0; +varying vec2 v_texcoord0; +varying vec2 v_texcoord1; + +void main() { + v_texcoord0 = a_texcoord0 + 0.000001; //HLSL precision workaround + gl_Position = a_position; + v_texcoord1 = 3.141592654 * (1.0/u_pixelDelta); +} diff --git a/assets/shaders/LunaShadeboostA.fsh b/assets/shaders/LunaShadeboostA.fsh new file mode 100644 index 0000000000..fd0bdfc24e --- /dev/null +++ b/assets/shaders/LunaShadeboostA.fsh @@ -0,0 +1,108 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//#define SHADEBOOST 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +//#define saturation 1.0 //Default: 1.0 //negative will look like inverted colors shader +//#define brightness 1.0 //Default: 1.0 +//#define contrast 1.0 //Default: 1.0 //negative will be... well negative;p +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define SHADEBOOSTv 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +//#define saturationv 1.0 //Default: 1.0 //negative will look like inverted colors shader +//#define brightnessv 1.0 //Default: 1.0 +//#define contrastv 1.0 //Default: 1.0 //negative will be... well negative;p +//#define redv 1.0 //Default: 1.0 +//#define greenv 1.0 //Default: 1.0 +//#define bluev 1.0 //Default: 1.0 +//Shadeboost presets: //Shadeboost must be activated, presets override options above +//#define SEPIAv 0 //Moody coolors:) +//#define GRAYSCALEv 0 //Just for lols? +//#define NEGATIVEv 0 //As above +//#define PSPCOLORSv 0 //Makes the colors as on older PSP screens(colder) +//Simple color swap: //Shadeboost must be activated +//#define rgbRBGv 0 //green <-> blue +//#define rgbBGRv 0 //red <-> blue +//#define rgbBRGv 0 //red -> green -> blue -> red +//#define rgbGRBv 0 //red <-> green +//#define rgbGBRv 0 //red -> blue -> green -> red +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +vec3 processSHADEBOOST(vec3 color){ + float sat = u_setting.y; + float brt = u_setting.z; + float con = u_setting.w; + + // Increase or decrease theese values to adjust r, g and b color channels seperately + float AvgLumR = 1.0; + float AvgLumG = 1.0; + float AvgLumB = 1.0; + + //========================== + const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); + + vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); + vec3 conRGB = vec3(0.5, 0.5, 0.5); + vec3 brtColor = color.rgb * brt; + vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c + vec3 satColor = mix(intensity, brtColor, sat); + vec3 conColor = mix(conRGB, satColor, con); + vec3 mixColor = AvgLumin * conColor; + color.rgb = mixColor; + + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processSHADEBOOST(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaShadeboostB.fsh b/assets/shaders/LunaShadeboostB.fsh new file mode 100644 index 0000000000..8a981311f8 --- /dev/null +++ b/assets/shaders/LunaShadeboostB.fsh @@ -0,0 +1,108 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//#define SHADEBOOST 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +//#define red 1.0 //Default: 1.0 +//#define green 1.0 //Default: 1.0 +//#define blue 1.0 //Default: 1.0 +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define SHADEBOOSTv 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +//#define saturationv 1.0 //Default: 1.0 //negative will look like inverted colors shader +//#define brightnessv 1.0 //Default: 1.0 +//#define contrastv 1.0 //Default: 1.0 //negative will be... well negative;p +//#define redv 1.0 //Default: 1.0 +//#define greenv 1.0 //Default: 1.0 +//#define bluev 1.0 //Default: 1.0 +//Shadeboost presets: //Shadeboost must be activated, presets override options above +//#define SEPIAv 0 //Moody coolors:) +//#define GRAYSCALEv 0 //Just for lols? +//#define NEGATIVEv 0 //As above +//#define PSPCOLORSv 0 //Makes the colors as on older PSP screens(colder) +//Simple color swap: //Shadeboost must be activated +//#define rgbRBGv 0 //green <-> blue +//#define rgbBGRv 0 //red <-> blue +//#define rgbBRGv 0 //red -> green -> blue -> red +//#define rgbGRBv 0 //red <-> green +//#define rgbGBRv 0 //red -> blue -> green -> red +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +vec3 processSHADEBOOST(vec3 color){ + float sat = 1.0; + float brt = 1.0; + float con = 1.0; + + // Increase or decrease theese values to adjust r, g and b color channels seperately + float AvgLumR = u_setting.y; + float AvgLumG = u_setting.z; + float AvgLumB = u_setting.w; + + //========================== + const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); + + vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); + vec3 conRGB = vec3(0.5, 0.5, 0.5); + vec3 brtColor = color.rgb * brt; + vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c + vec3 satColor = mix(intensity, brtColor, sat); + vec3 conColor = mix(conRGB, satColor, con); + vec3 mixColor = AvgLumin * conColor; + color.rgb = mixColor; + + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processSHADEBOOST(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaShadeboostC.fsh b/assets/shaders/LunaShadeboostC.fsh new file mode 100644 index 0000000000..fb5fcde910 --- /dev/null +++ b/assets/shaders/LunaShadeboostC.fsh @@ -0,0 +1,102 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//Simple color swap: //Shadeboost must be activated +//#define rgbRBG 0 //green <-> blue +//#define rgbBGR 0 //red <-> blue +//#define rgbBRG 0 //red -> green -> blue -> red +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define SHADEBOOSTv 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +//#define saturationv 1.0 //Default: 1.0 //negative will look like inverted colors shader +//#define brightnessv 1.0 //Default: 1.0 +//#define contrastv 1.0 //Default: 1.0 //negative will be... well negative;p +//#define redv 1.0 //Default: 1.0 +//#define greenv 1.0 //Default: 1.0 +//#define bluev 1.0 //Default: 1.0 +//Shadeboost presets: //Shadeboost must be activated, presets override options above +//#define SEPIAv 0 //Moody coolors:) +//#define GRAYSCALEv 0 //Just for lols? +//#define NEGATIVEv 0 //As above +//#define PSPCOLORSv 0 //Makes the colors as on older PSP screens(colder) +//Simple color swap: //Shadeboost must be activated +//#define rgbRBGv 0 //green <-> blue +//#define rgbBGRv 0 //red <-> blue +//#define rgbBRGv 0 //red -> green -> blue -> red +//#define rgbGRBv 0 //red <-> green +//#define rgbGBRv 0 //red -> blue -> green -> red +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +vec3 processSHADEBOOST(vec3 color){ + + float rgbRBG = u_setting.y; + float rgbBGR = u_setting.z; + float rgbBRG = u_setting.w; + + if(rgbRBG==1.0) { + color.rgb = color.rbg; + } + if(rgbBGR==1.0) { + color.rgb = color.bgr; + } + if(rgbBRG==1.0) { + color.rgb = color.brg; + } + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processSHADEBOOST(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaShadeboostD.fsh b/assets/shaders/LunaShadeboostD.fsh new file mode 100644 index 0000000000..9dec56169f --- /dev/null +++ b/assets/shaders/LunaShadeboostD.fsh @@ -0,0 +1,126 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//#define PSPCOLORS 0 //Makes the colors as on older PSP screens(colder) +//Simple color swap: //Shadeboost must be activated +//#define rgbGRB 0 //red <-> green +//#define rgbGBR 0 //red -> blue -> green -> red +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define SHADEBOOSTv 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +//#define saturationv 1.0 //Default: 1.0 //negative will look like inverted colors shader +//#define brightnessv 1.0 //Default: 1.0 +//#define contrastv 1.0 //Default: 1.0 //negative will be... well negative;p +//#define redv 1.0 //Default: 1.0 +//#define greenv 1.0 //Default: 1.0 +//#define bluev 1.0 //Default: 1.0 +//Shadeboost presets: //Shadeboost must be activated, presets override options above +//#define SEPIAv 0 //Moody coolors:) +//#define GRAYSCALEv 0 //Just for lols? +//#define NEGATIVEv 0 //As above +//#define PSPCOLORSv 0 //Makes the colors as on older PSP screens(colder) +//Simple color swap: //Shadeboost must be activated +//#define rgbRBGv 0 //green <-> blue +//#define rgbBGRv 0 //red <-> blue +//#define rgbBRGv 0 //red -> green -> blue -> red +//#define rgbGRBv 0 //red <-> green +//#define rgbGBRv 0 //red -> blue -> green -> red +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +vec3 processSHADEBOOST(vec3 color){ + float sat = 1.0; + float brt = 1.0; + float con = 1.0; + + // Increase or decrease theese values to adjust r, g and b color channels seperately + float AvgLumR = 1.0; + float AvgLumG = 1.0; + float AvgLumB = 1.0; + float PSPCOLORS = u_setting.w; + + //==========================presets + if(PSPCOLORS==1.0) { + sat = 1.0; + brt = 1.0; + con = 1.0; + AvgLumR = 0.9593; + AvgLumG = 1.0739; + AvgLumB = 1.4604; + } + //========================== + const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); + + vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); + vec3 conRGB = vec3(0.5, 0.5, 0.5); + vec3 brtColor = color.rgb * brt; + vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c + vec3 satColor = mix(intensity, brtColor, sat); + vec3 conColor = mix(conRGB, satColor, con); + vec3 mixColor = AvgLumin * conColor; + color.rgb = mixColor; + float rgbGRB = u_setting.y; + float rgbGBR = u_setting.z; + if(rgbGRB==1.0) { + color.rgb = color.grb; + } + if(rgbGBR==1.0) { + color.rgb = color.gbr; + } + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processSHADEBOOST(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaShadeboostE.fsh b/assets/shaders/LunaShadeboostE.fsh new file mode 100644 index 0000000000..19e19e369d --- /dev/null +++ b/assets/shaders/LunaShadeboostE.fsh @@ -0,0 +1,137 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//COLORING FILTERS: +//================ +//Shadeboost presets: //Shadeboost must be activated, presets override options above +//#define SEPIA 0 //Moody coolors:) +//#define GRAYSCALE 0 //Just for lols? +//#define NEGATIVE 0 //As above +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//COLORING FILTERS: +//================ +//#define SHADEBOOSTv 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +//#define saturationv 1.0 //Default: 1.0 //negative will look like inverted colors shader +//#define brightnessv 1.0 //Default: 1.0 +//#define contrastv 1.0 //Default: 1.0 //negative will be... well negative;p +//#define redv 1.0 //Default: 1.0 +//#define greenv 1.0 //Default: 1.0 +//#define bluev 1.0 //Default: 1.0 +//Shadeboost presets: //Shadeboost must be activated, presets override options above +//#define SEPIAv 0 //Moody coolors:) +//#define GRAYSCALEv 0 //Just for lols? +//#define NEGATIVEv 0 //As above +//#define PSPCOLORSv 0 //Makes the colors as on older PSP screens(colder) +//Simple color swap: //Shadeboost must be activated +//#define rgbRBGv 0 //green <-> blue +//#define rgbBGRv 0 //red <-> blue +//#define rgbBRGv 0 //red -> green -> blue -> red +//#define rgbGRBv 0 //red <-> green +//#define rgbGBRv 0 //red -> blue -> green -> red +//^All presets and color swap are simple switch ON:1/OFF:0 +//================ +//Approximate performance hit +//Free: +//Light: COLORED, SHADEBOOST, GAMMA +//Medium: NATURALC +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +vec3 processSHADEBOOST(vec3 color){ + float sat = 1.0; + float brt = 1.0; + float con = 1.0; + + // Increase or decrease theese values to adjust r, g and b color channels seperately + float AvgLumR = 1.0; + float AvgLumG = 1.0; + float AvgLumB = 1.0; + float SEPIA = u_setting.y; + float GRAYSCALE = u_setting.z; + float NEGATIVE = u_setting.w; + + //==========================presets + if(SEPIA==1.0) { + sat = 0.11; + brt = 0.87; + con = 1.20; + AvgLumR = 1.19930; + AvgLumG = 0.960; + AvgLumB = 0.6754; + } + if(GRAYSCALE==1.0) { + sat = 0.0; + brt = 1.0; + con = 1.0; + AvgLumR = 1.0; + AvgLumG = 1.0; + AvgLumB = 1.0; + } + if(NEGATIVE==1.0) { + sat = 1.0; + brt = 1.0; + con = -1.0; + AvgLumR = 1.0; + AvgLumG = 1.0; + AvgLumB = 1.0; + } + //========================== + const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); + + vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); + vec3 conRGB = vec3(0.5, 0.5, 0.5); + vec3 brtColor = color.rgb * brt; + vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c + vec3 satColor = mix(intensity, brtColor, sat); + vec3 conColor = mix(conRGB, satColor, con); + vec3 mixColor = AvgLumin * conColor; + color.rgb = mixColor; + + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processSHADEBOOST(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaSimpleScanlines.fsh b/assets/shaders/LunaSimpleScanlines.fsh new file mode 100644 index 0000000000..0689e21429 --- /dev/null +++ b/assets/shaders/LunaSimpleScanlines.fsh @@ -0,0 +1,105 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SCANLINE FILTERS: +//================ +//#define SCANLINES 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) +//#define SLsize 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high +//#define SLcolor 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation +//#define SLpower 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, +#define SLV 0 //ON:1/OFF:0 /vertical scanlines +#define SSnoGradient 1 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//OTHER FILTERS: +//================ +//#define SCANLINESv 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) +//#define SLsizev 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high +//#define SLcolorv 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation +//#define SLpowerv 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, +//#define SLVv 0 //ON:1/OFF:0 /vertical scanlines +//#define noGradientv 0 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line//================ +//Approximate performance hit +//Free: +//Light: SCANLINES, LCD3x +//Medium: +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +vec3 processSCANLINES(vec3 color){ + int vscan = SLV; + int noGradient = SSnoGradient; + vec3 colorSL=color*u_setting.w; + + float SLsizeSCANLINES = u_setting.y; + float SLpowerSCANLINES = u_setting.z; + + + if(vscan==0){ + float rey = (1.0/SLsizeSCANLINES/u_pixelDelta.y); + float posSy = v_texcoord0.y*rey; + float lineSy = mod(posSy,2.0); + if (noGradient==1) { + bool clSy = lineSy<1.0; + lineSy = mix(1.0,0.0,float(clSy)); + } + color=color-lineSy; + } else { + float rex = (1.0/SLsizeSCANLINES/u_pixelDelta.x); + float posSx = v_texcoord0.x*(rex/1.0); + float lineSx = mod(posSx,2.0); + if (noGradient==1) { + bool clSx = lineSx<1.0; + lineSx = mix(1.0,0.0,float(clSx)); + } + color=color-lineSx; + } + if (noGradient==1) { + color=mix(color,clamp(colorSL,0.0,1.0),SLpowerSCANLINES); + } else { + color=mix(color,colorSL,SLpowerSCANLINES); + } + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processSCANLINES(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaSimpleSharpen.fsh b/assets/shaders/LunaSimpleSharpen.fsh new file mode 100644 index 0000000000..f387da0a89 --- /dev/null +++ b/assets/shaders/LunaSimpleSharpen.fsh @@ -0,0 +1,71 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing +//================ +//#define SHARPEN 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default +//#define value 7.5 //Default: 7.5 /higher = more visible effect +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing +//================ +//#define SHARPENv 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default +//#define valuev 7.5 //Default: 7.5 /higher = more visible effect +//================ +//Approximate performance hit +//Free: +//Light: SHARPEN +//Medium: S_COM_V2 +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +vec3 processSHARPEN(vec3 color){ + float valueSHARPEN = u_setting.y; + color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*valueSHARPEN; + color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*valueSHARPEN; + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processSHARPEN(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaTest.fsh b/assets/shaders/LunaTest.fsh new file mode 100644 index 0000000000..8bc2300f66 --- /dev/null +++ b/assets/shaders/LunaTest.fsh @@ -0,0 +1,77 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// Attach to any effect you wish to easily test +//======================================================================================= +//=========================================TEST========================================== +//======================================================================================= +//#define TEST 0 //ON:1/OFF:0 /test mode, applies shaders on half of the screen for easy result comparison and tweaking +//#define TESTANIM 0 //ON:1/OFF:0 /as above, animation slides shader from left to right and back /use only one +//#define testAspeed 1.0 //animation speed +//================ +//Approximate performance hit +//Free: TEST, TESTANIM +//Light: +//Medium: +//Heavy: +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform sampler2D sampler1; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +vec3 processTEST(vec3 color){ + if(v_texcoord0.x<0.5) { + color.xyz=color.xyz; + } else { + color.xyz=texture2D(sampler1, v_texcoord0.xy).xyz; + } + return color; +} + +vec3 processTESTANIM(vec3 color){ + float anim=(sin(u_time.x*u_setting.y)+0.9)*0.55; + if(v_texcoord0.x smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) -#define filtro 0 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier -//================ -//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing -//================ -#define SHARPEN 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default -#define value 7.5 //Default: 7.5 /higher = more visible effect -//================ -#define S_COM_V2 0 //ON:1/OFF:0 /Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate -#define S_val0 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect -//================ -//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" - //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically -//================ -#define xBR 0 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below -#define VariantB 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details -#define Variantx2 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR -//================ -#define xBRAccuracy 0 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below -#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding -#define CornerB 0 //ON:1/OFF:0 / activate only one -#define CornerD 0 //ON:1/OFF:0 -// CornerC //used as default if no other ones are defined -//================ -#define xHQ 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution -#define scaleoffset 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness -//================ -//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one -//================ -#define Deband 1 //ON:1/OFF:0 /Blurs -#define DeTol 16.0 //Default: 16.0 /tolerance, too high will look glitchy -//================ -#define Frost 0 //ON:1/OFF:0 /Dithering ~ adds noise -#define fTol 32.0 //Default: 32.0 /tolerance, too high will look glitchy -#define fSimple 0 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version -//================ -#define Bilateral 0 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH -//================ -//OTHER FILTERS: //Most effects from here on can be fully mixed without loosing previous effects. Exceptions: Natural Colors, Advanced Cartoon -//================ -#define BLOOM 1 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ -#define MIKU 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress -#define samples 3 //Default: 4 /higher = more glow, worse performance -#define quality 0.14 //Default: 0.18 /lower = smaller glow, better quality -#define Bpower 1.0 //Default: 1.0 /amount of bloom mixed -//================ -#define COLORED 0 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o -#define Cpower 0.5 //Default: 0.5 /strenght of the effect -//================ -#define NATURALC 0 //ON:1/OFF:0 /by popular demand, natular colors, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -#define ncpower 0.5 //Default:0.5 / higher = more natural color, check note line above -//================ -#define ACARTOON 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack -#define th 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 -#define bb 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 -#define pp 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 -#define acpower 0.5 //Default:0.5 / higher = more effect, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -//================ -#define SHADEBOOST 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 -#define saturation 1.0 //Default: 1.0 //negative will look like inverted colors shader -#define brightness 1.0 //Default: 1.0 -#define contrast 1.0 //Default: 1.0 //negative will be... well negative;p -#define red 1.0 //Default: 1.0 -#define green 1.0 //Default: 1.0 -#define blue 1.0 //Default: 1.0 -//Shadeboost presets: //Shadeboost must be activated, presets override options above -#define SEPIA 0 //Moody coolors:) -#define GRAYSCALE 0 //Just for lols? -#define NEGATIVE 0 //As above -#define PSPCOLORS 0 //Makes the colors as on older PSP screens(colder) -//Simple color swap: //Shadeboost must be activated -#define rgbRBG 0 //green <-> blue -#define rgbBGR 0 //red <-> blue -#define rgbBRG 0 //red -> green -> blue -> red -#define rgbGRB 0 //red <-> green -#define rgbGBR 0 //red -> blue -> green -> red -//^All presets and color swap are simple switch ON:1/OFF:0 -//================ -#define GAMMA 1 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 -#define correction 0.75 //Default: 1.0 -//================ -#define SCANLINES 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) -#define SLsize 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high -#define SLcolor 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation -#define SLpower 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, -#define SLV 0 //ON:1/OFF:0 /vertical scanlines -#define noGradient 0 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line -//================ -#define LCD3x 0 //ON:1/OFF:0 //different scanline shader -#define b_sl 16.0 //Default: 16.0 /horizontal lines brightness -#define b_lcd 4.0 //Default: 4.0 /vertical lines brightness -#define sl_size 2.0 //Default: 2.0 /scanline size -//================ -#define VIGNETTE 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings -#define vsize 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values -#define VIpos 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) -#define deVi 0 //ON:1/OFF:0 /reverse vignette -//======================================================================================= -//=========================================VIDEO========================================= -//======================================================================================= -//SMOOTHING FILTERS: //If you love smooth graphics ~ those are also great for downscaling - to do that, you need to use higher rendering res than your display res -//================ -#define FXAAv 0 //ON:1/OFF:0 /default FXAA, orginal info below -//================ -#define GAUSS_SQv 0 //ON:1/OFF:0 /full square gauss filtering -#define Gsmoothingv 3.5 //Default: 3.5 /increase for smoother(blurry) graphics -//================ -#define GAUSS_Sv 0 //ON:1/OFF:0 /simple gauss filtering by Bigpet, slightly different from above /you can find standalone in https://github.com/hrydgard/ppsspp/issues/7242 -//================ -#define Guest_AA4ov 1 //ON:1/OFF:0 /alternative to FXAA /taken from http://forums.ppsspp.org/showthread.php?tid=6594&pid=124441#pid124441 -#define scalev 3.0 //Default: 7.0 / 4.0 -> smooth, 8.0 -> sharp (4.0 + filtro works well also as upscaling filter for 2D games) -#define filtrov 1 //ON:1/OFF:0 /less blurry with smoother settings, but also like 3 times heavier -//================ -//SHARPENING FILTERS: //if you need very sharp image, add lots of aliasing -//================ -#define SHARPENv 0 //ON:1/OFF:0 /a simple sharpen filter, might be counterproductive to FXAA and BLOOM, hence disabled by default -#define valuev 7.5 //Default: 7.5 /higher = more visible effect -//================ -#define S_COM_V2v 0 //ON:1/OFF:0 /Sharpen Complex v2 from https://github.com/mpc-hc similar to above in effect, maybe more accurate -#define S_val0v 5.0 //Default: 5.0 /higher ~ increases sharpness /negative ~ can add extra blurr/strange effect -//================ -//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" - //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically -//================ -#define xBRv 0 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below -#define VariantBv 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details -#define Variantx2v 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR -//================ -#define xBRAccuracyv 0 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below -#define CornerAv 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding -#define CornerBv 0 //ON:1/OFF:0 / activate only one -#define CornerDv 0 //ON:1/OFF:0 -// CornerCv //used as default if no other ones are defined -//================ -#define xHQv 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution -#define scaleoffsetv 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness -//================ -//DEBANDING FILTERS: //especially useful for upscaling filters like 5xBR as well as texture scaling like xBRZ, use only one -//================ -#define Debandv 0 //ON:1/OFF:0 /Blurs -#define DeTolv 16.0 //Default: 16.0 /tolerance, too high will look glitchy -//================ -#define Frostv 0 //ON:1/OFF:0 /Dithering ~ adds noise -#define fTolv 32.0 //Default: 32.0 /tolerance, too high will look glitchy -#define fSimplev 1 //ON:1/OFF:0 / simpler(about half as demanding, slightly less smooth) version -//================ -#define Bilateralv 1 //ON:1/OFF:0 /Nice, but very expensive, made by mrharicot ~ https://www.shadertoy.com/view/4dfGDH -//================ -//OTHER FILTERS: //Most effects from here on can be fully mixed without loosing previous effects. Exceptions: Natural Colors, Advanced Cartoon -//================ -#define BLOOMv 1 //ON:1/OFF:0 /bloom implementation from "my heroics" blog http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/ -#define MIKUv 0 //Hatsune<3 this is an optional bloom filter for all those pale anime faces which get white otherwise:P tested on Miku in white dress -#define samplesv 3 //Default: 4 /higher = more glow, worse performance -#define qualityv 0.14 //Default: 0.18 /lower = smaller glow, better quality -#define Bpowerv 1.0 //Default: 1.0 /amount of bloom mixed -//================ -#define COLOREDv 0 //ON:1/OFF:0 /coloring part of KrossX Overlay Bloom shader from here http://www.mediafire.com/krossx#ste5pa5ijfa0o -#define Cpowerv 0.5 //Default: 0.5 /strenght of the effect -//================ -#define NATURALCv 0 //ON:1/OFF:0 /by popular demand, natular colors, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -#define ncpowerv 0.5 //Default:0.5 / higher = more natural color, check note line above -//================ -#define ACARTOONv 0 //ON:1/OFF:0 Advanced Cartoon from Guest shader pack -#define thv 0.10 //Default: 0.10 /outlines sensitivity, recommended from 0.00...0.50 -#define bbv 0.45 //Default: 0.45 /outlines strength, recommended from 0.10...2.00 -#define ppv 1.50 //Default: 1.50 /outlines blackening, recommended from 0.25...2.00 -#define acpowerv 0.5 //Default:0.5 / higher = more effect, note: this shader can't be fully mixed with smoothing/sharpening/upscaling effects -//================ -#define SHADEBOOSTv 0 //ON:1/OFF:0 /color correction from GSdx/pcsx2 plugin, initially taken from http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 -#define saturationv 1.0 //Default: 1.0 //negative will look like inverted colors shader -#define brightnessv 1.0 //Default: 1.0 -#define contrastv 1.0 //Default: 1.0 //negative will be... well negative;p -#define redv 1.0 //Default: 1.0 -#define greenv 1.0 //Default: 1.0 -#define bluev 1.0 //Default: 1.0 -//Shadeboost presets: //Shadeboost must be activated, presets override options above -#define SEPIAv 0 //Moody coolors:) -#define GRAYSCALEv 0 //Just for lols? -#define NEGATIVEv 0 //As above -#define PSPCOLORSv 0 //Makes the colors as on older PSP screens(colder) -//Simple color swap: //Shadeboost must be activated -#define rgbRBGv 0 //green <-> blue -#define rgbBGRv 0 //red <-> blue -#define rgbBRGv 0 //red -> green -> blue -> red -#define rgbGRBv 0 //red <-> green -#define rgbGBRv 0 //red -> blue -> green -> red -//^All presets and color swap are simple switch ON:1/OFF:0 -//================ -#define GAMMAv 0 //ON:1/OFF:0 /simple gamma function after reading http://filmicgames.com/archives/299 -#define correctionv 0.75 //Default: 1.0 -//================ -#define SCANLINESv 0 //Ugly lines which never existed on psp, yet are popular among some people(I had to, sorry:P) -#define SLsizev 1 //Default: 1 /basically sets how wide each line is, from 1 to looks_weird_when_too_high -#define SLcolorv 2.8 //Default: 2.8(1.2 for noGradient) /brightens screen to compensate for dark lines, set to 1.0 for no compensation -#define SLpowerv 0.4 //Default: 0.4(0.8 for noGradient) /less/more = darker/brighter lines, -#define SLVv 0 //ON:1/OFF:0 /vertical scanlines -#define noGradientv 0 //ON:1/OFF:0 /enabling this makes the scanline a simple sharp line -//================ -#define LCD3xv 0 //ON:1/OFF:0 //different scanline shader -#define b_slv 16.0 //Default: 16.0 /horizontal lines brightness -#define b_lcdv 4.0 //Default: 4.0 /vertical lines brightness -#define sl_sizev 2.0 //Default: 2.0 /scanline size -//================ -#define VIGNETTEv 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings -#define vsizev 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values -#define VIposv 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) -#define deViv 0 //ON:1/OFF:0 /reverse vignette -//======================================================================================= -//=========================================TEST========================================== -//======================================================================================= -#define TEST 0 //ON:1/OFF:0 /test mode, applies shaders on half of the screen for easy result comparison and tweaking -#define TESTANIM 0 //ON:1/OFF:0 /as above, animation slides shader from left to right and back /use only one -#define testAspeed 1.0 //animation speed -//================ -//Approximate performance hit -//Free: TEST, TESTANIM -//Light: SHARPEN, COLORED, SHADEBOOST, GAMMA, SCANLINES, LCD3x, VIGNETTE, BLOOM(<= 2 samples) -//Medium: FXAA, GAUSS_SQ, GAUSS_S, S_COM_V2, xHQ, Deband, Frost(fSimple), NATURALC, ACARTOON, BLOOM(== 3 samples) -//Heavy: Guest_AA4o, xBR, Frost, BLOOM(>= 4 samples), xBRAccuracy -//Extremely Heavy: Guest_AA4o(filtro), BLOOM(>= 8 samples), Bilateral -//====================================================================================================================================================================== -//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), -// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken -// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), -// other credits mentioned earlier, any more info / required licenses can be found below. - - - - -/* - FXAA shader, GLSL code adapted from: - http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA - Whitepaper describing the technique: - http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf -*/ - -/* - AA shader 4.o / AA shader 4.o - filtro - - Copyright (C) 2014 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - Hyllian's 5xBR v3.5a Shader - - Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from: - http://forums.ngemu.com/showthread.php?t=76098 - - by guest(r) (guest.r@gmail.com) - License: GNU-GPL - - Shader notes: looks better with sprite games -*/ - -/* - Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) - - Copyright (C) 2011-2015 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. - - Incorporates some of the ideas from SABR shader. Thanks to Joshua Street. -*/ - -/* - Advanced Cartoon shader - - Copyright (C) 2006 guest(r) - guest.r@gmail.com - - 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. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#ifdef GL_ES -precision mediump float; -precision mediump int; -#endif - -uniform sampler2D sampler0; -uniform vec4 u_time; -uniform float u_video; - -//=========== -// The inverse of the texture dimensions along X and Y -uniform vec2 u_texelDelta; -uniform vec2 u_pixelDelta; -varying vec2 v_texcoord0; - -varying vec4 v_texcoord1; -varying vec4 v_texcoord2; -varying vec4 v_texcoord3; -varying vec4 v_texcoord4; -varying vec2 v_texcoord5; - - -//=========== -//=========== -#if(FXAA==1 || FXAAv==1) -vec3 processFXAA(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float FXAA_SPAN_MAX = 8.0; - float FXAA_REDUCE_MUL = 1.0/8.0; - float FXAA_REDUCE_MIN = (1.0/128.0); - - vec3 rgbNW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, -1.0) * u_texelDelta).xyz; - //#define Pass_Diffuse(v2TexCoord) texture2D(sampler0, v2TexCoord).xyz - //vec3 rgbNW = Pass_Diffuse(v2TexCoord + vec2(-u_texelDelta.x, -u_texelDelta.y)).xyz; - vec3 rgbNE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, -1.0) * u_texelDelta).xyz; - vec3 rgbSW = texture2D(sampler0, v_texcoord0 + vec2(-1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbSE = texture2D(sampler0, v_texcoord0 + vec2(+1.0, +1.0) * u_texelDelta).xyz; - vec3 rgbM = texture2D(sampler0, v_texcoord0).xyz; - - vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW, luma); - float lumaNE = dot(rgbNE, luma); - float lumaSW = dot(rgbSW, luma); - float lumaSE = dot(rgbSE, luma); - float lumaM = dot( rgbM, luma); - - float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); - float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); - - vec2 dir; - dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); - dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); - - float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); - - float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); - - dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), - max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta; - - vec3 rgbA = (1.0/2.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (1.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (2.0/3.0 - 0.5)).xyz); - vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( - texture2D(sampler0, v_texcoord0 + dir * (0.0/3.0 - 0.5)).xyz + - texture2D(sampler0, v_texcoord0 + dir * (3.0/3.0 - 0.5)).xyz); - float lumaB = dot(rgbB, luma); - - if((lumaB < lumaMin) || (lumaB > lumaMax)){ - color=rgbA; - } else { - color=rgbB; - } - return color; -} -#endif -#if(GAUSS_SQ==1 || GAUSS_SQv==1) -vec3 processGAUSS_SQ(vec3 color){ - float GAUSS_KERNEL_SIZE = 5.0; - //indices - // 00 01 02 03 04 - // 05 06 07 08 09 - // 10 11 12 13 14 - // 15 16 17 18 19 - // 20 21 22 23 24 - - //filter strength, rather smooth - // 01 04 07 04 01 - // 04 16 26 16 04 - // 07 26 41 26 07 - // 04 16 26 16 04 - // 01 04 07 04 01 - - vec2 offset = u_pixelDelta*Gsmoothing/GAUSS_KERNEL_SIZE; - if (u_video==1.0){ - offset = u_pixelDelta*Gsmoothingv/GAUSS_KERNEL_SIZE; - } - - vec3 cGauss0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-2.0)).xyz; - vec3 cGauss1 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-2.0)).xyz; - vec3 cGauss2 = 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz; - vec3 cGauss3 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-2.0)).xyz; - vec3 cGauss4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-2.0)).xyz; - vec3 cGauss5 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0,-1.0)).xyz; - vec3 cGauss6 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz; - vec3 cGauss7 = 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz; - vec3 cGauss8 = 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz; - vec3 cGauss9 = 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0,-1.0)).xyz; - vec3 cGauss10= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz; - vec3 cGauss11= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz; - vec3 cGauss12= 41.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz; - vec3 cGauss13= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz; - vec3 cGauss14= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz; - vec3 cGauss15= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 1.0)).xyz; - vec3 cGauss16= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz; - vec3 cGauss17= 26.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz; - vec3 cGauss18= 16.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz; - vec3 cGauss19= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 1.0)).xyz; - vec3 cGauss20= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 2.0)).xyz; - vec3 cGauss21= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 2.0)).xyz; - vec3 cGauss22= 7.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz; - vec3 cGauss23= 4.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 2.0)).xyz; - vec3 cGauss24= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 2.0)).xyz; - - color.xyz = cGauss0 + cGauss1 + cGauss2 + cGauss3 + cGauss4 + cGauss5 + cGauss6 + cGauss7 + cGauss8 + cGauss9 + cGauss10 + cGauss11 + cGauss12 + cGauss13 + cGauss14 + cGauss15 + cGauss16 + cGauss17 + cGauss18 + cGauss19 + cGauss20 + cGauss21 + cGauss22 + cGauss23 + cGauss24; - color.xyz = color.xyz / 273.0; - return color; -} -#endif -#if(GAUSS_S==1 || GAUSS_Sv==1) -vec3 processGAUSS_S(vec3 color){ - //The parameters are hardcoded for now, but could be - //made into uniforms to control fromt he program. - float GAUSSS_SPAN_MAX = 1.5; - - //just a variable to describe the maximu - float GAUSSS_KERNEL_SIZE = 5.0; - //indices - // XX XX 00 XX XX - // XX 01 02 03 XX - // 04 05 06 07 08 - // XX 09 10 11 XX - // XX XX 12 XX XX - - //filter strength, rather smooth - // XX XX 01 XX XX - // XX 03 08 03 XX - // 01 08 10 08 01 - // XX 03 08 03 XX - // XX XX 01 XX XX - - vec2 offsetS = u_pixelDelta*GAUSSS_SPAN_MAX/GAUSSS_KERNEL_SIZE; - - vec3 cGaussS0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-2.0)).xyz; - vec3 cGaussS1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0,-1.0)).xyz; - vec3 cGaussS2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0,-1.0)).xyz; - vec3 cGaussS3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0,-1.0)).xyz; - vec3 cGaussS4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-2.0, 0.0)).xyz; - vec3 cGaussS5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 0.0)).xyz; - vec3 cGaussS6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 0.0)).xyz; - vec3 cGaussS7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 0.0)).xyz; - vec3 cGaussS8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 2.0, 0.0)).xyz; - vec3 cGaussS9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2(-1.0, 1.0)).xyz; - vec3 cGaussS10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 1.0)).xyz; - vec3 cGaussS11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 1.0, 1.0)).xyz; - vec3 cGaussS12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offsetS * vec2( 0.0, 2.0)).xyz; - - color = cGaussS0 + cGaussS1 + cGaussS2 + cGaussS3 + cGaussS4 + cGaussS5 + cGaussS6 + cGaussS7 + cGaussS8 + cGaussS9 + cGaussS10 + cGaussS11 + cGaussS12; - color = color / 58.0; - return color; -} -#endif -#if(xBRAccuracy==1 || xBR==1 || xBRAccuracyv==1 || xBRv==1) - -const float lv2_cf = 2.0; -const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25); -const float XBR_SCALE = 3.0; -const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0); -const float coef = 2.0; - -const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); -const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); -const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); -const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); -const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); -const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); -const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); - - -vec4 df(vec4 A, vec4 B) { - return abs(A-B); -} -//#if(xBRAccuracy==1 || xBRAccuracyv==1) - -// Compare two vectors and return their components are different. -vec4 diff(vec4 A, vec4 B) { - return vec4(notEqual(A, B)); -} - -// Determine if two vector components are equal based on a threshold. -vec4 eq(vec4 A, vec4 B) { - return (step(df(A, B), eq_threshold)); -} - -// Determine if two vector components are NOT equal based on a threshold. -vec4 neq(vec4 A, vec4 B) { - return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B)); -} -float c_df(vec3 c1, vec3 c2) { - vec3 df = abs(c1 - c2); - return df.r + df.g + df.b; -} -//#else -bvec4 _and_(bvec4 A, bvec4 B) { - return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); -} -bvec4 _or_(bvec4 A, bvec4 B) { - return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); -} -bvec4 close(vec4 A, vec4 B) { - return (lessThan(df(A, B), vec4(15.0))); -} -vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) { - return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); -} -//#endif -vec3 processxBR(vec3 color){ - vec2 pS = 1.0 / u_texelDelta.xy; - vec2 fp = fract(v_texcoord0.xy*pS.xy); - vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy; - vec2 dx = vec2(u_texelDelta.x,0.0); - vec2 dy = vec2(0.0,u_texelDelta.y); - vec2 y2 = dy + dy; vec2 x2 = dx + dx; - -//#if(xBRAccuracy==1 || xBRAccuracyv==1) - // px = pixel, edr = edge detection rule - vec4 edri, edr, edr_l, edr_u, px; - vec4 irlv0, irlv1, irlv2l, irlv2u; - vec4 fx, fx_l, fx_u; // inequations of straight lines. - - vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE); - vec4 delta_u = delta_l.yxwz; -//#else - bvec4 edrBR, edr_left, edr_up, pxBR; // px = pixel, edr = edge detection rule - bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up; - bvec4 nc; // new_color - bvec4 fxBR, fx_left, fx_up; // inequations of straight lines. -//#endif - - vec3 rgbw = vec3(16.163, 23.351, 8.4772); - if((xBRAccuracy==1 && u_video!=1.0) || (xBRAccuracyv==1 && u_video==1.0)) { - rgbw = vec3(14.352, 28.176, 5.472); - } - - vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy).xyz; - vec3 B = texture2D(sampler0, TexCoord_0 -dy).xyz; - vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy).xyz; - vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz; - vec3 E = texture2D(sampler0, TexCoord_0 ).xyz; - vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz; - vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy).xyz; - vec3 H = texture2D(sampler0, TexCoord_0 +dy).xyz; - vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy).xyz; - vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz; - vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz; - vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz; - vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz; - vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz; - vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz; - vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz; - vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz; - vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz; - vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz; - vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz; - vec3 F4 = texture2D(sampler0, TexCoord_0 +x2 ).xyz; - - vec4 b = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw)); - vec4 c = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw)); - vec4 d = b.yzwx; - vec4 e = vec4(dot(E,rgbw)); - vec4 f = b.wxyz; - vec4 g = c.zwxy; - vec4 h = b.zwxy; - vec4 i = c.wxyz; - vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw)); - vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw)); - vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw)); - vec4 f4 = h5.yzwx; - - vec3 res; - -//#if(xBRAccuracy==1 || xBRAccuracyv==1) -if((xBRAccuracy==1 && u_video!=1.0) || (xBRAccuracyv==1 && u_video==1.0)) { - // These inequations define the line below which interpolation occurs. - fx = (Ao*fp.y+Bo*fp.x); - fx_l = (Ax*fp.y+Bx*fp.x); - fx_u = (Ay*fp.y+By*fp.x); - - irlv1 = irlv0 = diff(e,f) * diff(e,h); - -if((CornerA==0 && u_video!=1.0) || (CornerAv==0 && u_video==1.0)) { // A takes priority skipping other corners - #define SMOOTH_TIPS - // Corner C also default if no other ones used - irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) ); - int select1 = 0; -if((CornerB==1 && u_video!=1.0) || (CornerBv==1 && u_video==1.0)) {// Corner B - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) ); - select1 = 1; -} -if((CornerD==1 && u_video!=1.0) || (CornerDv==1 && u_video==1.0)) { // Corner D - if (select1==0){ - vec4 c1 = i4.yzwx; - vec4 g0 = i5.wxyz; - irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0))); - } -} -} //Corner A if end - - irlv2l = diff(e,g) * diff(d,g); - irlv2u = diff(e,c) * diff(b,c); - - vec4 fx45i = clamp((fx + delta -Co - Ci)/(2.0*delta ), 0.0, 1.0); - vec4 fx45 = clamp((fx + delta -Co )/(2.0*delta ), 0.0, 1.0); - vec4 fx30 = clamp((fx_l + delta_l -Cx )/(2.0*delta_l), 0.0, 1.0); - vec4 fx60 = clamp((fx_u + delta_u -Cy )/(2.0*delta_u), 0.0, 1.0); - - vec4 w1, w2; - w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw); - w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw); - w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw); - w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw); - - w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw); - w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw); - w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw); - w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw); - - edri = step(w1, w2) * irlv0; - edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1); - - w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw); - w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw); - - edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr; - edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr; - - fx45 = edr * fx45; - fx30 = edr_l * fx30; - fx60 = edr_u * fx60; - fx45i = edri * fx45i; - - w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw); - w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw); - - px = step(w1, w2); - -#ifdef SMOOTH_TIPS - vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i)); -#else - vec4 maximos = max(max(fx30, fx60), fx45); -#endif - - vec3 res1 = E; - res1 = mix(res1, mix(H, F, px.x), maximos.x); - res1 = mix(res1, mix(B, D, px.z), maximos.z); - - vec3 res2 = E; - res2 = mix(res2, mix(F, B, px.y), maximos.y); - res2 = mix(res2, mix(D, H, px.w), maximos.w); - - res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2))); -//#else -} else { - // These inequations define the line below which interpolation occurs. - fxBR = greaterThan(Ao*fp.y+Bo*fp.x,Co); - fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx); - fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy); - - if (VariantB==1){ - bvec4 t1 = _and_( notEqual(e, f), notEqual(e, h) ); - bvec4 t2 = _and_( not(close(f, b)), not(close(h, d)) ); - bvec4 t3 = _and_( _and_( close(e, i), not(close(f, i4)) ), not(close(h, i5)) ); - bvec4 t4 = _or_( close(e, g), close(e, c) ); - interp_restriction_lv1 = _and_( t1, _or_( _or_(t2, t3), t4 ) ); - } else { - interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h))); - } - interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g))); - interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c))); - - edrBR = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1)); - edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left)); - edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up)); - - nc.x = ( edrBR.x && (fxBR.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) ); - nc.y = ( edrBR.y && (fxBR.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) ); - nc.z = ( edrBR.z && (fxBR.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) ); - nc.w = ( edrBR.w && (fxBR.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) ); - - pxBR = lessThanEqual(df(e,f),df(e,h)); - - - if (Variantx2 == 1) { - vec3 E0 = E.xyz; - vec3 E1 = E.xyz; - vec3 E2 = E.xyz; - vec3 E3 = E.xyz; - vec3 P[4]; - P[0] = pxBR.x ? F : H; - P[1] = pxBR.y ? B : F; - P[2] = pxBR.z ? D : B; - P[3] = pxBR.w ? H : D; - if (edrBR.x) { - if (edr_left.x && edr_up.x) { - E3 = mix(E3 , P[0], 0.833333); - E2 = mix(E2 , P[0], 0.25); - E1 = mix(E1 , P[0], 0.25); - } else if (edr_left.x) { - E3 = mix(E3 , P[0], 0.75); - E2 = mix(E2 , P[0], 0.25); - } else if (edr_up.x) { - E3 = mix(E3 , P[0], 0.75); - E1 = mix(E1 , P[0], 0.25); - } else { - E3 = mix(E3 , P[0], 0.5); - } - } - if (edrBR.y) { - if (edr_left.y && edr_up.y) { - E1 = mix(E1 , P[1], 0.833333); - E3 = mix(E3 , P[1], 0.25); - E0 = mix(E0 , P[1], 0.25); - } else if (edr_left.y) { - E1 = mix(E1 , P[1], 0.75); - E3 = mix(E3 , P[1], 0.25); - } else if (edr_up.y) { - E1 = mix(E1 , P[1], 0.75); - E0 = mix(E0 , P[1], 0.25); - } else { - E1 = mix(E1 , P[1], 0.5); - } - } - if (edrBR.z) { - if (edr_left.z && edr_up.z) { - E0 = mix(E0 , P[2], 0.833333); - E1 = mix(E1 , P[2], 0.25); - E2 = mix(E2 , P[2], 0.25); - } else if (edr_left.z) { - E0 = mix(E0 , P[2], 0.75); - E1 = mix(E1 , P[2], 0.25); - } else if (edr_up.z) { - E0 = mix(E0 , P[2], 0.75); - E2 = mix(E2 , P[2], 0.25); - } else { - E0 = mix(E0 , P[2], 0.5); - } - } - if (edrBR.w) { - if (edr_left.w && edr_up.w) { - E2 = mix(E2 , P[3], 0.833333); - E0 = mix(E0 , P[3], 0.25); - E3 = mix(E3 , P[3], 0.25); - } else if (edr_left.w) { - E2 = mix(E2 , P[3], 0.75); - E0 = mix(E0 , P[3], 0.25); - } else if (edr_up.w) { - E2 = mix(E2 , P[3], 0.75); - E3 = mix(E3 , P[3], 0.25); - } else { - E2 = mix(E2 , P[3], 0.5); - } - } - res = (fp.x < 0.50) ? (fp.y < 0.50 ? E0 : E2) : (fp.y < 0.50 ? E1: E3); - } else { - res = nc.x ? pxBR.x ? F : H : nc.y ? pxBR.y ? B : F : nc.z ? pxBR.z ? D : B : nc.w ? pxBR.w ? H : D : E; - } -//#endif -} - return res; -} -#endif -#if(BLOOM==1 || BLOOMv==1) -vec3 processBLOOM(vec3 color, vec3 colorB, int hatsu){ - #define factor 0.002 //Default: 0.002 /just an extra tweak for the bloom slightly higher values might look better in some cases, but too much can cause artifacts - vec4 sum = vec4(0); - int jb; - int samplesBloom = samples; - float qualityBloom = quality; - float BpowerBloom = Bpower; - if((BLOOMv==1 && u_video==1.0)) { - samplesBloom = samplesv; - qualityBloom = qualityv; - BpowerBloom = Bpowerv; - } - int diffx = samplesBloom - 1; - int ib; - int diffy = samplesBloom; - vec3 bloom; - for( ib= -diffy ;ib < diffy; ib++) { - for (jb = -diffx; jb < diffx; jb++) { - sum += texture2D(sampler0, v_texcoord0.xy + vec2(jb, ib)*factor) * qualityBloom; - } - } - if(color.r < 0.3 && color.g < 0.3 && color.b < 0.3) { - bloom = sum.xyz*sum.xyz*0.012 + color; - } else { - if(color.r < 0.5 && color.g < 0.5 && color.b < 0.5) { - bloom = sum.xyz*sum.xyz*0.009 + color; - } else { - bloom = sum.xyz*sum.xyz*0.0075 + color; - } - } - color = mix(color, bloom, BpowerBloom); - if(hatsu==1) { - color = mix(colorB, color, 0.5); - } - return color; -} -vec3 processMIKU(vec3 color){ - vec3 mmm = vec3(0.1, 0.1, 0.1); - color = mix(color,mmm, 0.9); - return color; -} -#endif -#if(NATURALC==1 || NATURALCv==1) -const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212, - 0.587,-0.275,-0.523, - 0.114,-0.321, 0.311); - -const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0, - 0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523, - 0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149); - -const vec3 val00 = vec3( 1.2, 1.2, 1.2); -vec3 processNATURALC(vec3 color){ - vec3 c0,c1; - - c0 = texture2D(sampler0,v_texcoord1.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord1.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord1.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord1.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord2.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord2.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord2.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord2.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord3.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord3.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord3.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord3.zw).xyz)*0.125; - - c0+= texture2D(sampler0,v_texcoord4.xy).xyz; - c0+=(texture2D(sampler0,v_texcoord4.zy).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord4.xw).xyz)*0.25; - c0+=(texture2D(sampler0,v_texcoord4.zw).xyz)*0.125; - c0*=0.153846153846; - - c1=RGBtoYIQ*c0; - - c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz); - - float ncpowerNATURALC = ncpower; - if((NATURALCv==1 && u_video==1.0)) { - ncpowerNATURALC = ncpowerv; - } - - color=mix(color,YIQtoRGB*c1,ncpowerNATURALC); - return color; -} -#endif -#if(SCANLINES==1 || SCANLINESv==1) -vec3 processSCANLINES(vec3 color){ - int vscan = SLV; - vec3 colorSL=color*SLcolor; - - int SLsizeSCANLINES = SLsize; - float SLpowerSCANLINES = SLpower; - - if((SCANLINESv==1 && u_video==1.0)) { - vscan = SLVv; - SLsizeSCANLINES = SLsizev; - colorSL=color*SLcolorv; - SLpowerSCANLINES = SLpowerv; - } - - if(vscan==0){ - float rey = (1.0/float(SLsizeSCANLINES)/u_pixelDelta.y); - float posSy = v_texcoord0.y*rey; - float lineSy = mod(posSy,2.0); - if (noGradient==1) { - bool clSy = lineSy<1.0; - lineSy = mix(1.0,0.0,float(clSy)); - } - color=color-lineSy; - } else { - float rex = (1.0/float(SLsizeSCANLINES)/u_pixelDelta.x); - float posSx = v_texcoord0.x*(rex/1.0); - float lineSx = mod(posSx,2.0); - if (noGradient==1) { - bool clSx = lineSx<1.0; - lineSx = mix(1.0,0.0,float(clSx)); - } - color=color-lineSx; - } - if ((noGradient==1 && u_video!=1.0) || (noGradientv==1 && u_video==1.0)) { - color=mix(color,clamp(colorSL,0.0,1.0),SLpowerSCANLINES); - } else { - color=mix(color,colorSL,SLpowerSCANLINES); - } - return color; -} -#endif -#if(SHARPEN==1 || SHARPENv==1) -vec3 processSHARPEN(vec3 color){ - float valueSHARPEN = value; - if((SHARPENv==1 && u_video==1.0)) { - valueSHARPEN = valuev; - } - color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*valueSHARPEN; - color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*valueSHARPEN; - return color; -} -#endif -#if(S_COM_V2==1 || S_COM_V2v==1) -vec3 processS_COM_V2(vec3 color){ - float S_val0S_COM_V2 = S_val0; - if((S_COM_V2v==1 && u_video==1.0)) { - S_val0S_COM_V2 = S_val0v; - } - float width = (v_texcoord0.x); - float height = (v_texcoord0.y); - float px = (u_texelDelta.x); - float py = (u_texelDelta.y); - float mean = 0.6; - float dx = (mean * px); - float dy = (mean * py); - float CoefBlur = 2.0; - float CoefOrig = (1.0 + CoefBlur); - float Sharpen_val1 = ((S_val0S_COM_V2 - 1.0) / 8.0); - vec3 S_Edge = vec3(0.2,0.2,0.2); - // get original pixel / color - - // compute blurred image (gaussian filter) - vec3 c1 = texture2D(sampler0, v_texcoord0 + vec2(-dx, -dy)).xyz; - vec3 c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -dy)).xyz; - vec3 c3 = texture2D(sampler0, v_texcoord0 + vec2( dx, -dy)).xyz; - vec3 c4 = texture2D(sampler0, v_texcoord0 + vec2(-dx, 0)).xyz; - vec3 c5 = texture2D(sampler0, v_texcoord0 + vec2( dx, 0)).xyz; - vec3 c6 = texture2D(sampler0, v_texcoord0 + vec2(-dx, dy)).xyz; - vec3 c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, dy)).xyz; - vec3 c8 = texture2D(sampler0, v_texcoord0 + vec2( dx, dy)).xyz; - - // gaussian filter - // [ 1, 2, 1 ] - // [ 2, 4, 2 ] - // [ 1, 2, 1 ] - // to normalize the values, we need to divide by the coeff sum - // 1 / (1+2+1+2+4+2+1+2+1) = 1 / 16 = 0.0625 - vec3 flou = (c1 + c3 + c6 + c8 + 2.0 * (c2 + c4 + c5 + c7) + 4.0 * color) * 0.0625; - - // substract blurred image from original image - vec3 corrected = CoefOrig * color - CoefBlur * flou; - - // edge detection - // Get neighbor points - // [ c1, c2, c3 ] - // [ c4, color, c5 ] - // [ c6, c7, c8 ] - c1 = texture2D(sampler0, v_texcoord0 + vec2(-px, -py)).xyz; - c2 = texture2D(sampler0, v_texcoord0 + vec2( 0, -py)).xyz; - c3 = texture2D(sampler0, v_texcoord0 + vec2( px, -py)).xyz; - c4 = texture2D(sampler0, v_texcoord0 + vec2(-px, 0)).xyz; - c5 = texture2D(sampler0, v_texcoord0 + vec2( px, 0)).xyz; - c6 = texture2D(sampler0, v_texcoord0 + vec2(-px, py)).xyz; - c7 = texture2D(sampler0, v_texcoord0 + vec2( 0, py)).xyz; - c8 = texture2D(sampler0, v_texcoord0 + vec2( px, py)).xyz; - - // using Sobel filter - // horizontal gradient - // [ -1, 0, 1 ] - // [ -2, 0, 2 ] - // [ -1, 0, 1 ] - vec3 delta1 = (c3 + 2.0 * c5 + c8) - (c1 + 2.0 * c4 + c6); - - // Save some arithmetic operations to ensure PS2 compatibility - c1 += c3; - c6 += c8; - // vertical gradient - // [ -1, - 2, -1 ] - // [ 0, 0, 0 ] - // [ 1, 2, 1 ] - vec3 delta2 = (c6 + 2.0 * c7 ) - (c1 + 2.0 * c2 ); - vec3 checkshc = sqrt(delta1 * delta1 + delta2 * delta2); - // computation - if (checkshc.x > S_Edge.x || checkshc.y > S_Edge.y || checkshc.z > S_Edge.z) { - // if we have an edge, use sharpen - corrected = color * S_val0S_COM_V2 - (c1 + c2 + c4 + c5 + c6 + c7 ) * Sharpen_val1; - } - return corrected; -} -#endif -#if(GAMMA==1 || GAMMAv==1) -vec3 processGAMMA(vec3 color){ - float correctionGAMMA = correction; - if((GAMMAv==1 && u_video==1.0)) { - correctionGAMMA = correctionv; - } - vec3 gam=vec3(pow(color.r,1.0/abs(correctionGAMMA)),pow(color.g,1.0/abs(correctionGAMMA)),pow(color.b,1.0/abs(correctionGAMMA))); - return gam; -} -#endif -#if(SHADEBOOST==1 || SHADEBOOSTv==1) -vec3 processSHADEBOOST(vec3 color){ - float sat = saturation; - float brt = brightness; - float con = contrast; - - // Increase or decrease theese values to adjust r, g and b color channels seperately - float AvgLumR = red; - float AvgLumG = green; - float AvgLumB = blue; - - if((SHADEBOOSTv==1 && u_video==1.0)) { - sat = saturationv; - brt = brightnessv; - con = contrastv; - - AvgLumR = redv; - AvgLumG = greenv; - AvgLumB = bluev; - } - - //==========================presets - if((SEPIA==1 && u_video!=1.0) || (SEPIAv==1 && u_video==1.0)) { - sat = 0.11; - brt = 0.87; - con = 1.20; - AvgLumR = 1.19930; - AvgLumG = 0.960; - AvgLumB = 0.6754; - } - if((GRAYSCALE==1 && u_video!=1.0) || (GRAYSCALEv==1 && u_video==1.0)) { - sat = 0.0; - brt = 1.0; - con = 1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if((NEGATIVE==1 && u_video!=1.0) || (NEGATIVEv==1 && u_video==1.0)) { - sat = 1.0; - brt = 1.0; - con = -1.0; - AvgLumR = 1.0; - AvgLumG = 1.0; - AvgLumB = 1.0; - } - if((PSPCOLORS==1 && u_video!=1.0) || (PSPCOLORSv==1 && u_video==1.0)) { - sat = 1.0; - brt = 1.0; - con = 1.0; - AvgLumR = 0.9593; - AvgLumG = 1.0739; - AvgLumB = 1.4604; - } - //========================== - const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); - - vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); - vec3 conRGB = vec3(0.5, 0.5, 0.5); - vec3 brtColor = color.rgb * brt; - vec3 intensity = vec3((brtColor.r*LumCoeff.r)+(brtColor.g*LumCoeff.g)+(brtColor.b*LumCoeff.b)); //workaround for AMD legacy drivers could be just dot(brtColor,LumCoeff) ;c - vec3 satColor = mix(intensity, brtColor, sat); - vec3 conColor = mix(conRGB, satColor, con); - vec3 mixColor = AvgLumin * conColor; - color.rgb = mixColor; - if((rgbRBG==1 && u_video!=1.0) || (rgbRBGv==1 && u_video==1.0)) { - color.rgb = color.rbg; - } - if((rgbBGR==1 && u_video!=1.0) || (rgbBGRv==1 && u_video==1.0)) { - color.rgb = color.bgr; - } - if((rgbBRG==1 && u_video!=1.0) || (rgbBRGv==1 && u_video==1.0)) { - color.rgb = color.brg; - } - if((rgbGRB==1 && u_video!=1.0) || (rgbGRBv==1 && u_video==1.0)) { - color.rgb = color.grb; - } - if((rgbGBR==1 && u_video!=1.0) || (rgbGBRv==1 && u_video==1.0)) { - color.rgb = color.gbr; - } - return color; -} -#endif -#if(COLORED==1 || COLOREDv==1) -float overlay(float base, float blend) { - float result = 0.0; - if( base < 0.5 ) { - result = 2.0 * base * blend; - } else { - result = 1.0 - (1.0 - 2.0*(base-0.5)) * (1.0-blend); - } - return result; -} -vec3 processCOLORED(vec3 color){ - float CpowerCOLORED = Cpower; - if((COLOREDv==1 && u_video==1.0)) { - CpowerCOLORED = Cpowerv; - } - vec3 blur = color * 1.22520613262190495; - vec3 newcolor = vec3(overlay(color.r,blur.r), - overlay(color.g,blur.g), - overlay(color.b,blur.b)); - color = mix(color, newcolor, CpowerCOLORED); - return color; -} -#endif -#if(TEST==1) -vec3 processTEST(vec3 color){ - if(v_texcoord0.x<0.5) { - color.xyz=color.xyz; - } else { - color.xyz=texture2D(sampler0, v_texcoord0.xy).xyz; - } - return color; -} -#endif -#if(TESTANIM==1) -vec3 processTESTANIM(vec3 color){ - float anim=(sin(u_time.x*testAspeed)+0.9)*0.55; - if(v_texcoord0.x tolerance || diff.g > tolerance || diff.b > tolerance; //workaround for the above - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Frost==1 || Frostv==1) -float rand(vec2 co){ - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); -} -vec3 processFrost(vec3 color) { - float tolerance = fTol/1638.4; - if((Frostv==1 && u_video==1.0)) { - tolerance = fTolv; - } - for (int i=1;i<5;i++) { - float p = u_pixelDelta.x * float(i) / rand(vec2(rand(v_texcoord0.xy),rand(v_texcoord0.xy))); - vec3 c1 = texture2D(sampler0,v_texcoord0.xy + vec2( p, p)).xyz; - vec3 c1b = texture2D(sampler0,v_texcoord0.xy + vec2( -p, -p)).xyz; - vec3 c2 = texture2D(sampler0,v_texcoord0.xy + vec2( -p, p)).xyz; - vec3 c2b = texture2D(sampler0,v_texcoord0.xy + vec2( p, -p)).xyz; - vec3 c3 = texture2D(sampler0,v_texcoord0.xy + vec2( p,0.0)).xyz; - vec3 c3b = texture2D(sampler0,v_texcoord0.xy + vec2( -p,0.0)).xyz; - vec3 c4 = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, -p)).xyz; - vec3 c4b = texture2D(sampler0,v_texcoord0.xy + vec2(0.0, p)).xyz; - vec3 avg; - if((fSimple==1 && u_video!=1.0) || (fSimplev==1 && u_video==1.0)) { - avg = (c1 + c2 + c3 + c4)/4.0; - } else { - avg = (c1 + c2 + c3 + c4 + c1b + c2b + c3b + c4b)/8.0; - } - vec3 diff = abs(color - avg); - bool a = diff.r > tolerance || diff.g > tolerance || diff.b > tolerance; - color = mix(avg, color, float(a)); - } - return color; -} -#endif -#if(Guest_AA4o==1 || Guest_AA4ov==1) -const vec3 dt = vec3(1.0,1.0,1.0); -vec3 texture2d (vec2 texcoord) { - float scaleGuest_AA4o = scale; - if((Guest_AA4ov==1 && u_video==1.0)) { - scaleGuest_AA4o = scalev; - } - vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scaleGuest_AA4o; - vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scaleGuest_AA4o; - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2); -} -vec3 texture2dd (vec2 texcoord) { - float scaleGuest_AA4o = scale; - if((Guest_AA4ov==1 && u_video==1.0)) { - scaleGuest_AA4o = scalev; - } - vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scaleGuest_AA4o; - vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scaleGuest_AA4o; - vec3 c11 = texture2D(sampler0, texcoord ).xyz; - vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz; - vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz; - vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz; - vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz; - vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz; - vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz; - vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz; - vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz; - - float d1=dot(abs(c00-c22),dt)+0.001; - float d2=dot(abs(c20-c02),dt)+0.001; - float m1=dot(abs(s00-s22),dt)+0.001; - float m2=dot(abs(s02-s20),dt)+0.001; - - vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2)); - - return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2)); -} -vec3 processGuestAA4o() { - float scaleGuest_AA4o = scale; - if((Guest_AA4ov==1 && u_video==1.0)) { - scaleGuest_AA4o = scalev; - } - - // Calculating texel coordinates - - vec2 size = vec2(480.0,272.0)*scaleGuest_AA4o; - vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scaleGuest_AA4o; - - vec2 OGL2Pos = v_texcoord0 * size; - vec2 fp = fract(OGL2Pos); - vec2 dx = vec2(inv_size.x,0.0); - vec2 dy = vec2(0.0, inv_size.y); - vec2 g1 = vec2(inv_size.x,inv_size.y); - vec2 g2 = vec2(-inv_size.x,inv_size.y); - - vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size; - - // Reading the texels - vec3 C0 = texture2d(pC4 - g1); - vec3 C1 = texture2d(pC4 - dy); - vec3 C2 = texture2d(pC4 - g2); - vec3 C3 = texture2d(pC4 - dx); - vec3 C4 = texture2d(pC4 ); - vec3 C5 = texture2d(pC4 + dx); - vec3 C6 = texture2d(pC4 + g2); - vec3 C7 = texture2d(pC4 + dy); - vec3 C8 = texture2d(pC4 + g1); - - vec3 ul, ur, dl, dr; - float m1, m2; - - m1 = dot(abs(C0-C4),dt)+0.001; - m2 = dot(abs(C1-C3),dt)+0.001; - ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2); - - m1 = dot(abs(C1-C5),dt)+0.001; - m2 = dot(abs(C2-C4),dt)+0.001; - ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2); - - m1 = dot(abs(C3-C7),dt)+0.001; - m2 = dot(abs(C6-C4),dt)+0.001; - dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2); - - m1 = dot(abs(C4-C8),dt)+0.001; - m2 = dot(abs(C5-C7),dt)+0.001; - dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2); - - vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y))); - - if((filtro==1 && u_video!=1.0) || (filtrov==1 && u_video==1.0)){ - vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)); - - inv_size = vec2(2.0/480.0,2.0/272.0)/scaleGuest_AA4o;; - - dx = vec2(inv_size.x,0.0); - dy = vec2(0.0,inv_size.y); - g1 = vec2( inv_size.x,inv_size.y); - g2 = vec2(-inv_size.x,inv_size.y); - pC4 = v_texcoord0; - - C0 = texture2dd(pC4-g1); - C1 = texture2dd(pC4-dy); - C2 = texture2dd(pC4-g2); - C3 = texture2dd(pC4-dx); - C4 = texture2dd(pC4 ); - C5 = texture2dd(pC4+dx); - C6 = texture2dd(pC4+g2); - C7 = texture2dd(pC4+dy); - C8 = texture2dd(pC4+g1); - - vec3 mn1 = min(min(C0,C1),C2); - vec3 mn2 = min(min(C3,C4),C5); - vec3 mn3 = min(min(C6,C7),C8); - vec3 mx1 = max(max(C0,C1),C2); - vec3 mx2 = max(max(C3,C4),C5); - vec3 mx3 = max(max(C6,C7),C8); - - mn1 = min(min(mn1,mn2),mn3); - mx1 = max(max(mx1,mx2),mx3); - - vec3 dif1 = abs(c11-mn1) + 0.0001*dt; - vec3 dif2 = abs(c11-mx1) + 0.0001*dt; - - float filterparam = 2.0; - - dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam)); - dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam)); - - c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x); - c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y); - c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z); - - result = c11; - } - - return result; -} -#endif -#if(Bilateral==1 || Bilateralv==1) - - -#define SIGMA 10.0 -#define BSIGMA 0.1 -#define MSIZE 15 -float normpdf(float x, float sigma) { - return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma; -} - -float normpdf3(vec3 v, float sigma) { - return 0.39894*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma; -} - -vec3 processBilateral(vec3 color) { - const int kSize = (MSIZE-1)/2; - float kernel[MSIZE]; - vec3 final_colour; - - // Create the 1-D kernel - float Zxx = 0.0; - for (int j = 0; j <= kSize; ++j) { - kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA); - } - // sigma 10.0, MSIZE 15 - //someone mentioned performance increase with precompiled kernel, but really don't see that - //const float kernel[MSIZE] = float[MSIZE](0.031225216, 0.033322271, 0.035206333, 0.036826804, 0.038138565, 0.039104044, 0.039695028, 0.039894000, 0.039695028, 0.039104044, 0.038138565, 0.036826804, 0.035206333, 0.033322271, 0.031225216); - vec3 cc; - float factorNB; - float bZ = 1.0/normpdf(0.0, BSIGMA); - // Read out the texels - for (int i=-kSize; i <= kSize; ++i) { - for (int j=-kSize; j <= kSize; ++j) { - cc = texture2D(sampler0, v_texcoord0.xy+vec2(float(i)*u_pixelDelta.x,float(j)*u_pixelDelta.x)).rgb; - factorNB = normpdf3(cc-color, BSIGMA)*bZ*kernel[kSize+j]*kernel[kSize+i]; - Zxx += factorNB; - final_colour += factorNB*cc; - } - } - return final_colour/Zxx; -} -#endif -void main() { - vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; - - #if(FXAA==1 || FXAAv==1) - if((FXAA==1 && u_video!=1.0) || (FXAAv==1 && u_video==1.0)) { - color=processFXAA(color); - } - #endif - #if(GAUSS_SQ==1 || GAUSS_SQv==1) - if((GAUSS_SQ==1 && u_video!=1.0) || (GAUSS_SQv==1 && u_video==1.0)) { - color=processGAUSS_SQ(color); - } - #endif - #if(GAUSS_S==1 || GAUSS_Sv==1) - if((GAUSS_S==1 && u_video!=1.0) || (GAUSS_Sv==1 && u_video==1.0)) { - color=processGAUSS_S(color); - } - #endif - #if(Guest_AA4o==1 || Guest_AA4ov==1) - if((Guest_AA4o==1 && u_video!=1.0) || (Guest_AA4ov==1 && u_video==1.0)) { - color=processGuestAA4o(); - } - #endif - #if(SHARPEN==1 || SHARPENv==1) - if((SHARPEN==1 && u_video!=1.0) || (SHARPENv==1 && u_video==1.0)) { - color=processSHARPEN(color); - } - #endif - #if(S_COM_V2==1 || S_COM_V2v==1) - if((S_COM_V2==1 && u_video!=1.0) || (S_COM_V2v==1 && u_video==1.0)) { - color=processS_COM_V2(color); - } - #endif - #if(xHQ==1 || xHQv==1) - if((xHQ==1 && u_video!=1.0) || (xHQv==1 && u_video==1.0)) { - color=processxHQ(color); - } - #endif - #if(xBRAccuracy==1 || xBR==1 || xBRAccuracyv==1 || xBRv==1) - if(((xBRAccuracy==1 || xBR==1) && u_video!=1.0) || ((xBRAccuracyv==1 || xBRv==1) && u_video==1.0)) { - color=processxBR(color); - } - #endif - #if(Deband==1 || Debandv==1) - if((Deband==1 && u_video!=1.0) || (Debandv==1 && u_video==1.0)) { - color=processDeband(color); - } - #endif - #if(Frost==1 || Frostv==1) - if((Frost==1 && u_video!=1.0) || (Frostv==1 && u_video==1.0)) { - color=processFrost(color); - } - #endif - #if(Bilateral==1 || Bilateralv==1) - if((Bilateral==1 && u_video!=1.0) || (Bilateralv==1 && u_video==1.0)) { - color=processBilateral(color); - } - #endif - #if(NATURALC==1 || NATURALCv==1) - if((NATURALC==1 && u_video!=1.0) || (NATURALCv==1 && u_video==1.0)) { - color=processNATURALC(color); - } - #endif - #if(ACARTOON==1 || ACARTOONv==1) - if((ACARTOON==1 && u_video!=1.0) || (ACARTOONv==1 && u_video==1.0)) { - color=processACARTOON(color); - } - #endif - #if(BLOOM==1 || BLOOMv==1) - if((BLOOM==1 && u_video!=1.0) || (BLOOMv==1 && u_video==1.0)) { - vec3 colorB=color; - int hatsu = 0; - if((MIKU==1 && u_video!=1.0) || (MIKUv==1 && u_video==1.0)) { - hatsu = 1; - color=processMIKU(color); - } - color=processBLOOM(color, colorB, hatsu); - } - #endif - #if(COLORED==1 || COLOREDv==1) - if((COLORED==1 && u_video!=1.0) || (COLOREDv==1 && u_video==1.0)) { - color=processCOLORED(color); - } - #endif - #if(SHADEBOOST==1 || SHADEBOOSTv==1) - if((SHADEBOOST==1 && u_video!=1.0) || (SHADEBOOSTv==1 && u_video==1.0)) { - color=processSHADEBOOST(color); - } - #endif - #if(GAMMA==1 || GAMMAv==1) - if((GAMMA==1 && u_video!=1.0) || (GAMMAv==1 && u_video==1.0)) { - color=processGAMMA(color); - } - #endif - #if(SCANLINES==1 || SCANLINESv==1) - if((SCANLINES==1 && u_video!=1.0) || (SCANLINESv==1 && u_video==1.0)) { - color=processSCANLINES(color); - } - #endif - #if(LCD3x==1 || LCD3xv==1) - if((LCD3x==1 && u_video!=1.0) || (LCD3xv==1 && u_video==1.0)) { - color=processLCD3x(color); - } - #endif - #if(VIGNETTE==1 || VIGNETTEv==1) - if((VIGNETTE==1 && u_video!=1.0) || (VIGNETTEv==1 && u_video==1.0)) { - color=processVIGNETTE(color); - } - #endif - #if(TEST==1) - color = processTEST(color); - #endif - #if(TESTANIM==1) - color = processTESTANIM(color); - #endif - gl_FragColor.xyz=color; - gl_FragColor.a = 1.0; -} diff --git a/assets/shaders/LunaVignette.fsh b/assets/shaders/LunaVignette.fsh new file mode 100644 index 0000000000..8f0c3ee0ac --- /dev/null +++ b/assets/shaders/LunaVignette.fsh @@ -0,0 +1,84 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//OTHER FILTERS: +//================ +//#define VIGNETTE 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings +//#define vsize 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values +//#define VIpos 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) +//#define deVi 0 //ON:1/OFF:0 /reverse vignette +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//OTHER FILTERS: +//================ +//#define VIGNETTEv 0 //ON:1/OFF:0 /same as in PPSSPP, just with few settings +//#define vsizev 1.2 //Default: 1.2 /winter... I mean darkness is coming ~ with higher values +//#define VIposv 0.0 //Default: 0.0 /position of the effect between 0.0 and less than 0.5(where it disappears completely) +//#define deViv 0 //ON:1/OFF:0 /reverse vignette +//================ +//Approximate performance hit +//Free: +//Light: VIGNETTE, BLOOM(<= 2 samples) +//Medium: ACARTOON, BLOOM(== 3 samples) +//Heavy: BLOOM(>= 4 samples) +//Extremely Heavy: BLOOM(>= 8 samples) +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + + +//=========== +//=========== + +vec3 processVIGNETTE(vec3 color) { + float vsizeVIGNETTE = u_setting.y; + float VIposVIGNETTE = u_setting.z; + + float distance = dot(v_texcoord0 - 0.5, v_texcoord0 - 0.5); + distance = clamp(distance - VIposVIGNETTE,0.0,1.0); + float vignette; + if(u_setting.w==1.0){ + vignette = 1.1 + distance * vsizeVIGNETTE; + } else { + vignette = 1.1 - distance * vsizeVIGNETTE; + } + color = vignette * color; + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processVIGNETTE(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaXBR.fsh b/assets/shaders/LunaXBR.fsh new file mode 100644 index 0000000000..6bab9cfd4b --- /dev/null +++ b/assets/shaders/LunaXBR.fsh @@ -0,0 +1,433 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" + //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically +//================ +//#define xBR 0 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below +//#define VariantB 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details +//#define Variantx2 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR +//================ +//#define xBRAccuracy 1 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below +//#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding +//#define CornerB 0 //ON:1/OFF:0 / activate only one +//#define CornerD 0 //ON:1/OFF:0 +// CornerC //used as default if no other ones are defined +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" + //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically +//================ +//#define xBRv 0 //ON:1/OFF:0 /5xBR upscale, nice for 2D games especially those that might be buggy with higher rendering res, initially made by Hyllian - license below +//#define VariantBv 0 //ON:1/OFF:0 /slightly less effect on fonts, dots and other small details +//#define Variantx2v 0 //ON:1/OFF:0 /2xBR aka more blurry version of 5xBR +//================ +//#define xBRAccuracyv 1 //ON:1/OFF:0 / Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) ~ copy of the full license below +//#define CornerAv 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding +//#define CornerBv 0 //ON:1/OFF:0 / activate only one +//#define CornerDv 0 //ON:1/OFF:0 +// CornerCv //used as default if no other ones are defined +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: xHQ +//Heavy: xBR, xBRAccuracy +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + + +/* + Hyllian's 5xBR v3.5a Shader + + Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + + +/* + Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r) + + Copyright (C) 2011-2015 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. + + Incorporates some of the ideas from SABR shader. Thanks to Joshua Street. +*/ + + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + +const float lv2_cf = 2.0; +const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25); +const float XBR_SCALE = 3.0; +const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0); +const float coef = 2.0; + +const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 ); +const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 ); +const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 ); +const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 ); +const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 ); +const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 ); +const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 ); +const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 ); +const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 ); + + +vec4 df(vec4 A, vec4 B) { + return abs(A-B); +} + + +// Compare two vectors and return their components are different. +vec4 diff(vec4 A, vec4 B) { + return vec4(notEqual(A, B)); +} + +// Determine if two vector components are equal based on a threshold. +vec4 eq(vec4 A, vec4 B) { + return (step(df(A, B), eq_threshold)); +} + +// Determine if two vector components are NOT equal based on a threshold. +vec4 neq(vec4 A, vec4 B) { + return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B)); +} +float c_df(vec3 c1, vec3 c2) { + vec3 df = abs(c1 - c2); + return df.r + df.g + df.b; +} + +bvec4 _and_(bvec4 A, bvec4 B) { + return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w); +} +bvec4 _or_(bvec4 A, bvec4 B) { + return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w); +} +bvec4 close(vec4 A, vec4 B) { + return (lessThan(df(A, B), vec4(15.0))); +} +vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) { + return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h)); +} + +vec3 processxBR(vec3 color){ + vec2 pS = 1.0 / u_texelDelta.xy; + vec2 fp = fract(v_texcoord0.xy*pS.xy); + vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy; + vec2 dx = vec2(u_texelDelta.x,0.0); + vec2 dy = vec2(0.0,u_texelDelta.y); + vec2 y2 = dy + dy; vec2 x2 = dx + dx; + + // px = pixel, edr = edge detection rule + vec4 edri, edr, edr_l, edr_u, px; + vec4 irlv0, irlv1, irlv2l, irlv2u; + vec4 fx, fx_l, fx_u; // inequations of straight lines. + + vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE); + vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE); + vec4 delta_u = delta_l.yxwz; + + bvec4 edrBR, edr_left, edr_up, pxBR; // px = pixel, edr = edge detection rule + bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up; + bvec4 nc; // new_color + bvec4 fxBR, fx_left, fx_up; // inequations of straight lines. + + vec3 rgbw = vec3(16.163, 23.351, 8.4772); + if(u_setting.y==2.0) { + rgbw = vec3(14.352, 28.176, 5.472); + } + + vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy).xyz; + vec3 B = texture2D(sampler0, TexCoord_0 -dy).xyz; + vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy).xyz; + vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz; + vec3 E = texture2D(sampler0, TexCoord_0 ).xyz; + vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz; + vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy).xyz; + vec3 H = texture2D(sampler0, TexCoord_0 +dy).xyz; + vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy).xyz; + vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz; + vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz; + vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz; + vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz; + vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz; + vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz; + vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz; + vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz; + vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz; + vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz; + vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz; + vec3 F4 = texture2D(sampler0, TexCoord_0 +x2 ).xyz; + + vec4 b = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw)); + vec4 c = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw)); + vec4 d = b.yzwx; + vec4 e = vec4(dot(E,rgbw)); + vec4 f = b.wxyz; + vec4 g = c.zwxy; + vec4 h = b.zwxy; + vec4 i = c.wxyz; + vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw)); + vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw)); + vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw)); + vec4 f4 = h5.yzwx; + + vec3 res; + +if(u_setting.y==2.0) { + // These inequations define the line below which interpolation occurs. + fx = (Ao*fp.y+Bo*fp.x); + fx_l = (Ax*fp.y+Bx*fp.x); + fx_u = (Ay*fp.y+By*fp.x); + + irlv1 = irlv0 = diff(e,f) * diff(e,h); + +if(u_setting.z!=1.0) { // A takes priority skipping other corners + #define SMOOTH_TIPS + // Corner C also default if no other ones used + irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) ); + int select1 = 0; +if(u_setting.z==2.0) {// Corner B + irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) ); + select1 = 1; +} +if(u_setting.z==4.0) { // Corner D + if (select1==0){ + vec4 c1 = i4.yzwx; + vec4 g0 = i5.wxyz; + irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0))); + } +} +} //Corner A if end + + irlv2l = diff(e,g) * diff(d,g); + irlv2u = diff(e,c) * diff(b,c); + + vec4 fx45i = clamp((fx + delta -Co - Ci)/(2.0*delta ), 0.0, 1.0); + vec4 fx45 = clamp((fx + delta -Co )/(2.0*delta ), 0.0, 1.0); + vec4 fx30 = clamp((fx_l + delta_l -Cx )/(2.0*delta_l), 0.0, 1.0); + vec4 fx60 = clamp((fx_u + delta_u -Cy )/(2.0*delta_u), 0.0, 1.0); + + vec4 w1, w2; + w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw); + w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw); + w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw); + w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw); + + w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw); + w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw); + w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw); + w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw); + + edri = step(w1, w2) * irlv0; + edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1); + + w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw); + w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw); + + edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr; + edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr; + + fx45 = edr * fx45; + fx30 = edr_l * fx30; + fx60 = edr_u * fx60; + fx45i = edri * fx45i; + + w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw); + w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw); + + px = step(w1, w2); + +#ifdef SMOOTH_TIPS + vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i)); +#else + vec4 maximos = max(max(fx30, fx60), fx45); +#endif + + vec3 res1 = E; + res1 = mix(res1, mix(H, F, px.x), maximos.x); + res1 = mix(res1, mix(B, D, px.z), maximos.z); + + vec3 res2 = E; + res2 = mix(res2, mix(F, B, px.y), maximos.y); + res2 = mix(res2, mix(D, H, px.w), maximos.w); + + res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2))); +} else { //Version 1 + // These inequations define the line below which interpolation occurs. + fxBR = greaterThan(Ao*fp.y+Bo*fp.x,Co); + fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx); + fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy); + + if (u_setting.z==2.0){ + bvec4 t1 = _and_( notEqual(e, f), notEqual(e, h) ); + bvec4 t2 = _and_( not(close(f, b)), not(close(h, d)) ); + bvec4 t3 = _and_( _and_( close(e, i), not(close(f, i4)) ), not(close(h, i5)) ); + bvec4 t4 = _or_( close(e, g), close(e, c) ); + interp_restriction_lv1 = _and_( t1, _or_( _or_(t2, t3), t4 ) ); + } else { + interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h))); + } + interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g))); + interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c))); + + edrBR = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1)); + edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left)); + edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up)); + + nc.x = ( edrBR.x && (fxBR.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) ); + nc.y = ( edrBR.y && (fxBR.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) ); + nc.z = ( edrBR.z && (fxBR.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) ); + nc.w = ( edrBR.w && (fxBR.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) ); + + pxBR = lessThanEqual(df(e,f),df(e,h)); + + + if (u_setting.z==4.0) { + vec3 E0 = E.xyz; + vec3 E1 = E.xyz; + vec3 E2 = E.xyz; + vec3 E3 = E.xyz; + vec3 P[4]; + P[0] = pxBR.x ? F : H; + P[1] = pxBR.y ? B : F; + P[2] = pxBR.z ? D : B; + P[3] = pxBR.w ? H : D; + if (edrBR.x) { + if (edr_left.x && edr_up.x) { + E3 = mix(E3 , P[0], 0.833333); + E2 = mix(E2 , P[0], 0.25); + E1 = mix(E1 , P[0], 0.25); + } else if (edr_left.x) { + E3 = mix(E3 , P[0], 0.75); + E2 = mix(E2 , P[0], 0.25); + } else if (edr_up.x) { + E3 = mix(E3 , P[0], 0.75); + E1 = mix(E1 , P[0], 0.25); + } else { + E3 = mix(E3 , P[0], 0.5); + } + } + if (edrBR.y) { + if (edr_left.y && edr_up.y) { + E1 = mix(E1 , P[1], 0.833333); + E3 = mix(E3 , P[1], 0.25); + E0 = mix(E0 , P[1], 0.25); + } else if (edr_left.y) { + E1 = mix(E1 , P[1], 0.75); + E3 = mix(E3 , P[1], 0.25); + } else if (edr_up.y) { + E1 = mix(E1 , P[1], 0.75); + E0 = mix(E0 , P[1], 0.25); + } else { + E1 = mix(E1 , P[1], 0.5); + } + } + if (edrBR.z) { + if (edr_left.z && edr_up.z) { + E0 = mix(E0 , P[2], 0.833333); + E1 = mix(E1 , P[2], 0.25); + E2 = mix(E2 , P[2], 0.25); + } else if (edr_left.z) { + E0 = mix(E0 , P[2], 0.75); + E1 = mix(E1 , P[2], 0.25); + } else if (edr_up.z) { + E0 = mix(E0 , P[2], 0.75); + E2 = mix(E2 , P[2], 0.25); + } else { + E0 = mix(E0 , P[2], 0.5); + } + } + if (edrBR.w) { + if (edr_left.w && edr_up.w) { + E2 = mix(E2 , P[3], 0.833333); + E0 = mix(E0 , P[3], 0.25); + E3 = mix(E3 , P[3], 0.25); + } else if (edr_left.w) { + E2 = mix(E2 , P[3], 0.75); + E0 = mix(E0 , P[3], 0.25); + } else if (edr_up.w) { + E2 = mix(E2 , P[3], 0.75); + E3 = mix(E3 , P[3], 0.25); + } else { + E2 = mix(E2 , P[3], 0.5); + } + } + res = (fp.x < 0.50) ? (fp.y < 0.50 ? E0 : E2) : (fp.y < 0.50 ? E1: E3); + } else { + res = nc.x ? pxBR.x ? F : H : nc.y ? pxBR.y ? B : F : nc.z ? pxBR.z ? D : B : nc.w ? pxBR.w ? H : D : E; + } +} + return res; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processxBR(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaXHQ.fsh b/assets/shaders/LunaXHQ.fsh new file mode 100644 index 0000000000..83b9d1fee6 --- /dev/null +++ b/assets/shaders/LunaXHQ.fsh @@ -0,0 +1,131 @@ +//Note : Recommend to use PPSSPP with chain shaders for full functionality. +// This shader has 2 sets of configs, separate for in-game and video +//====================================================================================================================================================================== +//======================================================================================= +//========================================IN-GAME======================================== +//======================================================================================= +//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" + //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically +//================ +//#define xHQ 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution +//#define scaleoffset 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness +//======================================================================================= +//=========================================VIDEO========================================= +//======================================================================================= +//UPSCALING FILTERS: //To use those, you have to set rendering res to smaller than window/display size(x1 for best results) and screen scaling filter to "nearest" + //Starting from v1.1.1-28-g70e9979 you can also add Upscaling=True to ini file(check example) to do it automatically +//================ +//#define xHQv 0 //ON:1/OFF:0 same as 4xHQ in PPSSPP, but actually using output resolution +//#define scaleoffsetv 1.0 //Default: 1.0 /you can tweek it between 0.5 and 1.5, Note: to little = no effect, to high = ugliness +//================ +//Approximate performance hit +//Free: +//Light: +//Medium: xHQ +//Heavy: xBR, xBRAccuracy +//Extremely Heavy: +//====================================================================================================================================================================== +//~packed together, corrected to fit requirements of popular with PPSSPP AMD legacy drivers v11.11(if it works on that, it will on almost anything lol), +// currently meet requirements of GLSL version 100 meaning it will probably run on anything unless the driver is horribly broken +// partially written, ported to glsl where required and tested by LunaMoo (Moon Cow?;p), +// other credits mentioned earlier, any more info / required licenses can be found below. + + +/* + 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from: + http://forums.ngemu.com/showthread.php?t=76098 + + by guest(r) (guest.r@gmail.com) + License: GNU-GPL + + Shader notes: looks better with sprite games +*/ + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +uniform vec4 u_time; +uniform float u_video; + +uniform vec4 u_setting; + +//=========== +// The inverse of the texture dimensions along X and Y +uniform vec2 u_texelDelta; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + + +//=========== +//=========== + +const float mx = 0.325; // start smoothing factor +const float k = -0.250; // smoothing decrease factor +const float max_w = 0.25; // max. smoothing weigth +const float min_w =-0.05; // min smoothing/sharpening weigth + +vec3 processxHQ(vec3 color){ + + float x,y; + + float scaleoffsetxHQ = u_setting.y; + + x = u_pixelDelta.x*((u_texelDelta.x/u_pixelDelta.x)/2.0)*scaleoffsetxHQ; + y = u_pixelDelta.y*((u_texelDelta.y/u_pixelDelta.y)/2.0)*scaleoffsetxHQ; + + vec2 dg1 = vec2( x,y); + vec2 dg2 = vec2(-x,y); + vec2 sd1 = dg1*0.5; + vec2 sd2 = dg2*0.5; + + vec3 c = texture2D(sampler0, v_texcoord0.xy).xyz; + vec3 i1 = texture2D(sampler0, v_texcoord0.xy - sd1).xyz; + vec3 i2 = texture2D(sampler0, v_texcoord0.xy - sd2).xyz; + vec3 i3 = texture2D(sampler0, v_texcoord0.xy + sd1).xyz; + vec3 i4 = texture2D(sampler0, v_texcoord0.xy + sd2).xyz; + vec3 o1 = texture2D(sampler0, v_texcoord0.xy - dg1).xyz; + vec3 o3 = texture2D(sampler0, v_texcoord0.xy + dg1).xyz; + vec3 o2 = texture2D(sampler0, v_texcoord0.xy - dg2).xyz; + vec3 o4 = texture2D(sampler0, v_texcoord0.xy + dg2).xyz; + vec3 dt = vec3(1.0,1.0,1.0); + + float ko1 = dot(abs(o1-c),dt); + float ko2 = dot(abs(o2-c),dt); + float ko3 = dot(abs(o3-c),dt); + float ko4 = dot(abs(o4-c),dt); + float s1d = dot(abs(i1-i3),dt); + float s2d = dot(abs(i2-i4),dt); + float w1 = step(ko1,ko3)*s2d; + float w2 = step(ko2,ko4)*s1d; + float w3 = step(ko3,ko1)*s2d; + float w4 = step(ko4,ko2)*s1d; + + c = (w1*o1+w2*o2+w3*o3+w4*o4+0.1*c)/(w1+w2+w3+w4+0.1); + float lc = c.r+c.g+c.b+0.2; + + w1 = (i1.r+i1.g+i1.b+lc)*0.2; + w1 = clamp(k*dot(abs(c-i1),dt)/w1+mx,min_w,max_w); + w2 = (i2.r+i2.g+i2.b+lc)*0.2; + w2 = clamp(k*dot(abs(c-i2),dt)/w2+mx,min_w,max_w); + w3 = (i3.r+i3.g+i3.b+lc)*0.2; + w3 = clamp(k*dot(abs(c-i3),dt)/w3+mx,min_w,max_w); + w4 = (i4.r+i4.g+i4.b+lc)*0.2; + w4 = clamp(k*dot(abs(c-i4),dt)/w4+mx,min_w,max_w); + + color = w1*i1 + w2*i2 + w3*i3 + w4*i4 + (1.0-w1-w2-w3-w4)*c; + return color; +} + +void main() { + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processxHQ(color); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/LunaxBRZf-DU.fsh b/assets/shaders/LunaxBRZf-DU.fsh new file mode 100644 index 0000000000..b10e2c2049 --- /dev/null +++ b/assets/shaders/LunaxBRZf-DU.fsh @@ -0,0 +1,340 @@ +// Enter your shader in this window +// xBRZ freescale +// based on : + +// 4xBRZ shader - Copyright (C) 2014-2016 DeSmuME team +// +// This file 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. +// +// This file is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with the this software. If not, see . + + +/* + Hyllian's xBR-vertex code and texel mapping + + 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. + +*/ + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +//#define X_FACTOR 0.7991 // Default: 0.7991, for non-stretched use 1.0 +//#define Y_FACTOR 0.831 // Default: 0.831 + +#define BLEND_NONE 0 +#define BLEND_NORMAL 1 +#define BLEND_DOMINANT 2 +#define LUMINANCE_WEIGHT 1.0 +#define EQUAL_COLOR_TOLERANCE 30.0/255.0 +#define STEEP_DIRECTION_THRESHOLD 2.2 +#define DOMINANT_DIRECTION_THRESHOLD 3.6 + +uniform sampler2D sampler0; +uniform vec2 u_pixelDelta; +varying vec2 v_texcoord0; + +uniform float u_video; +uniform vec4 u_setting; + + +float DistYCbCr(vec3 pixA, vec3 pixB) +{ + const vec3 w = vec3(0.2627, 0.6780, 0.0593); + const float scaleB = 0.5 / (1.0 - w.b); + const float scaleR = 0.5 / (1.0 - w.r); + vec3 diff = pixA - pixB; + float Y = dot(diff.rgb, w); + float Cb = scaleB * (diff.b - Y); + float Cr = scaleR * (diff.r - Y); + + return sqrt(((LUMINANCE_WEIGHT * Y) * (LUMINANCE_WEIGHT * Y)) + (Cb * Cb) + (Cr * Cr)); +} + +bool IsPixEqual(const vec3 pixA, const vec3 pixB) +{ + return (DistYCbCr(pixA, pixB) < EQUAL_COLOR_TOLERANCE); +} + +float get_left_ratio(vec2 center, vec2 origin, vec2 direction, vec2 scale) +{ + vec2 P0 = center - origin; + vec2 proj = direction * (dot(P0, direction) / dot(direction, direction)); + vec2 distv = P0 - proj; + vec2 orth = vec2(-direction.y, direction.x); + float side = sign(dot(P0, orth)); + float v = side * length(distv * scale); + +// return step(0, v); + return smoothstep(-sqrt(2.0)/2.0, sqrt(2.0)/2.0, v); +} + +#define eq(a,b) (a == b) +#define neq(a,b) (a != b) + +vec3 processxBRZf(){ + //--------------------------------------- + // Input Pixel Mapping: -|x|x|x|- + // x|A|B|C|x + // x|D|E|F|x + // x|G|H|I|x + // -|x|x|x|- + float sampleModX = u_setting.y; //0.7991 + float sampleModY = u_setting.z; //0.831 + vec2 scaleFactor = vec2((480.0 * u_pixelDelta.x * sampleModX),(270.0 * u_pixelDelta.y * sampleModY)); + vec2 scale = vec2(1.0 / (u_pixelDelta.x / scaleFactor.x), 1.0 / (u_pixelDelta.y / scaleFactor.y)); + vec2 pos = fract(v_texcoord0.xy*scale.xy)- vec2(0.5*sampleModX, 0.5*sampleModY); + vec2 coord = v_texcoord0.xy-pos.xy*vec2(u_pixelDelta.x / scaleFactor.x, u_pixelDelta.y / scaleFactor.y).xy; + vec2 dx = vec2(u_pixelDelta.x / scaleFactor.x,0.0); + vec2 dy = vec2(0.0,u_pixelDelta.y / scaleFactor.y); + vec2 y2 = dy + dy; vec2 x2 = dx + dx; +/* + vec3 A = P(-1.,-1.); + vec3 B = P( 0.,-1.); + vec3 C = P( 1.,-1.); + vec3 D = P(-1., 0.); + vec3 E = P( 0., 0.); + vec3 F = P( 1., 0.); + vec3 G = P(-1., 1.); + vec3 H = P( 0., 1.); + vec3 I = P( 1., 1.); +*/ + vec3 A = texture2D(sampler0, coord -dx -dy ).xyz; + vec3 B = texture2D(sampler0, coord -dy ).xyz; + vec3 C = texture2D(sampler0, coord +dx -dy ).xyz; + vec3 D = texture2D(sampler0, coord -dx ).xyz; + vec3 E = texture2D(sampler0, coord ).xyz; + vec3 F = texture2D(sampler0, coord +dx ).xyz; + vec3 G = texture2D(sampler0, coord -dx +dy ).xyz; + vec3 H = texture2D(sampler0, coord +dy ).xyz; + vec3 I = texture2D(sampler0, coord +dx +dy ).xyz; + + vec3 A1 = texture2D(sampler0, coord -dx -y2).xyz; //-1,-2 + vec3 C1 = texture2D(sampler0, coord +dx -y2).xyz; //1,-2 + vec3 A0 = texture2D(sampler0, coord -x2 -dy).xyz; //-2,-1 + vec3 G0 = texture2D(sampler0, coord -x2 +dy).xyz; //-2,1 + vec3 C4 = texture2D(sampler0, coord +x2 -dy).xyz; //2,-1 + vec3 I4 = texture2D(sampler0, coord +x2 +dy).xyz; //2,1 + vec3 G5 = texture2D(sampler0, coord -dx +y2).xyz; //-1,2 + vec3 I5 = texture2D(sampler0, coord +dx +y2).xyz; //1,2 + vec3 B1 = texture2D(sampler0, coord -y2).xyz; //0,-2 + vec3 D0 = texture2D(sampler0, coord -x2 ).xyz; //-2,0 + vec3 H5 = texture2D(sampler0, coord +y2).xyz; //0,2 + vec3 F4 = texture2D(sampler0, coord +x2 ).xyz; //2,0 + + // blendResult Mapping: x|y| + // w|z| + ivec4 blendResult = ivec4(BLEND_NONE,BLEND_NONE,BLEND_NONE,BLEND_NONE); + + // Preprocess corners + // Pixel Tap Mapping: -|-|-|-|- + // -|-|B|C|- + // -|D|E|F|x + // -|G|H|I|x + // -|-|x|x|- + if (!((eq(E,F) && eq(H,I)) || (eq(E,H) && eq(F,I)))) + { + float dist_H_F = DistYCbCr(G, E) + DistYCbCr(E, C) + DistYCbCr(H5, I) + DistYCbCr(I, F4) + (4.0 * DistYCbCr(H, F)); + float dist_E_I = DistYCbCr(D, H) + DistYCbCr(H, I5) + DistYCbCr(B, F) + DistYCbCr(F, I4) + (4.0 * DistYCbCr(E, I)); + bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_H_F) < dist_E_I; + blendResult.z = ((dist_H_F < dist_E_I) && neq(E,F) && neq(E,H)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE; + } + + + // Pixel Tap Mapping: -|-|-|-|- + // -|A|B|-|- + // x|D|E|F|- + // x|G|H|I|- + // -|x|x|-|- + if (!((eq(D,E) && eq(G,H)) || (eq(D,G) && eq(E,H)))) + { + float dist_G_E = DistYCbCr(G0, D) + DistYCbCr(D, B) + DistYCbCr(G5, H) + DistYCbCr(H, F) + (4.0 * DistYCbCr(G, E)); + float dist_D_H = DistYCbCr(D0, G) + DistYCbCr(G, H5) + DistYCbCr(A, E) + DistYCbCr(E, I) + (4.0 * DistYCbCr(D, H)); + bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_D_H) < dist_G_E; + blendResult.w = ((dist_G_E > dist_D_H) && neq(E,D) && neq(E,H)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE; + } + + // Pixel Tap Mapping: -|-|x|x|- + // -|A|B|C|x + // -|D|E|F|x + // -|-|H|I|- + // -|-|-|-|- + if (!((eq(B,C) && eq(E,F)) || (eq(B,E) && eq(C,F)))) + { + float dist_E_C = DistYCbCr(D, B) + DistYCbCr(B, C1) + DistYCbCr(H, F) + DistYCbCr(F, C4) + (4.0 * DistYCbCr(E, C)); + float dist_B_F = DistYCbCr(A, E) + DistYCbCr(E, I) + DistYCbCr(B1, C) + DistYCbCr(C, F4) + (4.0 * DistYCbCr(B, F)); + bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_B_F) < dist_E_C; + blendResult.y = ((dist_E_C > dist_B_F) && neq(E,B) && neq(E,F)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE; + } + + // Pixel Tap Mapping: -|x|x|-|- + // x|A|B|C|- + // x|D|E|F|- + // -|G|H|-|- + // -|-|-|-|- + if (!((eq(A,B) && eq(D,E)) || (eq(A,D) && eq(B,E)))) + { + float dist_D_B = DistYCbCr(D0, A) + DistYCbCr(A, B1) + DistYCbCr(G, E) + DistYCbCr(E, C) + (4.0 * DistYCbCr(D, B)); + float dist_A_E = DistYCbCr(A0, D) + DistYCbCr(D, H) + DistYCbCr(A1, B) + DistYCbCr(B, F) + (4.0 * DistYCbCr(A, E)); + bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_D_B) < dist_A_E; + blendResult.x = ((dist_D_B < dist_A_E) && neq(E,D) && neq(E,B)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE; + } + + vec3 res = E; + + // Pixel Tap Mapping: -|-|-|-|- + // -|-|B|C|- + // -|D|E|F|x + // -|G|H|I|x + // -|-|x|x|- + if(blendResult.z != BLEND_NONE) + { + float dist_F_G = DistYCbCr(F, G); + float dist_H_C = DistYCbCr(H, C); + bool doLineBlend = (blendResult.z == BLEND_DOMINANT || + !((blendResult.y != BLEND_NONE && !IsPixEqual(E, G)) || (blendResult.w != BLEND_NONE && !IsPixEqual(E, C)) || + (IsPixEqual(G, H) && IsPixEqual(H, I) && IsPixEqual(I, F) && IsPixEqual(F, C) && !IsPixEqual(E, I)))); + + vec2 origin = vec2(0.0, 1.0 / sqrt(2.0)); + vec2 direction = vec2(1.0, -1.0); + if(doLineBlend) + { + bool haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_F_G <= dist_H_C) && neq(E,G) && neq(D,G); + bool haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_H_C <= dist_F_G) && neq(E,C) && neq(B,C); + origin = haveShallowLine? vec2(0.0, 0.25) : vec2(0.0, 0.5); + direction.x += haveShallowLine? 1.0: 0.0; + direction.y -= haveSteepLine? 1.0: 0.0; + } + + vec3 blendPix = mix(H,F, step(DistYCbCr(E, F), DistYCbCr(E, H))); + res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale)); + } + + // Pixel Tap Mapping: -|-|-|-|- + // -|A|B|-|- + // x|D|E|F|- + // x|G|H|I|- + // -|x|x|-|- + if(blendResult.w != BLEND_NONE) + { + float dist_H_A = DistYCbCr(H, A); + float dist_D_I = DistYCbCr(D, I); + bool doLineBlend = (blendResult.w == BLEND_DOMINANT || + !((blendResult.z != BLEND_NONE && !IsPixEqual(E, A)) || (blendResult.x != BLEND_NONE && !IsPixEqual(E, I)) || + (IsPixEqual(A, D) && IsPixEqual(D, G) && IsPixEqual(G, H) && IsPixEqual(H, I) && !IsPixEqual(E, G)))); + + vec2 origin = vec2(-1.0 / sqrt(2.0), 0.0); + vec2 direction = vec2(1.0, 1.0); + if(doLineBlend) + { + bool haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_H_A <= dist_D_I) && neq(E,A) && neq(B,A); + bool haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_D_I <= dist_H_A) && neq(E,I) && neq(F,I); + origin = haveShallowLine? vec2(-0.25, 0.0) : vec2(-0.5, 0.0); + direction.y += haveShallowLine? 1.0: 0.0; + direction.x += haveSteepLine? 1.0: 0.0; + } + origin = origin; + direction = direction; + + vec3 blendPix = mix(H,D, step(DistYCbCr(E, D), DistYCbCr(E, H))); + res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale)); + } + + // Pixel Tap Mapping: -|-|x|x|- + // -|A|B|C|x + // -|D|E|F|x + // -|-|H|I|- + // -|-|-|-|- + if(blendResult.y != BLEND_NONE) + { + float dist_B_I = DistYCbCr(B, I); + float dist_F_A = DistYCbCr(F, A); + bool doLineBlend = (blendResult.y == BLEND_DOMINANT || + !((blendResult.x != BLEND_NONE && !IsPixEqual(E, I)) || (blendResult.z != BLEND_NONE && !IsPixEqual(E, A)) || + (IsPixEqual(I, F) && IsPixEqual(F, C) && IsPixEqual(C, B) && IsPixEqual(B, A) && !IsPixEqual(E, C)))); + + vec2 origin = vec2(1.0 / sqrt(2.0), 0.0); + vec2 direction = vec2(-1.0, -1.0); + + if(doLineBlend) + { + bool haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_B_I <= dist_F_A) && neq(E,I) && neq(H,I); + bool haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_F_A <= dist_B_I) && neq(E,A) && neq(D,A); + origin = haveShallowLine? vec2(0.25, 0.0) : vec2(0.5, 0.0); + direction.y -= haveShallowLine? 1.0: 0.0; + direction.x -= haveSteepLine? 1.0: 0.0; + } + + vec3 blendPix = mix(F,B, step(DistYCbCr(E, B), DistYCbCr(E, F))); + res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale)); + } + + // Pixel Tap Mapping: -|x|x|-|- + // x|A|B|C|- + // x|D|E|F|- + // -|G|H|-|- + // -|-|-|-|- + if(blendResult.x != BLEND_NONE) + { + float dist_D_C = DistYCbCr(D, C); + float dist_B_G = DistYCbCr(B, G); + bool doLineBlend = (blendResult.x == BLEND_DOMINANT || + !((blendResult.w != BLEND_NONE && !IsPixEqual(E, C)) || (blendResult.y != BLEND_NONE && !IsPixEqual(E, G)) || + (IsPixEqual(C, B) && IsPixEqual(B, A) && IsPixEqual(A, D) && IsPixEqual(D, G) && !IsPixEqual(E, A)))); + + vec2 origin = vec2(0.0, -1.0 / sqrt(2.0)); + vec2 direction = vec2(-1.0, 1.0); + if(doLineBlend) + { + bool haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_D_C <= dist_B_G) && neq(E,C) && neq(F,C); + bool haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_B_G <= dist_D_C) && neq(E,G) && neq(H,G); + origin = haveShallowLine? vec2(0.0, -0.25) : vec2(0.0, -0.5); + direction.x -= haveShallowLine? 1.0: 0.0; + direction.y += haveSteepLine? 1.0: 0.0; + } + + vec3 blendPix = mix(D,B, step(DistYCbCr(E, B), DistYCbCr(E, D))); + res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale)); + } + return res; +} + +void main(){ + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + + if(u_setting.x==2.0 || (u_setting.x==0.0 && u_video==0.0) || (u_setting.x==1.0 && u_video==1.0)) { + color=processxBRZf(); + } + + gl_FragColor.xyz=color; + gl_FragColor.a = 1.0; +} \ No newline at end of file diff --git a/assets/shaders/scaling shaders.ini b/assets/shaders/scaling shaders.ini deleted file mode 100644 index af630ee612..0000000000 --- a/assets/shaders/scaling shaders.ini +++ /dev/null @@ -1,36 +0,0 @@ -# You can have multiple ini files if you want, it doesn't matter. -[Customizable Scaling Shader] -Name=Customizable Scaling Shader -Author=LunaMoo -Fragment=Luna.fsh -Vertex=Luna.vsh -OutputResolution=True -#60fps=True -[Video Aware Customizable Scaling Shader] -Name=Video Aware Customizable Scaling Shader -Author=LunaMoo -Fragment=LunaV.fsh -Vertex=Luna.vsh -OutputResolution=True -#60fps=True -[Example Upscaling] -Name=Example Upscaling -Author=LunaMoo -Fragment=Luna2.fsh -Vertex=Luna.vsh -OutputResolution=True -Upscaling=True -#60fps=True -[CSS Mobile] -Name=Customizable Scaling Shader Mobile -Author=LunaMoo -Fragment=LunaM.fsh -Vertex=LunaM.vsh -OutputResolution=True -[EU Mobile] -Name=Example Upscaling Mobile -Author=LunaMoo -Fragment=Luna2M.fsh -Vertex=LunaM.vsh -OutputResolution=True -Upscaling=True \ No newline at end of file