yabba/shaders/fragment.glsl
#version 150 core
///shaderType:fragment
in vec2 posGO;
in vec2 texPosGO;
out vec4 colorFO; // layout(location = 0)
uniform vec3 playerPos;
uniform sampler2D tex_tilemap;
uniform vec4 tilespec;
uniform uvec2 modelType;
void main() {
float border = 0.0;
if ((modelType.y & 1u) != 0u) { // tr
border += (texPosGO.x * (1.0-texPosGO.y)) / 2.0;
}
if ((modelType.y & 2u) != 0u) { // br
border += (texPosGO.x * texPosGO.y) / 2.0;
}
if ((modelType.y & 4u) != 0u) { // bl
border += ((1.0-texPosGO.x) * texPosGO.y) / 2.0;
}
if ((modelType.y & 8u) != 0u) { // tl
border += ((1.0-texPosGO.x) * (1.0-texPosGO.y)) / 2.0;
}
float player_dist = length(vec2(
posGO.x * playerPos.z,
posGO.y
));
colorFO = mix(
mix(
texture(tex_tilemap, vec2(
tilespec.y + (texPosGO.x * tilespec.x),
tilespec.w + (texPosGO.y * tilespec.z)
)),
vec4(0.0, 0.0, 0.0, 1.0),
min(1.0, player_dist)
),
vec4(0.0, 0.0, 0.0, 1.0),
border
);
}