mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 15:51:30 +11:00
Merge pull request #21 from rz5/master
(crt-lottes-multipass) Style nits
This commit is contained in:
commit
97f02f97f2
|
@ -2,25 +2,25 @@
|
||||||
|
|
||||||
// -- config -- //
|
// -- config -- //
|
||||||
|
|
||||||
#define hardScan -8.0
|
#define hardScan -8.0
|
||||||
#define warpX 0.031
|
#define warpX 0.031
|
||||||
#define warpY 0.041
|
#define warpY 0.041
|
||||||
#define maskDark 0.5
|
#define maskDark 0.5
|
||||||
#define maskLight 1.5
|
#define maskLight 1.5
|
||||||
#define shadowMask 1
|
#define shadowMask 1
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define bloomAmount 1.0/16.0
|
#define bloomAmount 1.0/16.0
|
||||||
#define hardBloomScan -2.0
|
#define hardBloomScan -2.0
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
|
|
||||||
#define DO_BLOOM
|
#define DO_BLOOM
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 SourceSize;
|
vec4 SourceSize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -30,8 +30,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER
|
// PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER
|
||||||
|
@ -64,126 +64,162 @@ layout(set = 0, binding = 9) uniform sampler2D horz7plus1;
|
||||||
// Assuming using sRGB typed textures this should not be needed.
|
// Assuming using sRGB typed textures this should not be needed.
|
||||||
float ToSrgb1(float c)
|
float ToSrgb1(float c)
|
||||||
{
|
{
|
||||||
return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);
|
return(c < 0.0031308 ? c*12.92 : 1.055*pow(c, 0.41666) - 0.055);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 ToSrgb(vec3 c)
|
vec3 ToSrgb(vec3 c)
|
||||||
{
|
{
|
||||||
return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));
|
return vec3(ToSrgb1(c.r), ToSrgb1(c.g), ToSrgb1(c.b));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.SourceSize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.SourceSize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// Return scanline weight.
|
// Return scanline weight.
|
||||||
float Scan(vec2 pos,float off){
|
float Scan(vec2 pos, float off)
|
||||||
float dst=Dist(pos).y;
|
{
|
||||||
return Gaus(dst+off,hardScan);}
|
float dst = Dist(pos).y;
|
||||||
|
|
||||||
|
return Gaus(dst + off, hardScan);
|
||||||
|
}
|
||||||
|
|
||||||
// Return scanline weight for bloom.
|
// Return scanline weight for bloom.
|
||||||
float BloomScan(vec2 pos,float off){
|
float BloomScan(vec2 pos, float off)
|
||||||
float dst=Dist(pos).y;
|
{
|
||||||
return Gaus(dst+off,hardBloomScan);}
|
float dst = Dist(pos).y;
|
||||||
|
|
||||||
|
return Gaus(dst + off, hardBloomScan);
|
||||||
|
}
|
||||||
|
|
||||||
// Allow nearest three lines to effect pixel.
|
// Allow nearest three lines to effect pixel.
|
||||||
vec3 Tri(vec2 pos){
|
vec3 Tri(vec2 pos)
|
||||||
vec3 a=texture(horz3minus1, pos).rgb;//Horz3(pos,-1.0);
|
{
|
||||||
vec3 b=texture(horz5, pos).rgb;//Horz5(pos, 0.0);
|
vec3 a = texture(horz3minus1, pos).rgb;//Horz3(pos,-1.0);
|
||||||
vec3 c=texture(horz3plus1, pos).rgb;//Horz3(pos, 1.0);
|
vec3 b = texture(horz5, pos).rgb;//Horz5(pos, 0.0);
|
||||||
float wa=Scan(pos,-1.0);
|
vec3 c = texture(horz3plus1, pos).rgb;//Horz3(pos, 1.0);
|
||||||
float wb=Scan(pos, 0.0);
|
|
||||||
float wc=Scan(pos, 1.0);
|
float wa = Scan(pos, -1.0);
|
||||||
return a*wa+b*wb+c*wc;}
|
float wb = Scan(pos, 0.0);
|
||||||
|
float wc = Scan(pos, 1.0);
|
||||||
|
|
||||||
|
return a*wa+b*wb+c*wc;
|
||||||
|
}
|
||||||
|
|
||||||
// Small bloom.
|
// Small bloom.
|
||||||
vec3 Bloom(vec2 pos){
|
vec3 Bloom(vec2 pos)
|
||||||
vec3 a=texture(horz5minus2, pos).rgb;//Horz5(pos,-2.0);
|
{
|
||||||
vec3 b=texture(horz7minus1, pos).rgb;//Horz7(pos,-1.0);
|
vec3 a = texture(horz5minus2, pos).rgb;//Horz5(pos,-2.0);
|
||||||
vec3 c=texture(horz7, pos).rgb;//Horz7(pos, 0.0);
|
vec3 b = texture(horz7minus1, pos).rgb;//Horz7(pos,-1.0);
|
||||||
vec3 d=texture(horz7plus1, pos).rgb;//Horz7(pos, 1.0);
|
vec3 c = texture(horz7, pos).rgb;//Horz7(pos, 0.0);
|
||||||
vec3 e=texture(horz5plus2, pos).rgb;//Horz5(pos, 2.0);
|
vec3 d = texture(horz7plus1, pos).rgb;//Horz7(pos, 1.0);
|
||||||
float wa=BloomScan(pos,-2.0);
|
vec3 e = texture(horz5plus2, pos).rgb;//Horz5(pos, 2.0);
|
||||||
float wb=BloomScan(pos,-1.0);
|
|
||||||
float wc=BloomScan(pos, 0.0);
|
float wa = BloomScan(pos, -2.0);
|
||||||
float wd=BloomScan(pos, 1.0);
|
float wb = BloomScan(pos, -1.0);
|
||||||
float we=BloomScan(pos, 2.0);
|
float wc = BloomScan(pos, 0.0);
|
||||||
return a*wa+b*wb+c*wc+d*wd+e*we;}
|
float wd = BloomScan(pos, 1.0);
|
||||||
|
float we = BloomScan(pos, 2.0);
|
||||||
|
|
||||||
|
return a*wa+b*wb+c*wc+d*wd+e*we;
|
||||||
|
}
|
||||||
|
|
||||||
// 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*=vec2(1.0+(pos.y*pos.y)*warpX,1.0+(pos.x*pos.x)*warpY);
|
pos = pos*2.0-1.0;
|
||||||
return pos*0.5+0.5;}
|
pos *= vec2(1.0 + (pos.y*pos.y)*warpX, 1.0 + (pos.x*pos.x)*warpY);
|
||||||
|
|
||||||
|
return pos*0.5 + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
// Shadow mask.
|
// Shadow mask.
|
||||||
vec3 Mask(vec2 pos){
|
vec3 Mask(vec2 pos)
|
||||||
vec3 mask=vec3(maskDark,maskDark,maskDark);
|
{
|
||||||
|
vec3 mask = vec3(maskDark, maskDark, maskDark);
|
||||||
|
|
||||||
// Very compressed TV style shadow mask.
|
// Very compressed TV style shadow mask.
|
||||||
if (shadowMask == 1.0) {
|
if (shadowMask == 1.0)
|
||||||
float line=maskLight;
|
{
|
||||||
float odd=0.0;
|
float line = maskLight;
|
||||||
if(fract(pos.x/6.0)<0.5)odd=1.0;
|
float odd = 0.0;
|
||||||
if(fract((pos.y+odd)/2.0)<0.5)line=maskDark;
|
|
||||||
pos.x=fract(pos.x/3.0);
|
if (fract(pos.x*0.166666666) < 0.5) odd = 1.0;
|
||||||
|
if (fract((pos.y + odd) * 0.5) < 0.5) line = maskDark;
|
||||||
if(pos.x<0.333)mask.r=maskLight;
|
|
||||||
else if(pos.x<0.666)mask.g=maskLight;
|
pos.x = fract(pos.x*0.333333333);
|
||||||
else mask.b=maskLight;
|
|
||||||
mask*=line;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aperture-grille.
|
if (pos.x < 0.333) mask.r = maskLight;
|
||||||
else if (shadowMask == 2.0) {
|
else if (pos.x < 0.666) mask.g = maskLight;
|
||||||
pos.x=fract(pos.x/3.0);
|
else mask.b = maskLight;
|
||||||
|
mask*=line;
|
||||||
|
}
|
||||||
|
|
||||||
if(pos.x<0.333)mask.r=maskLight;
|
// Aperture-grille.
|
||||||
else if(pos.x<0.666)mask.g=maskLight;
|
else if (shadowMask == 2.0)
|
||||||
else mask.b=maskLight;
|
{
|
||||||
}
|
pos.x = fract(pos.x*0.333333333);
|
||||||
|
|
||||||
// Stretched VGA style shadow mask (same as prior shaders).
|
if (pos.x < 0.333) mask.r = maskLight;
|
||||||
else if (shadowMask == 3.0) {
|
else if (pos.x < 0.666) mask.g = maskLight;
|
||||||
pos.x+=pos.y*3.0;
|
else mask.b = maskLight;
|
||||||
pos.x=fract(pos.x/6.0);
|
}
|
||||||
|
|
||||||
if(pos.x<0.333)mask.r=maskLight;
|
// Stretched VGA style shadow mask (same as prior shaders).
|
||||||
else if(pos.x<0.666)mask.g=maskLight;
|
else if (shadowMask == 3.0)
|
||||||
else mask.b=maskLight;
|
{
|
||||||
}
|
pos.x += pos.y*3.0;
|
||||||
|
pos.x = fract(pos.x*0.166666666);
|
||||||
|
|
||||||
// VGA style shadow mask.
|
if (pos.x < 0.333) mask.r = maskLight;
|
||||||
else if (shadowMask == 4.0) {
|
else if (pos.x < 0.666) mask.g = maskLight;
|
||||||
pos.xy=floor(pos.xy*vec2(1.0,0.5));
|
else mask.b = maskLight;
|
||||||
pos.x+=pos.y*3.0;
|
}
|
||||||
pos.x=fract(pos.x/6.0);
|
|
||||||
|
|
||||||
if(pos.x<0.333)mask.r=maskLight;
|
// VGA style shadow mask.
|
||||||
else if(pos.x<0.666)mask.g=maskLight;
|
else if (shadowMask == 4.0)
|
||||||
else mask.b=maskLight;
|
{
|
||||||
}
|
pos.xy = floor(pos.xy*vec2(1.0, 0.5));
|
||||||
|
pos.x += pos.y*3.0;
|
||||||
|
pos.x = fract(pos.x*0.166666666);
|
||||||
|
|
||||||
return mask;}
|
if (pos.x < 0.333) mask.r = maskLight;
|
||||||
|
else if (pos.x < 0.666) mask.g = maskLight;
|
||||||
|
else mask.b = maskLight;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 pos=Warp(vTexCoord);
|
vec2 pos = Warp(vTexCoord);
|
||||||
vec3 outColor = Tri(pos);
|
vec3 outColor = Tri(pos);
|
||||||
#ifdef DO_BLOOM
|
|
||||||
//Add Bloom
|
|
||||||
outColor.rgb+=Bloom(pos)*bloomAmount;
|
|
||||||
#endif
|
|
||||||
if(shadowMask > 0.0)
|
|
||||||
outColor.rgb*=Mask(vTexCoord.xy / global.OutputSize.zw * 1.000001);
|
|
||||||
//hacky clamp fix
|
|
||||||
vec2 bordertest = (pos);
|
|
||||||
if ( bordertest.x > 0.0001 && bordertest.x < 0.9999 && bordertest.y > 0.0001 && bordertest.y < 0.9999)
|
|
||||||
outColor.rgb = outColor.rgb;
|
|
||||||
else
|
|
||||||
outColor.rgb = vec3(0.0);
|
|
||||||
|
|
||||||
FragColor = vec4(ToSrgb(outColor.rgb), 1.0);
|
#ifdef DO_BLOOM
|
||||||
}
|
//Add Bloom
|
||||||
|
outColor.rgb += Bloom(pos)*bloomAmount;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (shadowMask > 0.0)
|
||||||
|
outColor.rgb *= Mask(vTexCoord.xy / global.OutputSize.zw * 1.000001);
|
||||||
|
|
||||||
|
/* TODO/FIXME - hacky clamp fix */
|
||||||
|
vec2 bordertest = (pos);
|
||||||
|
if ( bordertest.x > 0.0001 && bordertest.x < 0.9999 && bordertest.y > 0.0001 && bordertest.y < 0.9999)
|
||||||
|
outColor.rgb = outColor.rgb;
|
||||||
|
else
|
||||||
|
outColor.rgb = vec3(0.0);
|
||||||
|
|
||||||
|
FragColor = vec4(ToSrgb(outColor.rgb), 1.0);
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define hardPix -3.0
|
#define hardPix -3.0
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,32 +32,46 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 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 c=Fetch(pos,vec2( 0.0,off));
|
vec3 b = Fetch(pos,vec2(-1.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 1.0,off));
|
vec3 c = Fetch(pos,vec2( 0.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 d = Fetch(pos,vec2( 1.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardPix;
|
|
||||||
float wb=Gaus(dst-1.0,scale);
|
// Convert distance to weight.
|
||||||
float wc=Gaus(dst+0.0,scale);
|
float scale = hardPix;
|
||||||
float wd=Gaus(dst+1.0,scale);
|
float wb = Gaus(dst - 1.0, scale);
|
||||||
// Return filtered sample.
|
float wc = Gaus(dst + 0.0, scale);
|
||||||
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
|
float wd = Gaus(dst + 1.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (b*wb+c*wc+d*wd) / (wb+wc+wd);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz3(vTexCoord, -1.0).rgb, 1.0);
|
FragColor = vec4(Horz3(vTexCoord, -1.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define hardPix -3.0
|
#define hardPix -3.0
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,32 +32,46 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 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 c=Fetch(pos,vec2( 0.0,off));
|
vec3 b = Fetch(pos,vec2(-1.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 1.0,off));
|
vec3 c = Fetch(pos,vec2( 0.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 d = Fetch(pos,vec2( 1.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardPix;
|
|
||||||
float wb=Gaus(dst-1.0,scale);
|
// Convert distance to weight.
|
||||||
float wc=Gaus(dst+0.0,scale);
|
float scale = hardPix;
|
||||||
float wd=Gaus(dst+1.0,scale);
|
float wb = Gaus(dst - 1.0, scale);
|
||||||
// Return filtered sample.
|
float wc = Gaus(dst + 0.0, scale);
|
||||||
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
|
float wd = Gaus(dst + 1.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (b*wb+c*wc+d*wd) / (wb+wc+wd);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz3(vTexCoord, 1.0).rgb, 1.0);
|
FragColor = vec4(Horz3(vTexCoord, 1.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define hardPix -3.0
|
#define hardPix -3.0
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,36 +32,50 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 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 b=Fetch(pos,vec2(-1.0,off));
|
vec3 a = Fetch(pos,vec2(-2.0, off));
|
||||||
vec3 c=Fetch(pos,vec2( 0.0,off));
|
vec3 b = Fetch(pos,vec2(-1.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 1.0,off));
|
vec3 c = Fetch(pos,vec2( 0.0, off));
|
||||||
vec3 e=Fetch(pos,vec2( 2.0,off));
|
vec3 d = Fetch(pos,vec2( 1.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 e = Fetch(pos,vec2( 2.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardPix;
|
|
||||||
float wa=Gaus(dst-2.0,scale);
|
// Convert distance to weight.
|
||||||
float wb=Gaus(dst-1.0,scale);
|
float scale = hardPix;
|
||||||
float wc=Gaus(dst+0.0,scale);
|
float wa = Gaus(dst - 2.0, scale);
|
||||||
float wd=Gaus(dst+1.0,scale);
|
float wb = Gaus(dst - 1.0, scale);
|
||||||
float we=Gaus(dst+2.0,scale);
|
float wc = Gaus(dst + 0.0, scale);
|
||||||
// Return filtered sample.
|
float wd = Gaus(dst + 1.0, scale);
|
||||||
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
|
float we = Gaus(dst + 2.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz5(vTexCoord, 0.0).rgb, 1.0);
|
FragColor = vec4(Horz5(vTexCoord, 0.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define hardPix -3.0
|
#define hardPix -3.0
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,36 +32,50 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 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 b=Fetch(pos,vec2(-1.0,off));
|
vec3 a = Fetch(pos,vec2(-2.0, off));
|
||||||
vec3 c=Fetch(pos,vec2( 0.0,off));
|
vec3 b = Fetch(pos,vec2(-1.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 1.0,off));
|
vec3 c = Fetch(pos,vec2( 0.0, off));
|
||||||
vec3 e=Fetch(pos,vec2( 2.0,off));
|
vec3 d = Fetch(pos,vec2( 1.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 e = Fetch(pos,vec2( 2.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardPix;
|
|
||||||
float wa=Gaus(dst-2.0,scale);
|
// Convert distance to weight.
|
||||||
float wb=Gaus(dst-1.0,scale);
|
float scale = hardPix;
|
||||||
float wc=Gaus(dst+0.0,scale);
|
float wa = Gaus(dst - 2.0, scale);
|
||||||
float wd=Gaus(dst+1.0,scale);
|
float wb = Gaus(dst - 1.0, scale);
|
||||||
float we=Gaus(dst+2.0,scale);
|
float wc = Gaus(dst + 0.0, scale);
|
||||||
// Return filtered sample.
|
float wd = Gaus(dst + 1.0, scale);
|
||||||
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
|
float we = Gaus(dst + 2.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz5(vTexCoord, -2.0).rgb, 1.0);
|
FragColor = vec4(Horz5(vTexCoord, -2.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define hardPix -3.0
|
#define hardPix -3.0
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,36 +32,50 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 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 b=Fetch(pos,vec2(-1.0,off));
|
vec3 a = Fetch(pos,vec2(-2.0, off));
|
||||||
vec3 c=Fetch(pos,vec2( 0.0,off));
|
vec3 b = Fetch(pos,vec2(-1.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 1.0,off));
|
vec3 c = Fetch(pos,vec2( 0.0, off));
|
||||||
vec3 e=Fetch(pos,vec2( 2.0,off));
|
vec3 d = Fetch(pos,vec2( 1.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 e = Fetch(pos,vec2( 2.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardPix;
|
|
||||||
float wa=Gaus(dst-2.0,scale);
|
// Convert distance to weight.
|
||||||
float wb=Gaus(dst-1.0,scale);
|
float scale = hardPix;
|
||||||
float wc=Gaus(dst+0.0,scale);
|
float wa = Gaus(dst - 2.0, scale);
|
||||||
float wd=Gaus(dst+1.0,scale);
|
float wb = Gaus(dst - 1.0, scale);
|
||||||
float we=Gaus(dst+2.0,scale);
|
float wc = Gaus(dst + 0.0, scale);
|
||||||
// Return filtered sample.
|
float wd = Gaus(dst + 1.0, scale);
|
||||||
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
|
float we = Gaus(dst + 2.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz5(vTexCoord, 2.0).rgb, 1.0);
|
FragColor = vec4(Horz5(vTexCoord, 2.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
#define hardBloomPix -1.5
|
#define hardBloomPix -1.5
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,40 +32,54 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 7-tap Gaussian filter along horz line.
|
// 7-tap Gaussian filter along horz line.
|
||||||
vec3 Horz7(vec2 pos,float off){
|
vec3 Horz7(vec2 pos, float off)
|
||||||
vec3 a=Fetch(pos,vec2(-3.0,off));
|
{
|
||||||
vec3 b=Fetch(pos,vec2(-2.0,off));
|
vec3 a = Fetch(pos, vec2(-3.0, off));
|
||||||
vec3 c=Fetch(pos,vec2(-1.0,off));
|
vec3 b = Fetch(pos, vec2(-2.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 0.0,off));
|
vec3 c = Fetch(pos, vec2(-1.0, off));
|
||||||
vec3 e=Fetch(pos,vec2( 1.0,off));
|
vec3 d = Fetch(pos, vec2( 0.0, off));
|
||||||
vec3 f=Fetch(pos,vec2( 2.0,off));
|
vec3 e = Fetch(pos, vec2( 1.0, off));
|
||||||
vec3 g=Fetch(pos,vec2( 3.0,off));
|
vec3 f = Fetch(pos, vec2( 2.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 g = Fetch(pos, vec2( 3.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardBloomPix;
|
|
||||||
float wa=Gaus(dst-3.0,scale);
|
// Convert distance to weight.
|
||||||
float wb=Gaus(dst-2.0,scale);
|
float scale = hardBloomPix;
|
||||||
float wc=Gaus(dst-1.0,scale);
|
float wa = Gaus(dst - 3.0, scale);
|
||||||
float wd=Gaus(dst+0.0,scale);
|
float wb = Gaus(dst - 2.0, scale);
|
||||||
float we=Gaus(dst+1.0,scale);
|
float wc = Gaus(dst - 1.0, scale);
|
||||||
float wf=Gaus(dst+2.0,scale);
|
float wd = Gaus(dst + 0.0, scale);
|
||||||
float wg=Gaus(dst+3.0,scale);
|
float we = Gaus(dst + 1.0, scale);
|
||||||
// Return filtered sample.
|
float wf = Gaus(dst + 2.0, scale);
|
||||||
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);}
|
float wg = Gaus(dst + 3.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz7(vTexCoord, 0.0).rgb, 1.0);
|
FragColor = vec4(Horz7(vTexCoord, 0.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
#define hardBloomPix -1.5
|
#define hardBloomPix -1.5
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,40 +32,54 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 7-tap Gaussian filter along horz line.
|
// 7-tap Gaussian filter along horz line.
|
||||||
vec3 Horz7(vec2 pos,float off){
|
vec3 Horz7(vec2 pos, float off)
|
||||||
vec3 a=Fetch(pos,vec2(-3.0,off));
|
{
|
||||||
vec3 b=Fetch(pos,vec2(-2.0,off));
|
vec3 a = Fetch(pos, vec2(-3.0, off));
|
||||||
vec3 c=Fetch(pos,vec2(-1.0,off));
|
vec3 b = Fetch(pos, vec2(-2.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 0.0,off));
|
vec3 c = Fetch(pos, vec2(-1.0, off));
|
||||||
vec3 e=Fetch(pos,vec2( 1.0,off));
|
vec3 d = Fetch(pos, vec2( 0.0, off));
|
||||||
vec3 f=Fetch(pos,vec2( 2.0,off));
|
vec3 e = Fetch(pos, vec2( 1.0, off));
|
||||||
vec3 g=Fetch(pos,vec2( 3.0,off));
|
vec3 f = Fetch(pos, vec2( 2.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 g = Fetch(pos, vec2( 3.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardBloomPix;
|
|
||||||
float wa=Gaus(dst-3.0,scale);
|
// Convert distance to weight.
|
||||||
float wb=Gaus(dst-2.0,scale);
|
float scale = hardBloomPix;
|
||||||
float wc=Gaus(dst-1.0,scale);
|
float wa = Gaus(dst - 3.0, scale);
|
||||||
float wd=Gaus(dst+0.0,scale);
|
float wb = Gaus(dst - 2.0, scale);
|
||||||
float we=Gaus(dst+1.0,scale);
|
float wc = Gaus(dst - 1.0, scale);
|
||||||
float wf=Gaus(dst+2.0,scale);
|
float wd = Gaus(dst + 0.0, scale);
|
||||||
float wg=Gaus(dst+3.0,scale);
|
float we = Gaus(dst + 1.0, scale);
|
||||||
// Return filtered sample.
|
float wf = Gaus(dst + 2.0, scale);
|
||||||
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);}
|
float wg = Gaus(dst + 3.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz7(vTexCoord, -1.0).rgb, 1.0);
|
FragColor = vec4(Horz7(vTexCoord, -1.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#define brightboost 1
|
#define brightboost 1
|
||||||
#define shape 2.0
|
#define shape 2.0
|
||||||
#define hardBloomPix -1.5
|
#define hardBloomPix -1.5
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 REFERENCESize;
|
vec4 REFERENCESize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -19,8 +19,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
// vTexCoord = floor(global.REFERENCESize.xy * TexCoord);
|
||||||
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
// vTexCoord = (vTexCoord + 0.5) * global.REFERENCESize.zw;
|
||||||
}
|
}
|
||||||
|
@ -32,40 +32,54 @@ layout(set = 0, binding = 2) uniform sampler2D REFERENCE;
|
||||||
|
|
||||||
// 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=vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
{
|
||||||
return brightboost * texture(REFERENCE,pos.xy).rgb;
|
pos = vTexCoord;//(floor(pos*global.REFERENCESize.xy+off)+vec2(0.5,0.5)) * global.REFERENCESize.zw;
|
||||||
|
|
||||||
|
return brightboost * texture(REFERENCE, pos.xy).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance in emulated pixels to nearest texel.
|
// Distance in emulated pixels to nearest texel.
|
||||||
vec2 Dist(vec2 pos){pos=pos*global.REFERENCESize.xy;return -((pos-floor(pos))-vec2(0.5));}
|
vec2 Dist(vec2 pos)
|
||||||
|
{
|
||||||
|
pos = pos*global.REFERENCESize.xy;
|
||||||
|
|
||||||
|
return -((pos - floor(pos)) - vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
// 1D Gaussian.
|
// 1D Gaussian.
|
||||||
float Gaus(float pos,float scale){return exp2(scale*pow(abs(pos),shape));}
|
float Gaus(float pos, float scale)
|
||||||
|
{
|
||||||
|
return exp2(scale*pow(abs(pos), shape));
|
||||||
|
}
|
||||||
|
|
||||||
// 7-tap Gaussian filter along horz line.
|
// 7-tap Gaussian filter along horz line.
|
||||||
vec3 Horz7(vec2 pos,float off){
|
vec3 Horz7(vec2 pos, float off)
|
||||||
vec3 a=Fetch(pos,vec2(-3.0,off));
|
{
|
||||||
vec3 b=Fetch(pos,vec2(-2.0,off));
|
vec3 a = Fetch(pos, vec2(-3.0, off));
|
||||||
vec3 c=Fetch(pos,vec2(-1.0,off));
|
vec3 b = Fetch(pos, vec2(-2.0, off));
|
||||||
vec3 d=Fetch(pos,vec2( 0.0,off));
|
vec3 c = Fetch(pos, vec2(-1.0, off));
|
||||||
vec3 e=Fetch(pos,vec2( 1.0,off));
|
vec3 d = Fetch(pos, vec2( 0.0, off));
|
||||||
vec3 f=Fetch(pos,vec2( 2.0,off));
|
vec3 e = Fetch(pos, vec2( 1.0, off));
|
||||||
vec3 g=Fetch(pos,vec2( 3.0,off));
|
vec3 f = Fetch(pos, vec2( 2.0, off));
|
||||||
float dst=Dist(pos).x;
|
vec3 g = Fetch(pos, vec2( 3.0, off));
|
||||||
// Convert distance to weight.
|
float dst = Dist(pos).x;
|
||||||
float scale=hardBloomPix;
|
|
||||||
float wa=Gaus(dst-3.0,scale);
|
// Convert distance to weight.
|
||||||
float wb=Gaus(dst-2.0,scale);
|
float scale = hardBloomPix;
|
||||||
float wc=Gaus(dst-1.0,scale);
|
float wa = Gaus(dst - 3.0, scale);
|
||||||
float wd=Gaus(dst+0.0,scale);
|
float wb = Gaus(dst - 2.0, scale);
|
||||||
float we=Gaus(dst+1.0,scale);
|
float wc = Gaus(dst - 1.0, scale);
|
||||||
float wf=Gaus(dst+2.0,scale);
|
float wd = Gaus(dst + 0.0, scale);
|
||||||
float wg=Gaus(dst+3.0,scale);
|
float we = Gaus(dst + 1.0, scale);
|
||||||
// Return filtered sample.
|
float wf = Gaus(dst + 2.0, scale);
|
||||||
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);}
|
float wg = Gaus(dst + 3.0, scale);
|
||||||
|
|
||||||
|
// Return filtered sample.
|
||||||
|
return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(Horz7(vTexCoord, 1.0).rgb, 1.0);
|
FragColor = vec4(Horz7(vTexCoord, 1.0).rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 SourceSize;
|
vec4 SourceSize;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
|
@ -17,8 +17,8 @@ layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord;
|
vTexCoord = TexCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma stage fragment
|
#pragma stage fragment
|
||||||
|
@ -28,5 +28,5 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(pow(texture(Source, vTexCoord).rgb, vec3(GAMMA)), 1.0);
|
FragColor = vec4(pow(texture(Source, vTexCoord).rgb, vec3(GAMMA)), 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue