Hello folks,
I am trying to create a shader that will help me create an animated 3D stadium crowd. I currently have a rigged and animated mesh that I want to use. I was hoping to use a shader that will create multiple instances of this mesh with the verts offset by different amounts.
Shader "OffsetCrowd"
{
Properties
{
_Color("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Texture", 2D) = "white" {}
_Offset("Vertex Offset Translation", Vector) = (0,0,0,0)
}
SubShader
{
Tags {"RenderType" = "Opaque" "IgnoreProjector"="True"}
CGPROGRAM
#pragma surface surf Lambert vertex:vert
struct Input
{
float2 uv_MainTex;
};
float4 _Offset;
void vert (inout appdata_full v)
{
v.vertex.xyz += _Offset.xyz;
}
sampler2D _MainTex;
float4 _Color;
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = tex2D(_MainTex,IN.uv_MainTex).rgb * float3(2,2,2) *_Color.rgb;
}
ENDCG
}
Fallback "Diffuse"
}
So with this shader I can offset the mesh by a set amount along the objects axis. And if I make a few copies of this material, each with different _Offset values, and put them on the mesh’s Skinned Renderer, I get the effect I want. The problem with this is the excessive number of draw calls. Is it even possible to generate multiple instances of a mesh through a shader?
Any ideas or suggestions for creating an efficient 3D animated crowd are welcome.
Thanks in advance,
Andrew