Post Reply 
 
Thread Rating:
  • 11 Votes - 4.64 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom PPSSPP shaders
11-20-2021, 02:54 AM (This post was last modified: 11-21-2021 06:02 AM by YouFeng.)
Post: #376
RE: Custom PPSSPP shaders
Code:
// Aces Tonemap
//u_setting.xyz default values (1,0,1)
//Should I post here?

#ifdef GL_ES
precision highp float;
precision highp int;
#endif

uniform sampler2D sampler0;
varying vec2 v_texcoord0;

uniform vec4 u_setting;


const mat3 ACESInputMat = mat3(
    0.59719, 0.07600, 0.02840,
    0.35458, 0.90834, 0.13383,
    0.04823, 0.01566, 0.83777
);


const mat3 ACESOutputMat = mat3(
    1.60475, -0.10208, -0.00327,
    -0.53108,  1.10813, -0.07276,
    -0.07367, -0.00605,  1.07602
);

vec3 RRTAndODTFit(vec3 v)
{
    vec3 a = v * (v + 0.0245786) - 0.000090537;
    vec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;
    return a / b;
}



vec3 aces_main_bakinglab(vec3 color )
{    
      color.x = pow(abs(color.x),u_setting.z);
  color.y = pow(abs(color.y),u_setting.z);
  color.z = pow(abs(color.z),u_setting.z);
        
    color *= exp2(u_setting.y);

    color = ACESInputMat * color;
    
    color = RRTAndODTFit(color);
    
    color = ACESOutputMat*color;
    
    color.x = clamp(color.x,0.0,1.0);
    color.y = clamp(color.y,0.0,1.0);
    color.z = clamp(color.z,0.0,1.0);
    
        color.x = pow(abs(color.x),1.0/u_setting.z);
    color.y = pow(abs(color.y),1.0/u_setting.z);
    color.z = pow(abs(color.z),1.0/u_setting.z);
    
    return color;
}



void main()
{
vec3 color = texture2D(sampler0, v_texcoord0).rgb;
vec3 temp_color = color;
color = aces_main_bakinglab(color) * (1.0/aces_main_bakinglab(vec3(1.0,1.0,1.0)));
color = mix(temp_color,color,u_setting.x);
    gl_FragColor.rgb = color.rgb;
}
Code:
//Color Temperature
//Can change Game's color temperature cold or warm
//u_setting.xy default value (400,1)

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

uniform sampler2D sampler0;
varying vec2 v_texcoord0;

uniform vec4 u_setting;


vec3 ColorTemperatureToRGB(float temperatureInKelvins)
{
    vec3 retColor;
    
    temperatureInKelvins = clamp(temperatureInKelvins, 1000.0, 40000.0) / 100.0;
    
    if (temperatureInKelvins <= 66.0)
    {
        retColor.r = 1.0;
        retColor.g = clamp((0.39008157876901960784 * log(temperatureInKelvins) - 0.63184144378862745098), 0.0, 1.0);
    }
    else
    {
        float t = temperatureInKelvins - 60.0;
        retColor.r = clamp((1.29293618606274509804 * pow(t, -0.1332047592)), 0.0, 1.0);
        retColor.g = clamp((1.12989086089529411765 * pow(t, -0.0755148492)), 0.0, 1.0);
    }
    
    if (temperatureInKelvins >= 66.0)
        retColor.b = 1.0;
    else if(temperatureInKelvins <= 19.0)
        retColor.b = 0.0;
    else
        retColor.b = clamp((0.54320678911019607843 * log(temperatureInKelvins - 10.0) - 1.19625408914), 0.0, 1.0);

    return retColor;
}

vec3 RGBtoHCV(vec3 RGB)
{
    // Based on work by Sam Hocevar and Emil Persson
    vec4 P = (RGB.g < RGB.b) ? vec4(RGB.bg, -1.0, 2.0/3.0) : vec4(RGB.gb, 0.0, -1.0/3.0);
    vec4 Q = (RGB.r < P.x) ? vec4(P.xyw, RGB.r) : vec4(RGB.r, P.yzx);
    float C = Q.x - min(Q.w, Q.y);
    float H = abs((Q.w - Q.y) / (6.0 * C ) + Q.z);
    return vec3(H, C, Q.x);
}

vec3 RGBtoHSL(vec3 RGB)
{
    vec3 HCV = RGBtoHCV(RGB);
    float L = HCV.z - HCV.y * 0.5;
    float S = HCV.y / (1.0 - abs(L * 2.0 - 1.0) );
    return vec3(HCV.x, S, L);
}

vec3 HUEtoRGB(float H)
{
    float R = abs(H * 6.0 - 3.0) - 1.0;
    float G = 2.0 - abs(H * 6.0 - 2.0);
    float B = 2.0 - abs(H * 6.0 - 4.0);
    R = clamp(R,0.0,1.0);
    G = clamp(G,0.0,1.0);
    B = clamp(B,0.0,1.0);
    return vec3(R,G,B);
}

vec3 HSLtoRGB(in vec3 HSL)
{
    vec3 RGB = HUEtoRGB(HSL.x);
    float C = (1.0 - abs(2.0 * HSL.z - 1.0)) * HSL.y;
    return (RGB - 0.5) * C + vec3(HSL.z);
}



void main()
{


        float tmp_x = (u_setting.x+1.0)*100.0;
        vec3 color = texture2D(sampler0, v_texcoord0).xyz;        
        vec3 kColor    = ColorTemperatureToRGB( tmp_x);
        vec3 oLum      = RGBtoHSL( color.xyz );
        vec3 tmp = color.xyz * kColor.xyz;
        vec3 blended   = mix( color.xyz,tmp.xyz,u_setting.y);
        vec3 resHSV    = RGBtoHSL( blended.xyz );
        vec3 resRGB    = HSLtoRGB( vec3( resHSV.xy, oLum.z ));
        color.xyz        = mix( blended.xyz, resRGB.xyz, 1.0 );
        gl_FragColor.rgb = color;
        
}

This is two I usually use in gta vcs

I can use pc's reshade to get game's depth buffer memory address to CE.But I don't know how to use code to operate it, damn.I guess I have to give up....

Such as far plane use high sharpening, near is low.It is the basic....But I can't even achieve.


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
11-20-2021, 04:02 AM
Post: #377
RE: Custom PPSSPP shaders
And the screen space reflection, or the ambient occlusion, it is not just need depth......I give up now....
Find all posts by this user
Quote this message in a reply
11-21-2021, 01:06 AM (This post was last modified: 11-21-2021 01:07 AM by LunaMoo.)
Post: #378
RE: Custom PPSSPP shaders
I think you're confusing something, what you want is not supported and you can't just input to an emulator post process shader whatever you want from external software, you need to provide it within PPSSPP's own system.

That's why I said pull requests are welcome, because you'd need to figure out how to and modify the PPSSPP itself(and I don't mean to modify it to read some stuff from external software, but to simply provide the information on it's own).




When you're posting a post process effect in the forums, best if you just pack the file(ie. using 7z) and if you're posting the code, just place it between [ code ] and [ /code ] (without spaces inside []) this will create a window like that:

Code:
Where you can place even very long text and it'll preserve the code formatting and keep it short for people that just want to read the text.

The way you posted makes your post very hard to read and also broke the formatting of the code itself.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
11-21-2021, 05:59 AM
Post: #379
RE: Custom PPSSPP shaders
Ok.I pack the file.These are some post process effects I convert from Reshade.Include Aces Tonemap, Temperature,level,HDR,Vibrance.....Just put those into shader folder it works.


Attached File(s)
.7z  reshadeshaders_ PPSSPP.7z (Size: 3.74 KB / Downloads: 1006)
Find all posts by this user
Quote this message in a reply
11-30-2021, 01:55 PM
Post: #380
RE: Custom PPSSPP shaders
Hello,
I would like to play with shaders but can you please explain me a little that I have to do with... Huh
And if I understand correctly PPSSPP is PlayStation portable, right?
Find all posts by this user
Quote this message in a reply
01-11-2022, 09:01 PM
Post: #381
RE: Custom PPSSPP shaders
Hi can some won add nice shader 2xbrz ?

I tried to use it in the program but it doesn't do it in real time and it takes a few seconds to load the textures

I'm looking for something for a custom shader 2 xbrz I'm looking for something with anti-aliasing
Find all posts by this user
Quote this message in a reply
01-12-2022, 08:31 AM
Post: #382
RE: Custom PPSSPP shaders
If you wanted to actually use a post process, just use existing BR family shaders, they're all same differing only by rounding over corners which doesn't give that much of a difference in PSP games as it would in NES or SNES games where those differences were relevant, if it doesn't have AA, you can just add a different one in the chain.

What you used is texture scaling which outside of Vulkan backend can only be done on CPU and does have a delay because even most powerful CPU's are not powerful enough to upscale textures in real time. Vulkan does have GPU texture upscaling with two methods implemented that at least on gaming hardware can be done in real time.

None of that is what this thread is about which is about post process effects, that is effects applied after rendering is all done. Post process effect does not have any delay, through upscaling through post process shaders is not recommended outside fully 2D games since those shaders are applied on the output not per texture.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
01-12-2022, 09:16 PM (This post was last modified: 01-12-2022 09:18 PM by zerr10.)
Post: #383
RE: Custom PPSSPP shaders
So there is no anti-aliasing that doesn't cause a bug in the image?

I used xbr v2, v3, v4, v5 but unfortunately the textures require a few seconds to load so that there are no slowdowns so I write in the emulator you can't turn it off? to constantly redraw everything on a level because what changes the scene needs these few seconds to load textures

but in the built-in xbr v2, v4 scaler this is not the case, unfortunately these options do not smooth all textures like the above options.

I also tried FXAA but you can't see if it works at all ...
nobody here has some shader to smooth the edges?


unfortunately some options cause a text bug .. especially in naruto games
Find all posts by this user
Quote this message in a reply
02-19-2022, 10:36 AM (This post was last modified: 02-19-2022 10:37 AM by zerr10.)
Post: #384
RE: Custom PPSSPP shaders
question you can't turn off this constant loading of textures to keep xbrz active all the time? because the textures will change every frame and you can see the pixels ...

there is some way even at the expense of performance?
Find all posts by this user
Quote this message in a reply
02-19-2022, 01:47 PM
Post: #385
RE: Custom PPSSPP shaders
The "expense of performance" equals to freezes and stutters doesn't matter how high end the hardware is. CPU texture upscaling is too heavy doesn't matter what kind of machine is used, hence why it loads with a delay when needed, the delay is much shorter with texture replacement and results are far superior even with automatic scalers like lollypop or UltraYandere, so it's not a big deal anyway.

Either way you keep asking about texture scaling which isn't really the point of this thread which is about postprocess effects. Also texture replacement has nothing to do with anti aliasing, if you want AA and have powerful hardware best one would be SSAA, on low res displays a higher SSAA could be nice to use, through in more modern 4k or 8k, standard SSAA is already overkill and deals with aliasing. No post process shader can increase the resolution of a "texture" ouside of upscaling shaders when textures render at 1:1 res on flat surfaces(aka 2D games).

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
02-20-2022, 12:20 PM
Post: #386
RE: Custom PPSSPP shaders
(02-19-2022 01:47 PM)LunaMoo Wrote:  The "expense of performance" equals to freezes and stutters doesn't matter how high end the hardware is. CPU texture upscaling is too heavy doesn't matter what kind of machine is used, hence why it loads with a delay when needed, the delay is much shorter with texture replacement and results are far superior even with automatic scalers like lollypop or UltraYandere, so it's not a big deal anyway.

Either way you keep asking about texture scaling which isn't really the point of this thread which is about postprocess effects. Also texture replacement has nothing to do with anti aliasing, if you want AA and have powerful hardware best one would be SSAA, on low res displays a higher SSAA could be nice to use, through in more modern 4k or 8k, standard SSAA is already overkill and deals with aliasing. No post process shader can increase the resolution of a "texture" ouside of upscaling shaders when textures render at 1:1 res on flat surfaces(aka 2D games).



another question and it would not be possible to add post processing as it is in the xenia emulator from nivide and amd?
Find all posts by this user
Quote this message in a reply
02-20-2022, 01:58 PM
Post: #387
RE: Custom PPSSPP shaders
I don't care about Xenia, but there's nothing Nvidia or AMD has that's done by post process which is worth porting to PPSSPP which is why nobody did it yet:
- full FXAA version is meh compared to simply using SSAA(the FXAA we have is much lighter version that's nice to use on lower end hardware like smartphones),
- AMD FSR is a picture-degrading performance feature which might be useful for complex modern games that have problems running at 4k on high end hardware, it however is pretty useless in PSP games that easily render at 8k and more even on mediocre gpu's,
- CAS is just sharpening, we have sharpen filters that does the same, the thing is sharpening is opposite to AA which is especially noticeable at low res and most people choose AA.


PPSSPP has it's own post process shader support which is way more robust than in other emulators, just to name a few unique features:
- ability to set different effects when video is playing,
- ability to affect post process by game memory changes(via special ppsspp-only cwcheat) some ideas how this can be used is to for example flash the screen on hit, make a blur effect above certain speed, reduce colors on hp drop, add bloom when spells are casted etc.,
- auto-translation from GLSL to all backends that support post process shaders(meaning for all except D3D9 which is kept as a legacy backend for really rare cases of awfully old windows based hardware),
- multi pass shaders where passes can be easily controlled via UI.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
03-17-2022, 06:32 AM (This post was last modified: 03-17-2022 06:33 AM by el_rika.)
Post: #388
RE: Custom PPSSPP shaders
Hy there Luna,

Could a shader similar to "response time" in Retroarch (or a motion-blur with adjustable value), which simulates the motion blur/ghosting of different types of screen response in miliseconds, be added to the Android (vulkan) version?

It creates a beautiful sense of fast movement and smoothness, like motion blur in modern games. Would it be a difficult undertaking? (there are already "response-time" and "motion-blur" shaders in libretro repository, but i'm guessing they would need to be modified for ppsspp).

Thanks.so.much !
Find all posts by this user
Quote this message in a reply
07-11-2022, 09:15 AM (This post was last modified: 07-11-2022 10:28 PM by LunaMoo.)
Post: #389
RE: Custom PPSSPP shaders
Sorry, didn't notice earlier.

Anyway for motion blur, PPSSPP currently exposes previous frame to allow simulating ghosting of the original PSP <=2000 screens. As far as I can tell the shaders you're mentioning are doing just a basic blend between past frames with a drop off and are in no way difficult to write from 0, however they can't be written without exposing higher number of past frames in PPSSPP which due to lack of demand isn't a thing as of now, I guess enhancements typically concentrate on disabling motion blur in games that has it than the other way around^_^;.

Edit: I don't suffer from much free time recently, but opened a feature request on github, hopefully it will interest someone enough to implement this.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
12-27-2022, 07:00 PM
Post: #390
RE: Custom PPSSPP shaders
I have a weird issue with shaders on the latest version of PPSSPP. After a specific cinematic in crisis core the video wobbles like crazy, here take a look.





When that happens, if I turn off shaders it's back to normal, but if I reenable any shader it does this again. Only way to fix is to change the rendered resolution. Or disable all shaders before the cinematic Huh

If you want to test it's early in the game, it's the cinematic right after the double boss during the first mission in wutai. I have a save right before the boss if you want https://drive.google.com/file/d/1nS4aSQ6...share_link

I've tried D3D11 and Vulkan. I'm using default settings except I disabled fast memory because it crashes in some games.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: