Merge pull request #4142 from DanyalZia/patch-21

Add two more shaders just for fun.
This commit is contained in:
Henrik Rydgård 2013-10-12 10:39:34 -07:00
commit 0cc74bdd67
4 changed files with 101 additions and 1 deletions

View file

@ -0,0 +1,43 @@
//Modified to use in PPSSPP, Grabbed from:
//http://forums.ngemu.com/showthread.php?t=76098
// Advanced Cartoon shader I
// by guest(r) (guest.r@gmail.com)
// license: GNU-GPL
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
const float bb = 0.5; // effects black border sensitivity; from 0.0 to 1.0
uniform sampler2D sampler0;
void main()
{
vec3 c00 = texture2D(sampler0, gl_TexCoord[5].xy).xyz;
vec3 c10 = texture2D(sampler0, gl_TexCoord[1].xy).xyz;
vec3 c20 = texture2D(sampler0, gl_TexCoord[2].zw).xyz;
vec3 c01 = texture2D(sampler0, gl_TexCoord[3].xy).xyz;
vec3 c11 = texture2D(sampler0, gl_TexCoord[0].xy).xyz;
vec3 c21 = texture2D(sampler0, gl_TexCoord[4].xy).xyz;
vec3 c02 = texture2D(sampler0, gl_TexCoord[1].zw).xyz;
vec3 c12 = texture2D(sampler0, gl_TexCoord[2].xy).xyz;
vec3 c22 = texture2D(sampler0, gl_TexCoord[6].xy).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);
float d = bb*(d1+d2+hl+vl)/(dot(c11,dt)+0.15);
float lc = 4.0*length(c11);
float f = fract(lc); f*=f;
lc = 0.25*(floor(lc) + f*f)+0.05;
c11 = 4.0*normalize(c11);
vec3 frct = fract(c11); frct*=frct;
c11 = floor(c11)+ 0.05*dt + frct*frct;
gl_FragColor.xyz = 0.25*lc*(1.1-d*sqrt(d))*c11;
}

View file

@ -0,0 +1,27 @@
attribute vec4 a_position;
attribute vec2 a_texcoord0;
uniform mat4 u_viewproj;
float size = 2.0; //edge detection offset, 2.0-5.0 suitable range
void main()
{
float x = (0.125/480.0)*size;
float y = (0.25/272.0)*size;
vec2 dg1 = vec2( x,y);
vec2 dg2 = vec2(-x,y);
vec2 dx = vec2(x,0.0);
vec2 dy = vec2(0.0,y);
gl_Position = u_viewproj * a_position;
gl_TexCoord[0]=a_texcoord0.xyxy;
gl_TexCoord[1].xy = gl_TexCoord[0].xy - dy;
gl_TexCoord[2].xy = gl_TexCoord[0].xy + dy;
gl_TexCoord[3].xy = gl_TexCoord[0].xy - dx;
gl_TexCoord[4].xy = gl_TexCoord[0].xy + dx;
gl_TexCoord[5].xy = gl_TexCoord[0].xy - dg1;
gl_TexCoord[6].xy = gl_TexCoord[0].xy + dg1;
gl_TexCoord[1].zw = gl_TexCoord[0].xy - dg2;
gl_TexCoord[2].zw = gl_TexCoord[0].xy + dg2;
}

View file

@ -0,0 +1,22 @@
//Simple Scanlines shader
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
uniform sampler2D sampler0;
float offset = 1.0;
float frequency = 170.0;
varying vec2 v_texcoord0;
void main()
{
float pos0 = (v_texcoord0.y + offset) * frequency;
float pos1 = cos((fract( pos0 ) - 0.5)*3.14);
vec4 pel = texture2D( sampler0, v_texcoord0 );
gl_FragColor = mix(vec4(0,0,0,0), pel, pos1);
}

View file

@ -22,4 +22,12 @@ Vertex=fxaa.vsh
Name=Inverse Colors
Author=Henrik
Fragment=inversecolors.fsh
Vertex=fxaa.vsh
Vertex=fxaa.vsh
[Scanlines]
Name=Scanlines
Fragment=Scanlines.fsh
Vertex=fxaa.vsh
[Cartoon]
Name=Advance Cartoon shader
Fragment=Cartoon shader.fsh
Vertex=Cartoon shader.vsh