rendered paste bodyShader "Comic Test" {
Properties { }
SubShader {
Tags { "RenderType"="Opaque" }
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : POSITION;
float3 camDir : TEXCOORD1;
};
v2f vert(appdata_tan v) {
v2f o;
float4 worldSpacePos = mul(_Object2World, v.vertex);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
// calculate binormal
float3 binormal = cross(v.normal, v.tangent.xyz) * v.tangent.w;
// Setup tangent space matrix.
float3x3 tspace = float3x3(v.tangent.xyz, binormal, v.normal);
// Calculate view direction
float3 camDir = normalize((_WorldSpaceCameraPos - worldSpacePos).xyz );
o.camDir = mul(tspace, camDir);
return o;
}
half4 frag(v2f i) : COLOR {
return float4(i.camDir, 1);
}
ENDCG
}
}
}