Custom PPSSPP shaders - Printable Version

+- (
+-- Forum: PPSSPP - Playstation Portable Simulator Suitable for Playing Portably (/forumdisplay.php?fid=1)
+--- Forum: Development (/forumdisplay.php?fid=3)
+--- Thread: Custom PPSSPP shaders (/showthread.php?tid=6594)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Custom PPSSPP shaders - LunaMoo - 09-29-2013 10:26 PM

It started some time ago with just my fast growning customizable shader for quite a while, but finally we have more than one shader here, so slight reformat was neededSmile.
Here's my own shader which is very customizable(now actually divided to separate files since PPSSPP supports multi level shaders and has UI for their options) and includes:
- 2 Gauss smoothing filters,
- Guest AA 4.o,
- 5xBR variant A and B scaling shader(also includes Guest.r new version with different variants),
- 4xHQ scaling shader,
- scalable xBRZ pre-setted for Street Fighter Alpha 3 MAX, but usable in any game you set it for - doesn't use upscaling flag so if you need an upscaling for video only while keeping the 3D as sharp as it can be you can try this,
- Bloom with "Miku" option for very bright anime games,
- Colored(slight enhance of colors),
- Natural Colors,
- Advanced Cartoon,
- Sharpen,
- Complex Sharpen ,
- Shadeboost(color editing with few presets),
- Gamma correction,
- Vignette with optional reverse effect,
- Simple scanlines with some options, can be horizontal(default) or vertical,
- LCD3x ~ note on mobiles/GLES devices it requires changing "precision mediump" to "precision highp" ~ you can use any text editor to find and replace it inside .fsh file if you want to use it - it might not be supported on all devices through and also might cause everything to be slower that's why I didn't set it by default,
- few debanding methods ~ via blur and noise /dithering(with faster version as well) also includes very heavy bilateral filter now,
- last and frankly least as nobody will use that too oftenTongue, test mode, which allows apply any combination to half screen or animated change from left to right, useful for easy comparison screenshots and tweaking.

Now(shortly before 1.10 release) I also added multi-pass version of this, it'll be potentially more expensive, so I'd recommend removing/skipping passes which you don't use by editing ini files. I grouped certain effects which doesn't have sense to activate together, so activate only one smoothing, sharpening or upscaling effect althrough some other ones can still work together despite being in same pass. I did not used any shader settings yet, because it feels like a lot of work(and also because I forgot about it;p), but probably will in next release. Also take note TEST effects doesn't work yet with this chain shader, they will some time after 1.10 release when [Unknown]'s postshader branch get's merged.

I strongly recommend to customize those shaders for your liking, that's the point of my shader, if PPSSPP could easily mix various effects and allow a noob friendly customization I would more than likely never created it. Example is just so you can see how to add modified version of it to PPSSPP via ini file, check "Changing shader settings" below for more information.

download link ~ last time updated old version: 2017-12-01(y-m-d), new chain version(multi-pass): 2020-05-18, even newer chain version with full UI support(no more editing files): 2021-02-26
Please use PPSSPP v1.10.3-741-g4ccde4848 or newer, older versions doesn't support UI nor test shader in chain.

Installation is same as noted below, just extract all of the files into your ppsspp - assets\shaders\ folder (Android just "...PSP\Shaders" same place where saves are stored).

Included "mobile" versions of the shaders with 2 effects removed(natural colors and LCD3x), those effects weren't even heavy, however I think the only reason vertex shader could fail on mobiles for some people would be caused by passing too many variables to fragment shader and to decrease that, those two effects had to go, I could write them differently, but it would make them slower, with mobiles blah not worth the effort. Especially that it might not help, because I couldn't reproduce any real problem on anything I have.

Latest version should also work with d3d11 by glsl autotranslation(using slang and SPIRV-Cross) ~ which is available starting from v1.3-724-gc355947. Had to correct Guest 4.o AA code to match GLSL standard and added some precision workarounds for simple scanlines and xBR. Vulkan post process shaders are now supported as well ~ from around v1.5.

Also starting from PPSSPP v1.4.2-438-g799c85ebe, a new kind of shaders can be made which are video aware, that is can apply different effects to videos vs in-game, as such I added new preset file with doubled config to make use of it. Warning - this preset is probably too heavy to be used on integrated graphics/low end hardware, I used some very heavy effects together, tested only on fairy powerful desktop;p.

Note: Because my shaders can be used for down/up scaling now, if all you want to use it for is some basic coloring and have very weak gpu that cannot run games in at least your display resolution, you might remove "OutputResolution=True" from each shader in the included ini file. It will break all scaling, as well as scanline effects, but all the simple coloring shaders would still work and end up lighter.
Otherwise I don't recommend changing this, in most situations when used on fairy powerful modern hardware disabling it will probably degrade performance thanks to how downscaling works in ppsspp.

- FFIV video smoothed with new video aware shader
[Image: A0up9KN.jpg]

- same shader
[Image: EpH3gqb.jpg]

(~the text on that screenshot without knowing it's just a Castlevania intro might be a bit confusing;p)

- 10x res 3D game with downscaling shader (Monster Hunter Portable 3rd HD)
[Image: Oh0h66U.jpg]

- as above with less colors added, lots of diagonal edges to see AA effect (Senjou no Valkyria III)
[Image: WGLHMEV.jpg]

- 1x res 2D animation with upscaling shader(Heroes Phantasia)
[Image: m8OCK7j.jpg]

Colors I used might be a bit too deep for most games on default, but hey customization of everything is the point here. Also upscaling shader probably works better on more static objects, but I already posted some screenshots of 5xBR variants in here and wanted to check it on low res animation anyway.
- 5xBR again on more fitting scene/game(PoPoLoCrois)
[Image: yTG0mDX.jpg]


We also now have AA_Shader_v2.0_w_Natural_Vision as well as different versions of this shader + probably some extras ported by naoan which you can get from his post(click).

Comparison screenies:



You can also find different versions of shaders implemented in PPSSPP by default + probably some extras in this Danyal Zia post.

And Nick001's Arcade Scanlines ~ with bunch of screenshots included, if you're into scanlines that might be something to look at. If you get a bug with shader showing only bottom right corner of the screen, you can try my fix for it from this post.

Before it get's hidden, worth linking also Guest.r Updated shaders which has a bunch of different variants of his AA shader.


Installation: Simply unpack to your "..ppsspp\assets\shaders\" folder on Android it should be "...PSP\Shaders".

If the shader comes without it's own ini file you can create an empty ini file in same directory(or just edit an existing oneSmile) and add some more and less important lines inside like in this example based on naoan shader:
Name=AA Shader with Natural Vision
[] - is just a tag, set it whatever you like
Name= - whatever you write here will be visible in the list:)
Author= - that's only visible in the ini file I guess, but it's nice to give credits whenever you can or simply to remember who made it when something changes and shader stops working:)
Fragment= - has to be set to fragment shader file
Vertex= - has to be set to vertex shader file

In addition to above, ppsspp shader ini files also can include lines:
OutputResolution=True   #1
Upscaling=True          #2
RequiresIntSupport=True #3
SSAA=*integer number* #4
60fps=True  #5
1) Scales the output down/up to your display/window resolution. Combined with most blurry/aa filters and rendering res above your device screen will result in nice SSAA effect. Also required for upscaling filters.
2) Forces rendering resolution to x1 and screen scaling filter to nearest - settings required by upscaling shaders to work.
3) Enables integer support, most shaders will not require it.
4) It will set up a resolution with a multiply of set value of current window resolution, so let's say you're running the game in x2 window with x2 SSAA it will have full HD resolution, but if you then switch to fullscreen, it will use a resolution used by your monitor multiplied by 2, such super sampling combined with any blurry filter will result in super sampling AA effect.
5) It does the same thing as the option to duplicate frames up to 60, except this was existing much earlier as it's doing so for shaders that include animation without that flag animation speed would be affected by FPS changes in-game which is bad for a post process.

Changing shader settings:

Just use PPSSPP UI, latest version(post release!) allow shader modification directly from graphics settings menu, I even cut my large shader and provided it in separate effects each with it's own settings.Smile

Simply open the .fsh file(any text editor is enough) and mess aroundWink, my shader has a pretty big, but clean and well described config with alot of extra settings which can totally(and easily) change how it looks. Most shaders even if not specially made for modifications, should come with at least some variables that can be easily edited to change how the result looks like.

My own shader, under defines also comes with a list of approximate performance hit so you get the general idea which shaders to avoid on slower hardware. In general most desktops with modern dedicated gpu(including cheap ones) should be fine with everything, it also depends a lot on the rendering resolution used, for example xBR is easily the heaviest effect there, but due to upscaling shaders requiring x1 rendering res it might actually be lighter than some cheap downscaling shader used with x10 render res even through both would in the end output same resolution image.:]


Creating your own shaders:
It's actually easy, it was a black magic for me as well, but turned out they're easy to code and no point on doing it from 0 either, many effects are already free to use on the net, just search for GLSL fragment shaders that doesn't require multiply passes or even to HLSL pixel shaders since they're easy to port, tutorials are also scattered around the net, easy to find something for any level.

Not sure if it works on NVidia gpu's, but you might try AMD GPU Shader Analyzer which helps alot in terms of debugging or even optimizing and allows to simulate shader compilation on many different AMD GPU's on different driver version(how's that useful you ask? Well if a shader works on AMD it'll rather for sure work on Nvidia~actually not as history proven AMD drivers sometimes were even more understanding:|, also many people with older AMD gpu's ~ HD4000 series and older are using 11.11 drivers since they're considered best for PPSSPP - this tool allows to simulate those conditions which are somewhat unforgiving).

Another nice tool(CLI) OpenGL / OpenGL ES Reference Compiler, no gui makes it a bit more bothersome to use, but will in theory detect all problems, in practice it still fails to ensure shaders will work on mobiles, since they have messed up drivers and this only checks if code follows GLSL standard:].

Due to some recent post in this thread as of 2017-01-29 I have to add that I don't support spreading any of my work done for free especially stuff I really care to be easily customizable by community through some personal beerfund advertisement links and close minded rulesets or on sites that promote those.
Will I bother stopping people from doing it? No, I'm even putting it at the very bottom of the post for most people to not waste time reading this, but I will never support nor promote any of this and if you're normal decent human being you shouldn't either and any average user can do better than whatever they would show on screenshots when begging for fixing something they broke while ripping something they couldn't understand.

RE: Custom PPSSPP shaders - TheDax - 09-29-2013 10:38 PM

Here are a couple(default settings in the shader file, PPSSPP settings are 4x Render res, 3x window size, buffered rendering):

Monster Hunter 3rd HD:
(Click/tap for full size):
[Image: iu3r64rXWhcfx.jpg]

(Click/tap for full size):
[Image: iuGqedctWrJiC.jpg]

This thread gives me an idea for a nice menu option on Windows: Under game settings, I could add a new menu popout that lists all of the shaders you have in the shaders directory and lets you pick

Maybe I'll add it once we have some more shaders.

It'd probably also be possible to add in a second shader program(e.g. run FXAA and another) to combine more effects(say xBRZ/HQ4x and FXAA).

RE: Custom PPSSPP shaders - LunaMoo - 09-30-2013 12:03 AM

That would be nice, hope we get some people that are good with shaders here, I know only basics^_^, lots to learn and little time/lack of will(;p) to do it.

RE: Custom PPSSPP shaders - GuilhermeGS2 - 09-30-2013 02:24 AM

Wow, very nice. I will try on android, but I don't have sure if that will works.

I've tried on 0.9.1-1371 and not worked. May be:

-The PPSSPP for Android doesn't support that (need write a code to support).
-The Android can't read the files.
-I did anything wrong.

I put the files on "PSP/assests/shaders" (the two latest folders not existed before, need create), but didn't work. I tried put on "(root)", and didn't work too.
I enabled the buffer rendering and the FXAA Antialiasing.

RE: Custom PPSSPP shaders - LunaMoo - 09-30-2013 05:04 AM

Hmm, about folders didn't checked earlier, but apparently on android it should go to simply "shaders" dir, either "..ppsspp\shaders" or "(root)" not sure which one, but there should be default shader in there already to point you to correct one. If it's not check which version you have since FXAA was enabled on mobiles in v0.9.1-1319+ and will not have default shader files nor a chance to work in any earlier one.

I'm somewhat curious about the speed of it, if it actually compiles on android(@[email protected]). Initially I thought just FXAA would be overkill already on mobiles, but this default simple FXAA has actually little to do with it's more accurate(less blurry;p) but heavier version. Bloom shader can be easily made lighter by decreasing samples and quality as well. Not so sure about speed after using all of them at once through, so if it works, but will be extremely slow, you can edit the fragment shader file(.fsh) to change some options.^o^

Edit: I installed latest ppsspp on android myself to test it and cannot find the default fxaa.fsh anywhere either. I don't think it's stored externally on android at all(but even default simple fxaa is pretty serious hit to framerate;p).

RE: Custom PPSSPP shaders - solarmystic - 09-30-2013 06:52 AM

I'd like to say that it worked for me, but it doesn't. Enabling FXAA in a game with your customized shader files just causes PPSSPP to crash with a BEX64 error using a 64bit build:-

Problem signature:
  Problem Event Name:    BEX64
  Application Name:    PPSSPPWindows64test1378.exe
  Application Version:
  Application Timestamp:    5248ba6a
  Fault Module Name:    PPSSPPWindows64test1378.exe
  Fault Module Version:
  Fault Module Timestamp:    5248ba6a
  Exception Offset:    0000000000198acc
  Exception Code:    c0000409
  Exception Data:    0000000000000000
  OS Version:    6.1.7601.
  Locale ID:    1033
  Additional Information 1:    d26f
  Additional Information 2:    d26ff532f30d12254825d0eda6694d8e
  Additional Information 3:    2173
  Additional Information 4:    21731f93c13e195ecff107090e482efe

Read our privacy statement online:

If the online privacy statement is not available, please read our privacy statement offline:

Tested using rig in sig, latest 64bit Orphis build and default settings except for FXAA enabled.

RE: Custom PPSSPP shaders - LunaMoo - 09-30-2013 07:43 AM

BEX is related to windows data execution prevention, how's that linked to modded shader? And are you sure it was latest Orphis build? PPSSPPWindows64test1378.exe ~ doesn't really look as default name from Orphis buildbot.

Sorry, but with that I'm totally clueless about that, seems like some quirk of windows. As long as default fxaa works, this shader just add's extra work to it using exactly same input and outputting it's results same way. Something like an abussive firewall or antivirus could potentially prevent the file from being read by ppsspp which could cause BEX error, no clue why it would happen through.

RE: Custom PPSSPP shaders - solarmystic - 09-30-2013 08:23 AM

(09-30-2013 07:43 AM)LunaMoo Wrote:  BEX is related to windows data execution prevention, how's that linked to modded shader? And are you sure it was latest Orphis build? PPSSPPWindows64test1378.exe] ~ doesn't really look as default name from Orphis buildbot.

Sorry, but with that I'm totally clueless about that, seems like some quirk of windows. As long as default fxaa works, this shader just add's extra work to it using exactly same input and outputting it's results same way. Something like an abussive firewall or antivirus could potentially prevent the file from being read by ppsspp which could cause BEX error, no clue why it would happen through.

I just renamed it, since as a PPSSPP tester I run multiple builds in the same folder for ease of testing multiple games and multiple issues, and to prevent any confusion.

Replacing the your shader files with the original packaged ones make FXAA work again. I'm rather clueless myself as to why using your files would cause a BEX64 (DEP) error since I have DEP disabled on my machine.

RE: Custom PPSSPP shaders - vsub_ - 09-30-2013 08:31 AM

Can someone make a shader that is increasing the brightness\gama if it's possible.
Some games are just too dark.

RE: Custom PPSSPP shaders - LunaMoo - 09-30-2013 09:07 AM

@solarmystic Maybe that's exactly a reason why windows go crazy? Doesn't have enough priviledge to check stuff so it pulls the plug out to be safe.;X As far as I know DEP is mostly positive feature in modern windows, not sure about any reason to disable it.

RE: Custom PPSSPP shaders - Nezarn - 09-30-2013 09:26 AM

Thanks for this, it works nicely.

RE: Custom PPSSPP shaders - LunaMoo - 09-30-2013 09:34 AM

Just added "Shadeboost" shader to it, should be what you're looking for @vsub :3 in case you want only that, all other shaders can be disabled easily, just edit .fsh which has all the options at the start of the file.
Shadeboost basically allows change of:
As well as changing rgb color intensity.:3
Edit: blah that shadeboost had a bug with color channels (misleading code comments ~ blah;p) /fixed now

RE: Custom PPSSPP shaders - vsub_ - 09-30-2013 10:34 AM

Thanks(now I'll think about how to make some kind of gui so I can configure it easily)

Btw just as if info you didn't know,after you save the file,just do some kind of update to the window resize,minimize\restore\maximize,stretch,selecting the same rendering resolution and so on will reload the shader and apply the changes...much easier than constantly disabling=>enabling FXAA

RE: Custom PPSSPP shaders - isamu - 09-30-2013 05:03 PM

Wow this is interesting! What about compatibility with SweetFX shaders? I have been dying to use the Advance CRT Arcade Monitor effects shader from SweetFX in PPSSPP.

RE: Custom PPSSPP shaders - TheDax - 09-30-2013 09:28 PM

I don't know much about GLSL yet, but solarmystic's crash seems to be caused by this line:

vec3 color = texture2D(sampler0, v_texcoord0.xy);