Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- PhosphorLUT-GTU v1.1
- This shader uses an external lookup texture (LUT) to create a shadow mask with individual RGB phosphor lenses.
- You can swap out the LUTs by changing the 'file' referenced in Line 11.
- This version uses aliaspider's GTU shader code to create the phosphor bloom, rather than 2 passes of gaussian blur.
- Author: hunterk and aliaspider
- License: GPL (contains code from other GPL shaders).
- -->
- <shader language="GLSL">
- <texture id="phosphorLUT" file="480pvert.png" filter="linear"/>
- <vertex><![CDATA[
- void main()
- {
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
- gl_TexCoord[1].xy = gl_MultiTexCoord1.xy;
- }
- ]]></vertex>
- <fragment filter="linear" outscale="2.0"><![CDATA[
- uniform sampler2D rubyTexture;
- uniform sampler2D phosphorLUT;
- void main()
- {
- vec4 frame = texture2D(rubyTexture, gl_TexCoord[0].xy);
- vec4 inverse = 1 - texture2D(rubyTexture, gl_TexCoord[0].xy);
- vec4 screen = texture2D(phosphorLUT, gl_TexCoord[1].xy);
- gl_FragColor = screen - inverse;
- }
- ]]></fragment>
- <vertex><![CDATA[
- //--------------------------------------------------------------------------//
- // CONFIG :
- // uncomment next line to zoom the picture removing
- // horizontal and vertical overscan
- // #define CROP_OVERSCAN
- // CONFIG END.
- //--------------------------------------------------------------------------//
- uniform vec2 rubyTextureSize;
- uniform vec2 rubyInputSize ;
- uniform vec2 rubyOutputSize;
- void main() {
- vec4 pos = ftransform();
- #ifdef CROP_OVERSCAN
- pos.w=0.94;
- #endif
- gl_Position=pos;
- gl_TexCoord[0] = gl_MultiTexCoord0;
- }
- ]]></vertex>
- <fragment filter="nearest"><![CDATA[
- //--------------------------------------------------------------------------//
- // CONFIG :
- // a dirty fix for higan-accuracy because it handles
- // changes in game resolution differently
- //
- // #define HIGAN_ACCURACY
- // select scaling Kernel
- // 0 - Gaussian ( default )
- // 1 - Spline ( almost like Gaussian with a KERNEL_WIDTH = 1.88561808316
- // but without the ( barely visible) checkerboard effect. slower)
- // 2 - Bilinear
- //
- #define KERNEL 0
- // for gaussian kernel only :
- // define Kernel width and height ( how big an original pixel becomes)
- // higher values cause more blur, might be beneficial for some games.
- // lower values cause the gap between the original pixels to become visible
- // reducing this value for the height only produces a scanline effect
- // valid range : [ 0.5 : 4.0 ]
- // default is 1.88561808316 = (4.0f*sqrt(2.0f)/3.0f)
- //
- #define KERNEL_WIDTH 1.88561808316
- // you can set a different value for the kernel height if needed
- // otherwise KERNEL_WIDTH will be used for both
- //
- //#define KERNEL_HEIGHT 1.0
- // desired gamma value for the emulated CRT-TV
- // default 2.2
- //
- #define GAMMA_IN 2.2
- // the gamma value of the current display device
- // default 2.2
- //
- #define GAMMA_OUT 2.2
- // CONFIG END.
- //--------------------------------------------------------------------------//
- uniform sampler2D rubyTexture;
- uniform vec2 rubyTextureSize;
- uniform vec2 rubyInputSize ;
- uniform vec2 rubyOutputSize;
- #define pi 3.14159265358
- //uncommenting this line might give some speed-up on Nvidia GPUs
- // #pragma optionNV(unroll all)
- #ifndef KERNEL_HEIGHT
- #define KERNEL_HEIGHT KERNEL_WIDTH
- #endif
- #if (KERNEL==1)
- #define KERNEL_X(x) ((abs(x)<0.5)?(0.75-(abs(x)*abs(x))):((abs(x)<1.5)?(0.5*(1.5-abs(x))*(1.5-abs(x))):0.0))
- #define KERNEL_Y(x) KERNEL_X(x)
- #define MIN_X -1.0
- #define MAX_X 3.0
- #define MIN_Y -1.0
- #define MAX_Y 3.0
- #elif (KERNEL==2)
- #define KERNEL_X(x) (min(max((1.0-abs(x)),0.0),1.0))
- #define KERNEL_Y(x) KERNEL_X(x)
- #define MIN_X -1.0
- #define MAX_X 2.0
- #define MIN_Y -1.0
- #define MAX_Y 2.0
- #else
- #define KERNEL_X(x) ((sqrt(2.0)/KERNEL_WIDTH)*(exp(-2.0*pi*(x)*(x)/(KERNEL_WIDTH*KERNEL_WIDTH))))
- #define KERNEL_Y(y) ((sqrt(2.0)/KERNEL_HEIGHT)*(exp(-2.0*pi*(y)*(y)/(KERNEL_HEIGHT*KERNEL_HEIGHT))))
- #define MIN_X max((floor(-KERNEL_WIDTH)+1.0),-3.0)
- #define MAX_X min((ceil(KERNEL_WIDTH)+1.0),5.0)
- #define MIN_Y max((floor(-KERNEL_HEIGHT)+1.0),-3.0)
- #define MAX_Y min((ceil(KERNEL_HEIGHT)+1.0),5.0)
- #endif
- #define STUDIOSWING(c) min(max((c - ( 16.0 / 255.0 ) )* ( 255.0 / 219.0 ), 0.0),1.0)
- #define DECODE_GAMMA(c0) pow(c0,GAMMA_IN)
- #define ENCODE_GAMMA(c0) pow(c0,(1.0/GAMMA_OUT))
- void main() {
- vec2 oneT = 1.0 / rubyTextureSize ;
- vec2 offset =(gl_TexCoord[0].xy *rubyTextureSize );
- #ifdef HIGAN_ACCURACY
- offset.x /= 2.0;
- oneT.x*=2.0;
- #endif
- offset -= vec2(0.5,0.5);
- offset-=floor(offset);
- vec3 tempColor = vec3(0.0, 0.0, 0.0);
- float X,Y,fX,Xcoord;
- for (float i = MIN_X; i < MAX_X; i++) {
- X = (offset.x - i);
- fX = KERNEL_X(X);
- Xcoord = X * oneT.x;
- for (float j = MIN_Y; j < MAX_Y; j++) {
- Y = (offset.y - j);
- vec2 sourceCoord = gl_TexCoord[0].xy - vec2(Xcoord,Y * oneT.y);
- vec3 c=texture2D(rubyTexture, sourceCoord).xyz;
- c.x=DECODE_GAMMA(STUDIOSWING(c.x));
- c.y=DECODE_GAMMA(STUDIOSWING(c.y));
- c.z=DECODE_GAMMA(STUDIOSWING(c.z));
- tempColor += c* fX * KERNEL_Y(Y);
- }
- }
- tempColor.x=ENCODE_GAMMA(tempColor.x);
- tempColor.y=ENCODE_GAMMA(tempColor.y);
- tempColor.z=ENCODE_GAMMA(tempColor.z);
- gl_FragColor=vec4(tempColor,1.0);}
- ]]></fragment>
- <vertex><![CDATA[
- attribute vec2 rubyOrigTexCoord;
- varying vec2 orig_tex;
- void main()
- {
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- orig_tex = rubyOrigTexCoord;
- gl_TexCoord[1].xy = gl_MultiTexCoord1.xy;
- }
- ]]></vertex>
- <fragment filter="linear" outscale="2.0"><![CDATA[
- uniform sampler2D rubyOrigTexture;
- uniform sampler2D phosphorLUT;
- varying vec2 orig_tex;
- uniform float brightness;
- void main()
- {
- float brightness = 1.2;
- vec4 frame = texture2D(rubyOrigTexture, orig_tex);
- vec4 inverse = 1 - (brightness * texture2D(rubyOrigTexture, orig_tex));
- vec4 screen = texture2D(phosphorLUT, gl_TexCoord[1].xy);
- gl_FragColor = screen - inverse;
- }
- ]]></fragment>
- <vertex><![CDATA[
- attribute vec2 rubyPass1TexCoord;
- attribute vec2 rubyPass2TexCoord;
- varying vec2 pass1_tex;
- varying vec2 pass2_tex;
- void main() {
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- gl_TexCoord[0] = gl_MultiTexCoord0;
- pass1_tex = rubyPass1TexCoord;
- pass2_tex = rubyPass2TexCoord;
- }
- ]]></vertex>
- <fragment filter="linear"><![CDATA[
- uniform sampler2D rubyPass1Texture; // Result from Pass 1.
- uniform sampler2D rubyPass2Texture; // Result from Pass 2.
- uniform sampler2D rubyTexture; // Result from Pass 3 (previous pass).
- varying vec2 pass1_tex;
- varying vec2 pass2_tex;
- //#define LOWRES
- void main() {
- vec4 pass1 = texture2D(rubyPass1Texture, pass1_tex);
- vec4 pass2 = texture2D(rubyPass2Texture, pass2_tex);
- vec4 pass3 = texture2D(rubyTexture, gl_TexCoord[0].xy);
- #ifdef LOWRES
- gl_FragColor = 1.0 - (1.0 - pass1) * (1.0 - pass2) * (1.0 - pass3) * (1.0- pass2);
- #else
- gl_FragColor = 1.0 - (1.0 - pass1) * (1.0 - pass2) * (1.0 - pass3);
- #endif
- }
- ]]></fragment>
- </shader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement