Hellow. I’m trying to write a billboard shader using #pragma vertex with surface shader. But as I understand you don’t have full control on vertex when using surface shader, and your modified vertex will be multiplied on MVP matrix anyway? With that in mind currently I’m trying smth like:
#pragma surface surf Lambert alphatest:_Cutoff addshadow vertex:vert_func
void vert_func(inout appdata_full v_input, out Input v_output)
{
float3 view_pos = mul (UNITY_MATRIX_MV, v_input.vertex); // vertex to view space
float3 view_dir = normalize(view_pos);
float3 right_dir = cross(view_dir, float3(0.0, 1.0, 0.0));
// rotate our vertex using texcoords so it always face the camera
float3 result_pos = view_pos + right_dir * v_input.texcoord.x + float3(0.0, 1.0, 0.0) * v_input.texcoord.y;
// transform it back to model space
v_input.vertex.xyz = mul (UNITY_MATRIX_T_MV, float4(result_pos, 1.0));
}
but it looks wrong. Is it possible to get such functionality with surface shaders or do I have to use Cg shaders?