Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- v2f vert (appdata_full v)
- {
- v2f o;
- o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
- // get direction to camera in object space
- float3 facing = normalize(mul((float3x3)unity_WorldToObject, _WorldSpaceCameraPos) - v.vertex);
- // v.normal contains the direction
- float3 up = v.normal;
- // cross product gets the perpendicular
- float3 right = normalize(cross(facing, up));
- float3 lineBillboardOffset = mul((float3x3)UNITY_MATRIX_MVP, right);
- //v.texcoord.x contains if its left or right
- lineBillboardOffset.xy *= v.texcoord.x;
- //set the line thickness
- lineBillboardOffset.xy *= _LineThickness;
- //Add the offset
- o.vertex.xy += lineBillboardOffset.xy;
- return o;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement