Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Generating new vertices in a shader

Discussion in 'Shaders' started by liortal, Feb 8, 2016.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,455
    We are using a UI effect that creates an outline around text by cloning existing vertices and displacing them slightly (by a given amount) to create an outline.

    I was wondering whether this effect could actually be achieved using a shader?

    *NOTE: we are targeting mobile platforms so this has to be compatible.

    Can anyone point me in the right direction? what kind of shader type? what components / steps needed to be used in Unity for this ?
     
  2. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    Generally for this you don't duplicate the verts, you just draw the mesh in two passes. One draws the outline (pushed verts, inverted normals) and the other draws the mesh itself as normal.
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,455
    Is that favorable to duplicating (generating new vertices) ?
     
  4. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    Yes, you can't duplicate vertices in a standard vertex shader (I should have mentioned that) :p
     
    liortal likes this.
unityunity