31 lines
1002 B
GLSL
31 lines
1002 B
GLSL
#pragma language glsl3
|
|
|
|
extern ivec2 texSize;
|
|
extern float time;
|
|
|
|
vec4 effect(vec4 color, Image tex, vec2 texCoord, vec2 screenCoord)
|
|
{
|
|
float modY = (0.75 + sin(time) * 0.25) * (0.5 + cos(texCoord.y + 10 * sin(0.1 * time)) * 0.5);
|
|
vec4 outlineColor = vec4(modY, 0.2 * sin(time) + 0.5, 0.5, 1.0);
|
|
float outlineSize = 1.0;
|
|
|
|
float alpha = Texel(tex, texCoord).a;
|
|
if (alpha > 0.0)
|
|
return Texel(tex, texCoord) * color;
|
|
|
|
// Если среди соседей есть хоть один прозрачный пиксель, то это граница, обводим её
|
|
float outline = 0.0;
|
|
for (float x = -outlineSize; x <= outlineSize; x++) {
|
|
for (float y = -outlineSize; y <= outlineSize; y++) {
|
|
vec2 offset = vec2(x, y) / texSize;
|
|
float neighborAlpha = Texel(tex, texCoord + offset).a;
|
|
outline = max(outline, neighborAlpha);
|
|
}
|
|
}
|
|
|
|
if (outline > 0.0)
|
|
return outlineColor;
|
|
|
|
return vec4(0.0);
|
|
}
|