1#version 460 core
2#extension GL_ARB_separate_shader_objects : enable
3#extension GL_ARB_shading_language_420pack : enable
4
5// specialization
6
7// includes
8#include "render/shaders/common/render_compatibility_common.h"
9
10// sets
11
12layout(set = 0, binding = 0) uniform sampler uSampler;
13layout(set = 0, binding = 1) uniform texture2D uTex;
14
15// in / out
16
17layout (location = 0) in vec2 inUv;
18
19layout (location = 0) out vec4 outColor;
20
21struct PushConstantStruct
22{
23    vec4 texSizeInvTexSize;
24};
25
26layout(push_constant, std430) uniform uPushConstant
27{
28    PushConstantStruct uPc;
29};
30
31void main(void)
32{
33    const vec2 ths = uPc.texSizeInvTexSize.zw * 0.5;
34    const vec2 uv = inUv;
35
36    // center
37    vec4 color = textureLod(sampler2D(uTex, uSampler), uv, 0) * 0.5;
38    // corners
39    // 1.0 / 8.0 = 0.125
40    color += textureLod(sampler2D(uTex, uSampler), uv - ths, 0) * 0.125;
41    color += textureLod(sampler2D(uTex, uSampler), vec2(uv.x + ths.x, uv.y - ths.y), 0) * 0.125;
42    color += textureLod(sampler2D(uTex, uSampler), vec2(uv.x - ths.x, uv.y + ths.y), 0) * 0.125;
43    color += textureLod(sampler2D(uTex, uSampler), uv + ths, 0) * 0.125;
44
45    outColor = color.rgba;
46}
47