public static VertexAnimAttribute GetAttribute(Material m, int index) { VertexAnimAttribute attr = new VertexAnimAttribute(); attr.scale = m.GetVector(ShaderConst.SHADER_SCALE); attr.offset = m.GetVector(ShaderConst.SHADER_OFFSET); attr.end = m.GetVector(ShaderConst.SHADER_ANIM_END); attr.fps = m.GetFloat(ShaderConst.SHADER_FPS); var tex = m.GetTexture(ShaderConst.SHADER_ANIM_TEX); attr.texel = tex.texelSize; attr.index = index; return(attr); }
protected void SetupVertexAnim() { var animations = new Dictionary <string, Material>() { { "Idle", idle }, { "Walk", walk } }; var keys = animations.Keys.ToList(); int count = keys.Count; var attributes = new VertexAnimAttribute[count]; for (int i = 0; i < count; i++) { var key = keys[i]; var m = animations[key]; attributes[i] = VertexAnimHelper.GetAttribute(m, i); render.SetTexture("_PosTex_" + key, m.GetTexture(ShaderConst.SHADER_ANIM_TEX)); render.SetTexture("_NormTex_" + key, m.GetTexture(ShaderConst.SHADER_NORM_TEX)); } attributeBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(VertexAnimAttribute))); attributeBuffer.SetData(attributes); }