Search Unity

Vertex World Position With Offset

Discussion in 'Shaders' started by Justafin, Feb 4, 2017.

  1. Justafin

    Justafin

    Joined:
    Aug 6, 2012
    Posts:
    30
    Trying to offset vertex positions based upon their normal, similar to how I've seen it done in outline shaders:

    but I need to also need the world position of the vertex with this offset. Can anyone help?

    Thanks
     
  2. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    To translate the position from object space to world space you just have to multiply it with the correct matrix:
    Code (CSharp):
    1. mul(unity_ObjectToWorld, vertexPosition);
    Does this answer your question?
     
  3. Justafin

    Justafin

    Joined:
    Aug 6, 2012
    Posts:
    30
    I need the world space position with the vertices offset a small amount in their normal direction.