'Unity SpriteShape Material with ShaderGraph

Disclaimer: I know this is not a complete coding question, but since I access and modify the shaders via code, this post fits here IMHO.

What I've done so far in the context of a 2D game: I'm using the SpriteShapes for the grounds as well as the fog in a game. Since it's a bit boring to only use simple sprites for fog, I've tried implementing a shader for this (with the new ShaderGraph). I've played a bit around with shaders in the past and also the fog shader implemented for this is working fine with "normal"2D sprites.

What are the issues:

  1. The coordinates of the fill material seem to bit different to to coordinates of the edge material. Isn't there a way to only use the global coordinate system? I created a workaround to use a complete transparent material for the edges. With the same material the issue is displayed in the screenshot: Different coordinates regarding fill and edge material

  2. I want to fade out the texture when it's getting closer to the edge. I acchieved this for simple textures, but I wonder how this can be acchieved according to the actual SpriteShape border. The following screenshot is using a texture that is fadind out at the outer edges, but that is a square and not the actual sprite shape shape: enter image description here

Any help appreciated according to these two problems. I just found simple solutions for 2D sprites, but nothing related to shaders and spriteshapes. Thanks :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source