I have a shader for highlights and outlines that works just fine, except in one small but hugely annoying way:
https://i.stack.imgur.com/vfsNx.png
https://i.stack.imgur.com/N3mG6.png
My sprite is divided into separate Gameobjects for 'player', 'hair', 'outfit' and 'weapons' which are all swappable and animated. The outline/fill material is also on its own Gameobject, and the shader uses the 'player' Sprite Renderer as its _mainTex and to set the Sprite on it own Sprite Renderer.
The shader is currently using the 'hair' (and eventually 'outfit' and 'weapons') Sprite Renderer texture as a secondary texture in shader graph with the name _Hair to create a composite highlighted/outlined image of both hair and body.
It works great... except for the fact that the top line, and always exactly the the top line of pixels is cut off.
I know it's not the sprite sheet or any import setting problems, because other shaders are working fine on the individual parts, and I'm not using a sprite atlas or anything. I think it must be a problem with the way I've set up shader graph...
https://i.stack.imgur.com/5LZHZ.png
...the way I'm accessing the texture from the 'hair' sprite renderer or the way I'm setting the texture:
public class PlayerOutline : EntityOutline
{
public SpriteRenderer outlineRend;
public SpriteRenderer hairRend;
public override void SetSprite()
{
if (hairRend.sprite)
{
outlineRend.material.SetTexture("_Hair",hairRend.sprite.texture);
}
base.SetSprite();
}
}
I've been stuck on this for two days, so I'd be very grateful for any ideas, and I'm still very much a beginner with shaders; I haven't used them for much more than things like this before. This was also quite a hard problem to title, so any advice on a better title is also welcome!