Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1.             v2f vert (appdata_full v)
  2.             {
  3.                 v2f o;             
  4.  
  5.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  6.  
  7.                 // get direction to camera in object space
  8.                 float3 facing = normalize(mul((float3x3)unity_WorldToObject, _WorldSpaceCameraPos) - v.vertex);
  9.                 // v.normal contains the direction
  10.                 float3 up = v.normal;
  11.                 // cross product gets the perpendicular
  12.                 float3 right = normalize(cross(facing, up));
  13.  
  14.  
  15.                 float3 lineBillboardOffset = mul((float3x3)UNITY_MATRIX_MVP, right);
  16.                 //v.texcoord.x contains if its left or right
  17.                 lineBillboardOffset.xy *= v.texcoord.x;
  18.                 //set the line thickness
  19.                 lineBillboardOffset.xy *= _LineThickness;
  20.  
  21.                 //Add the offset
  22.                 o.vertex.xy += lineBillboardOffset;
  23.  
  24.                 return o;
  25.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement