public BakedAnimationClip(AnimationTextures animTextures, KeyframeTextureBaker.AnimationClipData clipData) { float onePixel = 1f / animTextures.Animation0.width; float start = (float)clipData.PixelStart / animTextures.Animation0.width + onePixel * 0.5f; float end = (float)clipData.PixelEnd / animTextures.Animation0.width + onePixel * 0.5f; TextureOffset = start; TextureRange = end - start; OnePixelOffset = onePixel; TextureWidth = animTextures.Animation0.width; AnimationLength = clipData.Clip.length; Looping = clipData.Clip.wrapMode == WrapMode.Loop; }
public unsafe InstancedSkinningDrawer(Material srcMaterial, Mesh meshToDraw, AnimationTextures animTexture) { this.mesh = meshToDraw; this.material = new Material(srcMaterial); argsBuffer = new ComputeBuffer(1, indirectArgs.Length * sizeof(uint), ComputeBufferType.IndirectArguments); indirectArgs[0] = mesh.GetIndexCount(0); indirectArgs[1] = (uint)0; argsBuffer.SetData(indirectArgs); objectToWorldBuffer = new ComputeBuffer(PreallocatedBufferSize, 16 * sizeof(float)); textureCoordinatesBuffer = new ComputeBuffer(PreallocatedBufferSize, 3 * sizeof(float)); this.material.SetBuffer("textureCoordinatesBuffer", textureCoordinatesBuffer); this.material.SetBuffer("objectToWorldBuffer", objectToWorldBuffer); this.material.SetTexture("_AnimationTexture0", animTexture.Animation0); this.material.SetTexture("_AnimationTexture1", animTexture.Animation1); this.material.SetTexture("_AnimationTexture2", animTexture.Animation2); }