forums.PPSSPP.org
Custom PPSSPP shaders - Printable Version

+- forums.PPSSPP.org (https://forums.ppsspp.org)
+-- 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


RE: Custom PPSSPP shaders - Danyal Zia - 10-31-2013 04:54 PM

Updated the link in original post Smile Also removed OGL2Lookup which was useless.


RE: Custom PPSSPP shaders - Combone - 10-31-2013 05:15 PM

(10-31-2013 04:54 PM)Danyal Zia Wrote:  Updated the link in original post Smile Also removed OGL2Lookup which was useless.

Thanks Alot!

SmileSmileBig GrinBig Grin

Works Nice Cool

....

Need now shader: AA Shader v2.o - Daisy

Angel Please


RE: Custom PPSSPP shaders - naoan - 10-31-2013 05:16 PM

(10-31-2013 03:37 PM)Combone Wrote:  @Danyal Zia

Shaders...
Must be converted again Sad

New version of PPSSPP cause Blackscreen.

EDIT:

This Shaders...

AA Shader v2.o
AA Shader v2.o - Daisy
AA shaders AA Shader v2.o - Bloom


Cause blackscreen too Sad

Here's the updated version of my port (along with the requested aa 2d 3d, which look bad btw Tongue) http://www.mediafire.com/?m01rx1t6czuvju3

Just unpack it to assets/shaders folder, delete the old shaders file and the entries inside the defaultshaders.ini if you have it, I've put it inside the extra.ini so it would not get overwritten if you update your ppsspp.


RE: Custom PPSSPP shaders - Combone - 10-31-2013 05:40 PM

(10-31-2013 05:16 PM)naoan Wrote:  
(10-31-2013 03:37 PM)Combone Wrote:  @Danyal Zia

Shaders...
Must be converted again Sad

New version of PPSSPP cause Blackscreen.

EDIT:

This Shaders...

AA Shader v2.o
AA Shader v2.o - Daisy
AA shaders AA Shader v2.o - Bloom


Cause blackscreen too Sad

Here's the updated version of my port (along with the requested aa 2d 3d, which look bad btw Tongue) http://www.mediafire.com/?m01rx1t6czuvju3

Just unpack it to assets/shaders folder, delete the old shaders file and the entries inside the defaultshaders.ini if you have it, I've put it inside the extra.ini so it would not get overwritten if you update your ppsspp.

Angel

Thanks Smile

Go Go Test Big Grin

.............

EDIT:

Tested..

Shy

AA Shader + Natural Vision

[Image: svrx.png]
[Image: kbc4.png]

*************

AA 2D+3D GLSL

[Image: vkti.png]


RE: Custom PPSSPP shaders - Combone - 11-01-2013 05:45 PM

About StoryBook Shader..

Someone has tested? (PPSSPP Emulator Huh )..

Shader demonstration..





.....

[Image: db3.jpg]


RE: Custom PPSSPP shaders - KillaMaaki - 11-05-2013 02:23 AM

Hello all. This is my first post in the PPSSPP community! Big Grin

Anyway, I downloaded PPSSPP so that I could emulate Birth By Sleep (actually purchased Birth By Sleep on Amazon for the purpose).
As I played it, I realized there was one thing missing - when I played KH1 and 2, I played them on those old NTSC televisions. I wanted to replicate that feel as a post process shader, and I'm nearly there.
There is just one thing I need - is there any way to get some kind of time value in the shader? I want to scroll the scanlines over time, but have no idea how.
Any help?


RE: Custom PPSSPP shaders - Henrik - 11-05-2013 08:54 AM

Hm, sorry there's no time value yet, might add one though.


RE: Custom PPSSPP shaders - naoan - 11-05-2013 09:39 AM

(11-05-2013 02:23 AM)KillaMaaki Wrote:  Hello all. This is my first post in the PPSSPP community! Big Grin

Anyway, I downloaded PPSSPP so that I could emulate Birth By Sleep (actually purchased Birth By Sleep on Amazon for the purpose).
As I played it, I realized there was one thing missing - when I played KH1 and 2, I played them on those old NTSC televisions. I wanted to replicate that feel as a post process shader, and I'm nearly there.
There is just one thing I need - is there any way to get some kind of time value in the shader? I want to scroll the scanlines over time, but have no idea how.
Any help?

Can't you just do some loop from top to bottom pixel until it reset back to top periodically? Not sure if that's what you want though.


RE: Custom PPSSPP shaders - KillaMaaki - 11-05-2013 04:17 PM

(11-05-2013 09:39 AM)naoan Wrote:  
(11-05-2013 02:23 AM)KillaMaaki Wrote:  Hello all. This is my first post in the PPSSPP community! Big Grin

Anyway, I downloaded PPSSPP so that I could emulate Birth By Sleep (actually purchased Birth By Sleep on Amazon for the purpose).
As I played it, I realized there was one thing missing - when I played KH1 and 2, I played them on those old NTSC televisions. I wanted to replicate that feel as a post process shader, and I'm nearly there.
There is just one thing I need - is there any way to get some kind of time value in the shader? I want to scroll the scanlines over time, but have no idea how.
Any help?

Can't you just do some loop from top to bottom pixel until it reset back to top periodically? Not sure if that's what you want though.

That's the thing though - without a time value I can't do any animation in the shader.
I actually prototyped this shader with the Unity game engine first - there they expose a global _Time vector which contains various multiples of the current time. I use that to offset scan position per pixel (which scrolls the scanlines).

To give a bit more detail on the shader, it first calculates scanlines - per pixel it's either 1 or 0, forming horizontal stripes.
It uses that to offset UV position, so on 1 it offsets a few pixels to the right, on 0 it doesn't offset. Makes it look a bit like those staggered phosphor TVs.
It also splits the red and green channels, shifting each left and right slightly to kind of simulate NTSC color bleed.

It actually looks really good when I animate the scanlines (in my Unity prototype), but without the animation it kind of looks boring.

EDIT: Actually, on a side note, anybody know how to implement multipass shaders? Thinking about porting over an actual NTSC shader, but they're all 3-pass and I'm unsure how to do this with PPSSPP.

EDIT 2: Got the first pass of the NTSC shader ported. Currently looks exactly like what happens when you connect a Y cable to a composite connection (you get a grayscale image with a few color artifacts/bleeding)

EDIT 3: Here's a prototype I made with the Unity game engine
https://dl.dropboxusercontent.com/u/99106620/CRT%20Effect/CRTDemo.html
It's off by default, hit "Toggle NTSC" to turn it on/off.

If I could make a multipass shader in PPSSPP (and have access to some kind of Time or frame count value) I would really love to get this ported over.


RE: Custom PPSSPP shaders - ZeroX4 - 12-02-2013 06:22 AM

will there be more shaders ? or like can we add ones from epsxe emulator or will they not work ?


RE: Custom PPSSPP shaders - LunaMoo - 12-02-2013 04:53 PM

Just a small(?) news - we can use time value now in our shaders.
Code:
v0.9.5-824-g7c7c4aa    Henrik RydgĂ„rd    2013-12-02 17:24:20    Add "u_time" uniform to postprocessing shaders.

basically set a
Code:
uniform vec4 u_time;
list of parameters from the code page:
float time[4] = {time_now(), (vCount % 60) * 1.0f/60.0f, (float)vCount, (float)(flipCount % 60)};

Tested it by setting one effect to show every second frame and seems to work, althrough I have no idea about using it to improve graphics, guess it was made on @KillaMaaki request ~ good luck with your NTSC shader^_^, multipass is still not possible or so I guess.


RE: Custom PPSSPP shaders - Kokoro - 12-05-2013 08:34 PM

Hi.
Like LunaMoo I was trying to merge two shaders: FXAA with Natural, but I'm not good with this and cant menage Natural shader to work together with FXAA shader. If someone could help me, with what is wrong in my code, and could improve it to work, I would be grateful.

fsh file
Code:
//================
//Extra options:
#define FXAA         1         //ON:1/OFF:0
//================
#define NATURAL      1         //ON:1/OFF:0
//================

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

uniform sampler2D sampler0;
uniform sampler2D sampler1;
varying vec4 v_texcoord1;
varying vec4 v_texcoord2;
varying vec4 v_texcoord3;
varying vec4 v_texcoord4;

// The inverse of the texture dimensions along X and Y
uniform vec2 u_texelDelta;
varying vec2 v_texcoord0;

//================
void main()
{
  // The parameters are hardcoded for now, but could be
  // made into uniforms to control fromt he program.
#if(FXAA==1)
  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.xy + (vec2(-1.0, -1.0) * u_texelDelta)).xyz;
  vec3 rgbNE = texture2D(sampler0, v_texcoord0.xy + (vec2(+1.0, -1.0) * u_texelDelta)).xyz;
  vec3 rgbSW = texture2D(sampler0, v_texcoord0.xy + (vec2(-1.0, +1.0) * u_texelDelta)).xyz;
  vec3 rgbSE = texture2D(sampler0, v_texcoord0.xy + (vec2(+1.0, +1.0) * u_texelDelta)).xyz;
  vec3 rgbM  = texture2D(sampler0, v_texcoord0.xy).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.xy + dir * (1.0/3.0 - 0.5)).xyz +
              texture2D(sampler0, v_texcoord0.xy + dir * (2.0/3.0 - 0.5)).xyz);
  vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (
              texture2D(sampler0, v_texcoord0.xy + dir * (0.0/3.0 - 0.5)).xyz +
              texture2D(sampler0, v_texcoord0.xy + dir * (3.0/3.0 - 0.5)).xyz);
  float lumaB = dot(rgbB, luma);

  if((lumaB < lumaMin) || (lumaB > lumaMax)){
    gl_FragColor.xyz=rgbA;
  } else {
    gl_FragColor.xyz=rgbB;
  }
  gl_FragColor.a = 1.0;
}

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);

