Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <shader language="GLSL">
- <fragment filter="nearest" outscale_x="1.0" outscale_y="1.0"><![CDATA[#version 130
- uniform sampler2D rubyTexture;
- uniform vec2 rubyTextureSize;
- uniform vec2 rubyInputSize;
- uniform vec2 rubyOutputSize;
- #define CRT_gamma 2.2
- #define display_gamma 2.2
- #define TEX2D(c) texture2D(rubyTexture,(c))
- #define risetime 1.1
- #define falltime 0.3
- #define distortion 0.1
- #define offpeakiness 0.1
- vec2 radialDistortion(vec2 coord) {
- coord *= rubyTextureSize / rubyInputSize;
- vec2 cc = coord - 0.5;
- float dist = dot(cc, cc) * distortion;
- return (coord + cc * (1.0 + dist) * dist) * rubyInputSize / rubyTextureSize;
- }
- void main()
- {
- vec2 xy = radialDistortion(gl_TexCoord[0].st - vec2(0.0, 0.5/rubyTextureSize.y));
- float emu_pos = xy.y * rubyTextureSize.y;
- float screen_pos = emu_pos * rubyOutputSize.y / rubyInputSize.y;
- float line_y = floor(emu_pos) * rubyOutputSize.y / rubyInputSize.y;
- float line_y2 = ceil(emu_pos) * rubyOutputSize.y / rubyInputSize.y;
- float x1 = screen_pos-line_y;
- float x2 = line_y2-screen_pos;
- vec2 uv_ratio = fract(xy*rubyTextureSize-vec2(0.5));
- vec2 one = 1.0/rubyTextureSize;
- xy = (floor(xy * rubyTextureSize - vec2(0.5)) + vec2(0.5)) / rubyTextureSize;
- float wrise = risetime*rubyInputSize.x/256.0;
- float wfall = falltime*rubyInputSize.x/256.0;
- vec2 onex = vec2(one.x, 0.0);
- vec4 ct0= TEX2D(xy);
- vec4 ct1= TEX2D(xy-onex);
- vec4 ct2= TEX2D(xy-2*onex);
- vec4 ct3= TEX2D(xy-3*onex);
- vec4 ct4= TEX2D(xy-4*onex);
- vec4 col = ct4;
- bvec4 rising = greaterThan(ct3, ct4);
- col += (ct3 - col) * (1.0-exp(-vec4(1.0)/mix(vec4(wfall),vec4(wrise),rising)));
- rising = greaterThan(ct2, ct3);
- col += (ct2 - col) * (1.0-exp(-vec4(1.0)/mix(vec4(wfall),vec4(wrise),rising)));
- rising = greaterThan(ct1, ct2);
- col += (ct1 - col) * (1.0-exp(-vec4(1.0)/mix(vec4(wfall),vec4(wrise),rising)));
- rising = greaterThan(ct0, ct1);
- col += (ct0 - col) * (1.0-exp(-vec4(uv_ratio.x)/mix(vec4(wfall),vec4(wrise),rising)));
- col = pow(col, vec4(CRT_gamma));
- if (x1 < 1.0)
- gl_FragColor = pow(col*vec4(offpeakiness/2+(1-offpeakiness)*(1-x1)),vec4(1/display_gamma));
- else if(x2 < 1.0)
- gl_FragColor = pow(col*vec4(offpeakiness/2+(1-offpeakiness)*(1-x2)),vec4(1/display_gamma));
- else
- gl_FragColor = vec4(0.0);
- }
- ]]></fragment>
- <fragment filter="nearest" outscale_x="1.0" outscale_y="1.0"><![CDATA[
- uniform sampler2D rubyTexture;
- uniform vec2 rubyTextureSize;
- uniform vec2 rubyInputSize;
- uniform vec2 rubyOutputSize;
- #define width 0.3
- #define display_gamma 2.2
- #define TEX2D(c) pow(texture2D(rubyTexture,(c)),vec4(display_gamma))
- void main()
- {
- vec2 xy = gl_TexCoord[0].st;
- float oney = 1.0/rubyTextureSize.y;
- // float wid = width*rubyOutputSize.y/rubyInputSize.y;
- float wid = width*4.0;
- float c1 = exp(-1.0/wid/wid);
- float c2 = exp(-4.0/wid/wid);
- float c3 = exp(-9.0/wid/wid);
- float c4 = exp(-16.0/wid/wid);
- //float norm = 1.0 / (1.0 + 2.0*(c1+c2+c3+c4));
- float norm = 0.9;
- vec4 sum = vec4(0.0);
- sum += TEX2D(xy + vec2(0.0, -4.0 * oney)) * vec4(c4);
- sum += TEX2D(xy + vec2(0.0, -3.0 * oney)) * vec4(c3);
- sum += TEX2D(xy + vec2(0.0, -2.0 * oney)) * vec4(c2);
- sum += TEX2D(xy + vec2(0.0, -1.0 * oney)) * vec4(c1);
- sum += TEX2D(xy);
- sum += TEX2D(xy + vec2(0.0, +1.0 * oney)) * vec4(c1);
- sum += TEX2D(xy + vec2(0.0, +2.0 * oney)) * vec4(c2);
- sum += TEX2D(xy + vec2(0.0, +3.0 * oney)) * vec4(c3);
- sum += TEX2D(xy + vec2(0.0, +4.0 * oney)) * vec4(c4);
- gl_FragColor = pow(sum*vec4(norm),vec4(1.0/display_gamma));
- }
- ]]></fragment>
- <fragment filter="nearest" outscale_x="1.0" outscale_y="1.0"><![CDATA[
- uniform sampler2D rubyTexture;
- uniform vec2 rubyTextureSize;
- uniform vec2 rubyInputSize;
- uniform vec2 rubyOutputSize;
- #define width 0.3
- #define display_gamma 2.2
- #define TEX2D(c) pow(texture2D(rubyTexture,(c)),vec4(display_gamma))
- void main()
- {
- vec2 xy = gl_TexCoord[0].st;
- float onex = 1.0/rubyTextureSize.x;
- // float wid = width*rubyOutputSize.y/rubyInputSize.y;
- float wid = width*4.0;
- float c1 = exp(-1.0/wid/wid);
- float c2 = exp(-4.0/wid/wid);
- float c3 = exp(-9.0/wid/wid);
- float c4 = exp(-16.0/wid/wid);
- float norm = 1.0 / (1.0 + 2.0*(c1+c2+c3+c4));
- vec4 sum = vec4(0.0);
- sum += TEX2D(xy + vec2(-4.0 * onex, 0.0)) * vec4(c4);
- sum += TEX2D(xy + vec2(-3.0 * onex, 0.0)) * vec4(c3);
- sum += TEX2D(xy + vec2(-2.0 * onex, 0.0)) * vec4(c2);
- sum += TEX2D(xy + vec2(-1.0 * onex, 0.0)) * vec4(c1);
- sum += TEX2D(xy);
- sum += TEX2D(xy + vec2(+1.0 * onex, 0.0)) * vec4(c1);
- sum += TEX2D(xy + vec2(+2.0 * onex, 0.0)) * vec4(c2);
- sum += TEX2D(xy + vec2(+3.0 * onex, 0.0)) * vec4(c3);
- sum += TEX2D(xy + vec2(+4.0 * onex, 0.0)) * vec4(c4);
- gl_FragColor = pow(sum*vec4(norm),vec4(1.0/display_gamma));
- }
- ]]></fragment>
- </shader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement