get camera direction frag shader Unity code example
Example: Unlit shader get the direction of camera UNity
struct v2f {
float4 pos : SV_POSITION;
float3 normal : TEXCOORD0; //you don't need these semantics except for XBox360
float3 viewT : TEXCOORD1; //you don't need these semantics except for XBox360
};
v2f vert (appdata_base v) {
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.normal = normalize(v.normal);
o.viewT = normalize(WorldSpaceViewDir(v.vertex));//ObjSpaceViewDir is similar, but localspace.
return o;
}