RetroArch-Wii-U-Slang-Shaders/scalefx/shaders/scalefx-pass0.ppslang
2020-04-26 18:03:54 -05:00

105 lines
1.1 KiB
Text

#version 450
layout(push_constant)uniform Push
{
vec4 SourceSize;
} params;
layout(set = 0, binding = 0, std140)uniform UBO
{
mat4 MVP;
} global;
#pragma stagevertex
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 stagefragment
layout(location = 0)in vec2 vTexCoord;
layout(location = 0)out vec4 FragColor;
layout(binding = 1)uniform sampler2D Source;
float dist(vec3 A, vec3 B)
{
float r = 0.5 *(A . r + B . r);
vec3 d = A - B;
vec3 c = vec3(2 + r, 4, 3 - r);
return sqrt(dot(c * d, d))/ 3;
}
void main()
{
vec3 A = textureOffset(Source, vTexCoord, ivec2(- 1, - 1)). rgb;
vec3 B = textureOffset(Source, vTexCoord, ivec2(0, - 1)). rgb;
vec3 C = textureOffset(Source, vTexCoord, ivec2(1, - 1)). rgb;
vec3 E = textureOffset(Source, vTexCoord, ivec2(0, 0)). rgb;
vec3 F = textureOffset(Source, vTexCoord, ivec2(1, 0)). rgb;
FragColor = vec4(dist(E, A), dist(E, B), dist(E, C), dist(E, F));
}