I'm trying to use Civ3 animations, and those animations are on a pink field. I'm trying to use pixel effects to remove the pink and make it transparent. Getting rid of the pink itself isn't too difficult; what is difficult is removing the residual pixels that have a pinkish hue, removing the pink and increasing the alpha component (this would allow shadows to appear, for example).
Here's a snippet of the most recent attempt at the code:
Code: Select all
effect = love.graphics.newPixelEffect [[
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
vec4 rColor = Texel(texture, vec2(1, 1));
vec4 AlphaColor = Texel(texture, texture_coords);
vec4 fColor;
if (all(equal(AlphaColor, rColor)))
{
AlphaColor.r -= rColor.r;
AlphaColor.g -= rColor.g;
AlphaColor.b -= rColor.b;
AlphaColor.a = abs(AlphaColor.r)+abs(AlphaColor.g)+abs(AlphaColor.b);
AlphaColor.a /= 3;
fColor = Texel(texture, texture_coords);
fColor.a = AlphaColor.a;
}
else
{
fColor = Texel(texture, texture_coords);
return fColor;
}
}
]]