2017-05-19 03:27:53 +10:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
/*
|
|
|
|
Merge Dithering and Pseudo Transparency Shader v2.8 - Pass 1
|
|
|
|
by Sp00kyFox, 2014
|
|
|
|
|
|
|
|
Preparing checkerboard patterns.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
layout(push_constant) uniform Push
|
|
|
|
{
|
|
|
|
vec4 SourceSize;
|
|
|
|
vec4 OriginalSize;
|
|
|
|
vec4 OutputSize;
|
|
|
|
uint FrameCount;
|
|
|
|
} params;
|
|
|
|
|
|
|
|
#define TEX(dx,dy) texture(Source, vTexCoord+vec2((dx),(dy))*params.SourceSize.zw)
|
|
|
|
|
|
|
|
|
2018-07-15 08:59:59 +10:00
|
|
|
float and_(float a, float b){
|
2017-05-19 03:27:53 +10:00
|
|
|
return min(a,b);
|
|
|
|
}
|
|
|
|
|
2018-07-15 08:59:59 +10:00
|
|
|
float and_(float a, float b, float c){
|
2017-05-19 03:27:53 +10:00
|
|
|
return min(a, min(b,c));
|
|
|
|
}
|
|
|
|
|
2018-07-15 08:59:59 +10:00
|
|
|
float or_(float a, float b){
|
2017-05-19 03:27:53 +10:00
|
|
|
return max(a,b);
|
|
|
|
}
|
|
|
|
|
2018-07-15 08:59:59 +10:00
|
|
|
float or_(float a, float b, float c, float d, float e){
|
2017-05-19 03:27:53 +10:00
|
|
|
return max(a, max(b, max(c, max(d,e))));
|
|
|
|
}
|
|
|
|
|
|
|
|
layout(std140, set = 0, binding = 0) uniform UBO
|
|
|
|
{
|
|
|
|
mat4 MVP;
|
|
|
|
} global;
|
|
|
|
|
|
|
|
#pragma stage vertex
|
|
|
|
layout(location = 0) in vec4 Position;
|
|
|
|
layout(location = 1) in vec2 TexCoord;
|
|
|
|
layout(location = 0) out vec2 vTexCoord;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = global.MVP * Position;
|
|
|
|
vTexCoord = TexCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma stage fragment
|
|
|
|
layout(location = 0) in vec2 vTexCoord;
|
|
|
|
layout(location = 0) out vec4 FragColor;
|
|
|
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
UL U UR
|
|
|
|
L C R
|
|
|
|
DL D DR
|
|
|
|
*/
|
|
|
|
|
|
|
|
vec3 C = TEX( 0., 0.).xyz;
|
|
|
|
vec3 L = TEX(-1., 0.).xyz;
|
|
|
|
vec3 R = TEX( 1., 0.).xyz;
|
|
|
|
vec3 D = TEX( 0., 1.).xyz;
|
|
|
|
vec3 U = TEX( 0.,-1.).xyz;
|
|
|
|
|
|
|
|
float UL = TEX(-1.,-1.).z;
|
|
|
|
float UR = TEX( 1.,-1.).z;
|
|
|
|
float DL = TEX(-1., 1.).z;
|
|
|
|
float DR = TEX( 1., 1.).z;
|
|
|
|
|
|
|
|
// Checkerboard Pattern Completion
|
2018-07-15 08:59:59 +10:00
|
|
|
float prCB = or_(C.z,
|
|
|
|
and_(L.z, R.z, or_(U.x, D.x)),
|
|
|
|
and_(U.z, D.z, or_(L.y, R.y)),
|
|
|
|
and_(C.x, or_(and_(UL, UR), and_(DL, DR))),
|
|
|
|
and_(C.y, or_(and_(UL, DL), and_(UR, DR))));
|
2017-05-19 03:27:53 +10:00
|
|
|
FragColor = vec4(C.x, prCB, 0.0, 0.0);
|
|
|
|
}
|