Add PSP color shader

This adds the PSP color shader ported from RetroArch courtesy from @jdgleaver (https://forums.ppsspp.org/showthread.php?tid=6594&pid=130635#pid130635) to PPSSPP

Also updated with up to date changes found here (https://github.com/libretro/glsl-shaders/blob/master/handheld/shaders/color/psp-color.glsl)
This commit is contained in:
RokkumanX 2020-09-28 09:31:33 +02:00 committed by GitHub
parent 0d3a5a27aa
commit 0f34a7427b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,58 @@
/*
psp_color vertex shader
Original code written by hunterk, modified by Pokefan531 and
released into the public domain
'Ported' (i.e. copy/paste) to PPSSPP format by jdgleaver
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.
Notes: This shader replicates the LCD dynamics of the PSP 1000 and PSP 2000
*/
//================
#ifdef GL_ES
precision mediump float;
precision mediump int;
// For android, use this instead...
//precision highp float;
//precision highp int;
//
#endif
//================
#define target_gamma 2.21
#define display_gamma 2.2
#define r 0.98
#define g 0.795
#define b 0.98
#define rg 0.04
#define rb 0.01
#define gr 0.20
#define gb 0.01
#define br -0.18
#define bg 0.165
//================
uniform sampler2D sampler0;
varying vec2 v_texcoord0;
//================
void main()
{
// Apply colour correction
vec3 screen = pow(texture2D(sampler0, v_texcoord0.xy).rgb, vec3(target_gamma));
screen = clamp(screen, 0.0, 1.0);
screen = pow(
mat3(r, rg, rb,
gr, g, gb,
br, bg, b) * screen,
vec3(1.0 / display_gamma)
);
gl_FragColor = vec4(screen, 1.0);
}

View File

@ -0,0 +1,6 @@
[PSP Color]
Name=PSP Color
Author=hunterk, Pokefan531 (ported by jdgleaver)
Fragment=psp_color.fsh
Vertex=psp_color.vsh
OutputResolution=True

View File

@ -0,0 +1,23 @@
/*
psp_color vertex shader
Original code written by hunterk, modified by Pokefan531 and
released into the public domain
'Ported' (i.e. copy/paste) to PPSSPP format by jdgleaver
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.
*/
attribute vec4 a_position;
attribute vec2 a_texcoord0;
varying vec2 v_texcoord0;
void main()
{
v_texcoord0 = a_texcoord0; // + 0.000001; // HLSL precision workaround (is this needed???)
gl_Position = a_position;
}