描述混合形状顶点数据在GraphicsBuffer中的位置。
当您使用BlendShapeBufferLayout.PerShape调用Mesh.GetBlendShapeBuffer时,Unity 会返回一个包含混合形状顶点数据的GraphicsBuffer,这些数据按混合形状排序。
当您为给定的混合形状调用Mesh.GetBlendShapeBufferRange时,Unity 会返回此结构体。使用此结构体可以在GraphicsBuffer
中找到该混合形状的数据。
using UnityEngine; using UnityEngine.Rendering;
public class Example : MonoBehaviour { public Mesh mesh; public ComputeShader computeShader;
void Start() { // Fetch GraphicsBuffer with Blend Shape data, ordered per shape, from the mesh var perShapeBuffer = mesh.GetBlendShapeBuffer(BlendShapeBufferLayout.PerShape);
// Iterate over all Blend Shapes in a mesh for (int blendShapeIndex = 0; blendShapeIndex < mesh.blendShapeCount; ++blendShapeIndex) { // Fetch which indices in the buffer that is part of this Blend Shape var blendShapeRange = mesh.GetBlendShapeBufferRange(blendShapeIndex);
// Set the start and end indices of the Blend Shape in the compute shader computeShader.SetInt("_StartIndex", (int)blendShapeRange.startIndex); computeShader.SetInt("_EndIndex", (int)blendShapeRange.endIndex);
// Dispatch compute shader and access data between start and end index for this Blend Shape computeShader.Dispatch(0, 64, 1, 1); }
// Dispose of GraphicsBuffer to avoid leak memory perShapeBuffer.Dispose(); } }
endIndex | 请求的混合形状的最后一个混合形状顶点的索引。 |
startIndex | 请求的混合形状的第一个混合形状顶点的索引。 |