void second()
{
#if(NATURAL==1)
vec3 c0,c1;

c0 = texture2D(sampler1,v_texcoord1.xy).xyz;
c0+=(texture2D(sampler1,v_texcoord1.zy).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord1.xw).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord1.zw).xyz)*0.125;

c0+= texture2D(sampler1,v_texcoord2.xy).xyz;
c0+=(texture2D(sampler1,v_texcoord2.zy).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord2.xw).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord2.zw).xyz)*0.125;

c0+= texture2D(sampler1,v_texcoord3.xy).xyz;
c0+=(texture2D(sampler1,v_texcoord3.zy).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord3.xw).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord3.zw).xyz)*0.125;

c0+= texture2D(sampler1,v_texcoord4.xy).xyz;
c0+=(texture2D(sampler1,v_texcoord4.zy).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord4.xw).xyz)*0.25;
c0+=(texture2D(sampler1,v_texcoord4.zw).xyz)*0.125;
c0*=0.153846153846;

c1=RGBtoYIQ*c0;

c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz);

gl_FragColor.xyz=YIQtoRGB*c1;

}

vsh file
Code:
uniform vec4 u_texelDelta;

attribute vec4 a_position;
attribute vec2 a_texcoord0;
varying vec2 v_texcoord0;
varying vec4 v_texcoord1;
varying vec4 v_texcoord2;
varying vec4 v_texcoord3;
varying vec4 v_texcoord4;

