no message
This commit is contained in:
parent
ef41d6ec40
commit
840d67f48d
|
@ -1,16 +1,14 @@
|
||||||
CODE(
|
CODE(
|
||||||
|
|
||||||
precision highp float;
|
precision highp float;
|
||||||
precision mediump int;
|
|
||||||
|
|
||||||
uniform sampler2D tex;
|
varying vec2 texCoord;
|
||||||
|
uniform sampler2D source;
|
||||||
uniform float trg_w;
|
uniform float trg_w;
|
||||||
uniform float trg_h;
|
uniform float trg_h;
|
||||||
|
|
||||||
|
|
||||||
// Emulated input resolution.
|
// Emulated input resolution.
|
||||||
vec2 res=vec2(256.0,144.0);
|
vec2 res=vec2(256.0,144.0);
|
||||||
|
|
||||||
vec2 trg=vec2(trg_w, trg_h);
|
vec2 trg=vec2(trg_w, trg_h);
|
||||||
|
|
||||||
// Hardness of scanline.
|
// Hardness of scanline.
|
||||||
|
@ -47,8 +45,8 @@ vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
|
||||||
// Nearest emulated sample given floating point position and texel offset.
|
// Nearest emulated sample given floating point position and texel offset.
|
||||||
// Also zero's off screen.
|
// Also zero's off screen.
|
||||||
vec3 Fetch(vec2 pos,vec2 off){
|
vec3 Fetch(vec2 pos,vec2 off){
|
||||||
pos=(floor(pos*res+off)+vec2(0.5,0.5))/res;
|
pos=(floor(pos*res+off)+vec2(0.5,0.5))/res;
|
||||||
return ToLinear(1.2 * texture2D(tex,pos.xy,-16.0).rgb);}
|
return ToLinear(1.2 * texture2D(source,pos.xy,-16.0).rgb);}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));}
|
||||||
|
@ -58,73 +56,72 @@ float Gaus(float pos,float scale){return exp2(scale*pos*pos);}
|
||||||
|
|
||||||
// 3-tap Gaussian filter along horz line.
|
// 3-tap Gaussian filter along horz line.
|
||||||
vec3 Horz3(vec2 pos,float off){
|
vec3 Horz3(vec2 pos,float off){
|
||||||
vec3 b=Fetch(pos,vec2(-1.0,off));
|
vec3 b=Fetch(pos,vec2(-1.0,off));
|
||||||
vec3 c=Fetch(pos,vec2( 0.0,off));
|
vec3 c=Fetch(pos,vec2( 0.0,off));
|
||||||
vec3 d=Fetch(pos,vec2( 1.0,off));
|
vec3 d=Fetch(pos,vec2( 1.0,off));
|
||||||
float dst=Dist(pos).x;
|
float dst=Dist(pos).x;
|
||||||
// Convert distance to weight.
|
// Convert distance to weight.
|
||||||
float scale=hardPix;
|
float scale=hardPix;
|
||||||
float wb=Gaus(dst-1.0,scale);
|
float wb=Gaus(dst-1.0,scale);
|
||||||
float wc=Gaus(dst+0.0,scale);
|
float wc=Gaus(dst+0.0,scale);
|
||||||
float wd=Gaus(dst+1.0,scale);
|
float wd=Gaus(dst+1.0,scale);
|
||||||
// Return filtered sample.
|
// Return filtered sample.
|
||||||
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
|
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
|
||||||
|
|
||||||
// 5-tap Gaussian filter along horz line.
|
// 5-tap Gaussian filter along horz line.
|
||||||
vec3 Horz5(vec2 pos,float off){
|
vec3 Horz5(vec2 pos,float off){
|
||||||
vec3 a=Fetch(pos,vec2(-2.0,off));
|
vec3 a=Fetch(pos,vec2(-2.0,off));
|
||||||
vec3 b=Fetch(pos,vec2(-1.0,off));
|
vec3 b=Fetch(pos,vec2(-1.0,off));
|
||||||
vec3 c=Fetch(pos,vec2( 0.0,off));
|
vec3 c=Fetch(pos,vec2( 0.0,off));
|
||||||
vec3 d=Fetch(pos,vec2( 1.0,off));
|
vec3 d=Fetch(pos,vec2( 1.0,off));
|
||||||
vec3 e=Fetch(pos,vec2( 2.0,off));
|
vec3 e=Fetch(pos,vec2( 2.0,off));
|
||||||
float dst=Dist(pos).x;
|
float dst=Dist(pos).x;
|
||||||
// Convert distance to weight.
|
// Convert distance to weight.
|
||||||
float scale=hardPix;
|
float scale=hardPix;
|
||||||
float wa=Gaus(dst-2.0,scale);
|
float wa=Gaus(dst-2.0,scale);
|
||||||
float wb=Gaus(dst-1.0,scale);
|
float wb=Gaus(dst-1.0,scale);
|
||||||
float wc=Gaus(dst+0.0,scale);
|
float wc=Gaus(dst+0.0,scale);
|
||||||
float wd=Gaus(dst+1.0,scale);
|
float wd=Gaus(dst+1.0,scale);
|
||||||
float we=Gaus(dst+2.0,scale);
|
float we=Gaus(dst+2.0,scale);
|
||||||
// Return filtered sample.
|
// Return filtered sample.
|
||||||
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
|
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
|
||||||
|
|
||||||
// Return scanline weight.
|
// Return scanline weight.
|
||||||
float Scan(vec2 pos,float off){
|
float Scan(vec2 pos,float off){
|
||||||
float dst=Dist(pos).y;
|
float dst=Dist(pos).y;
|
||||||
return Gaus(dst+off,hardScan);}
|
return Gaus(dst+off,hardScan);}
|
||||||
|
|
||||||
// Allow nearest three lines to effect pixel.
|
// Allow nearest three lines to effect pixel.
|
||||||
vec3 Tri(vec2 pos){
|
vec3 Tri(vec2 pos){
|
||||||
vec3 a=Horz3(pos,-1.0);
|
vec3 a=Horz3(pos,-1.0);
|
||||||
vec3 b=Horz5(pos, 0.0);
|
vec3 b=Horz5(pos, 0.0);
|
||||||
vec3 c=Horz3(pos, 1.0);
|
vec3 c=Horz3(pos, 1.0);
|
||||||
float wa=Scan(pos,-1.0);
|
float wa=Scan(pos,-1.0);
|
||||||
float wb=Scan(pos, 0.0);
|
float wb=Scan(pos, 0.0);
|
||||||
float wc=Scan(pos, 1.0);
|
float wc=Scan(pos, 1.0);
|
||||||
return a*wa+b*wb+c*wc;}
|
return a*wa+b*wb+c*wc;}
|
||||||
|
|
||||||
// Distortion of scanlines, and end of screen alpha.
|
// Distortion of scanlines, and end of screen alpha.
|
||||||
vec2 Warp(vec2 pos){
|
vec2 Warp(vec2 pos){
|
||||||
pos=pos*2.0-1.0;
|
pos=pos*2.0-1.0;
|
||||||
pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);
|
pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);
|
||||||
return pos*0.5+0.5;}
|
return pos*0.5+0.5;}
|
||||||
|
|
||||||
// Shadow mask.
|
// Shadow mask.
|
||||||
vec3 Mask(vec2 pos){
|
vec3 Mask(vec2 pos){
|
||||||
pos.x+=pos.y*3.0;
|
pos.x+=pos.y*3.0;
|
||||||
vec3 mask=vec3(maskDark,maskDark,maskDark);
|
vec3 mask=vec3(maskDark,maskDark,maskDark);
|
||||||
pos.x=fract(pos.x/6.0);
|
pos.x=fract(pos.x/6.0);
|
||||||
if(pos.x<0.333)mask.r=maskLight;
|
if(pos.x<0.333)mask.r=maskLight;
|
||||||
else if(pos.x<0.666)mask.g=maskLight;
|
else if(pos.x<0.666)mask.g=maskLight;
|
||||||
else mask.b=maskLight;
|
else mask.b=maskLight;
|
||||||
return mask;}
|
return mask;}
|
||||||
|
|
||||||
void main()
|
void main() {
|
||||||
{
|
vec2 pos = gl_FragCoord.xy/trg.xy;
|
||||||
vec2 pos = gl_FragCoord.xy/trg.xy;
|
hardScan=-12.0;
|
||||||
hardScan=-12.0;
|
// maskDark=maskLight;
|
||||||
// maskDark=maskLight;
|
pos=Warp(gl_FragCoord.xy/trg.xy);
|
||||||
pos=Warp(gl_FragCoord.xy/trg.xy);
|
gl_FragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy);
|
||||||
gl_FragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy);
|
gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0);
|
||||||
gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0);
|
|
||||||
})
|
})
|
Loading…
Reference in New Issue