Search Unity

Shader Sprite Defuse Thickness

Discussion in 'Shaders' started by piggybank1974, Dec 12, 2019.

  1. piggybank1974

    piggybank1974

    Joined:
    Dec 15, 2015
    Posts:
    621
    I've never tackled anything to do with shaders before, like this, only done the basic stuff.

    What I'm trying to achieve is draw lines using a Mesh and make them look like Vector graphics from the 80s and 90s this was done with a vector screen but I'm sure unity can draw a few lines.

    for example, code I created, I'm using the following

    Code (CSharp):
    1. public class TestComponent : MonoBehaviour
    2. {
    3.     void Start()
    4.     {
    5.      MeshFilter mFilter =  this.GetComponent<MeshFilter>();
    6.      Vector3[] verts = new Vector3[] { new Vector3(-2F, 0, -7F)  , new Vector3(-2F, 0, 7F), new Vector3(2F, 0, 7F), new Vector3(2F, 0, -7F) };
    7.   int[] indicesForLineStrip = new int[] { 0, 1, 2, 3, 0 };
    8.  
    9.   Mesh mesh = new Mesh();
    10.   mesh.vertices = verts;
    11.   mesh.SetIndices(indicesForLineStrip, MeshTopology.LineStrip, 0);
    12.   mesh.RecalculateBounds();
    13.  
    14.   mFilter.mesh = mesh;
    15. }
    16. }
    17.  
    this does create the line exactly how I wanted them, but I'm not too sure how I can add a thickness to the shader so I can make the line a bit thicker when needed "Selected segment for example"

    I did try to use a line renderer and yes it does work but the amount of line renders I would need is quite a few and I think this is a better way as it's much cleaner visually as well code wise.

    any help on creating the shader would be appreciated.
     
  2. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85