void main()
{
  v_texcoord0 = a_texcoord0;
  gl_Position = a_position;

  v_texcoord1=a_texcoord0.xyxy+vec4(-0.5,-0.5,-1.5,-1.5)*u_texelDelta.xyxy;
  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;
}



RE: Custom PPSSPP shaders - LunaMoo - 12-06-2013 01:21 PM

void main() is the return function, you have to mix both shaders there, also vsh file of natural ~ vertex shader had a small, but confusing bug:
Code:
uniform vec4 u_texelDelta;
should be
Code:
uniform vec2 u_texelDelta;
;p since it only returns 2 parameters and vec4 was either a typo or error on the author side most likely. As even below where it's used:
Code:
u_texelDelta.xyxy;
it only uses 2 parametersTongue.

Joined them myself now ~ you can download and see how I did it.


RE: Custom PPSSPP shaders - Kokoro - 12-06-2013 03:31 PM

Now I understand what's going on. Thanks for the response and help, now I know how to combine shaders with each other. +1 Rep for you Wink


RE: Custom PPSSPP shaders - globe94 - 12-09-2013 07:07 PM

* Brothers!
* i need a little help.
* this is my first try to use custom shaders i got from browsing the whole thread.
* i cant make it work Sad

* im using latest build u can see on buildbot.
* on android.
* i extracted the files in sdcard > PSP > shaders
* then opened ppsspp.
* when i select the " PostP Shader " button in the options
* ppsspp crashes.
* shaders i tried can be found on the first page.