Hello. It is worth saying that I've never worked with shaders and possibly don't familiar with some base concepts. So my purpose is writing simple outline shader, no more, and I don't see the point in spending a lot of time to learn shading skills.

All magenta pixels actually transparent, magenta only here for visibility on white background.

So I have some sprite and outline mask sprite with same size. In shader I want impose outline mask to sprite to get outline effect. Probably sounds unclear, let's go to specific sprites. I have this spritesheet with isometric-ship: And this outline mask: In sprite node first set as texture, second as normal map: I've created new matireal, and put this code in shader script:

shader_type canvas_item;

void fragment(){
	COLOR = texture(TEXTURE, UV)+texture(NORMAL_TEXTURE, UV);
}

In my mind, empty pixels from NORMAL_TEXTURE added with colored pixels from TEXTURE should save color from TEXTURE in the result. But I see that: So just overlaying outline mask to sprite in any graphic editor have another result: At first I thought about non-zero values in rbg channels, and we don't see color becouse alpha channel set as0, but when adding two textures in shader script they make themselves felt. So I filled whole transparent pixels in black, and now outline mask looks like this: But in godot result more strange: I tryied all render_mode, but the result did't suit me. And now I understand that I need forum help.

Thanks that you read this considerable question, I tried told you everything I had tried or thought. I hope you haven't questions to my question :)

Maybe try this with the black mask:

shader_type canvas_item;
void fragment(){
    vec4 mask_col = texture(NORMAL_TEXTURE, UV);
    if (mask_col.r > 0.1) {
        COLOR = mask_col;
    }
    else {
        COLOR = texture(TEXTURE, UV);
    }
}

That looks like you might have exported an 'optimized' PNG? What image editor are you exporting from, and with what settings? And what are your image import settings in godot?

@TwistedTwigleg your example should work and I'd been even using this method. But I refused from It becouse this doesn't allow using transparent, or modulated outline color. I thought about outline mask as place where outline must be, and about every pixel settings, like modulating outline color, or transparent. For example I have white pixel with alpha channel as 0.2 which overlaps colored pixel from sprite, so this pixel must lighten up a little, but in your example this pixel just replace colored pixel and there will be "white hole" in result render.

@Megalomaniak I use Aseprite v1.2.9-x64, export settings in aseprite and import settings in godot you can see on screenshots:

edited: Also I tried .bmp format, with a little another code in shader:

shader_type canvas_item;

void fragment(){
	COLOR = vec4(texture(TEXTURE, UV).rgb+texture(NORMAL_TEXTURE, UV).rgb, 1.0);
}

And finally right result: So that your assumption must be right. But I still didn't reach the same result with .png format, I've re-exported this sprite with gimp without compression, and file size increased to ~75 KB against ~9 KB with aseprite, but result haven't changed.

heheheh. This problem fixes with just switching off Fix Alpha Border setting in import settings. In godot docs I don't quite understand what's It doing, but now it does not matter)

2 years later