Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetBlendShapeBuffer

Retrieves a GraphicsBuffer that provides direct read and write access to GPU blend shape vertex data.
Read time 3 minutesLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

GetBlendShapeBuffer(BlendShapeBufferLayout)

Retrieves a GraphicsBuffer that provides direct read and write access to GPU blend shape vertex data.
public GraphicsBuffer GetBlendShapeBuffer(BlendShapeBufferLayout layout)

Parameters

Which buffer to access. The default value is BlendShapeBufferLayout.PerShape.

Returns

Type

Description

GraphicsBufferThe blend shape vertex data as a GraphicsBuffer.

Remarks

The buffer that this function returns is called the blend shape buffer. It contains blend shape vertices, which the GPU uses to deform the mesh into blend shapes.
There are two blend shape buffers that you can access. They use different layout patterns, and contain slightly different data. For more information, see BlendShapeBufferLayout.PerShape and BlendShapeBufferLayout.PerVertex. Compute shader support is required to access this buffer.
The version of this function that takes no parameter is equivalent to calling it with BlendShapeBufferLayout.PerShape as argument.
Mesh.isReadable does not need to be
true
to access this data.
After using this buffer, you should dispose of it.
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); // Fetch GraphicsBuffer with Blend Shape data, ordered per vertex, from the mesh var perVertexBuffer = mesh.GetBlendShapeBuffer(BlendShapeBufferLayout.PerVertex); // Set Blend Shape data buffers to a compute shader computeShader.SetBuffer(0, "PerShape_BlendShapeBuffer", perShapeBuffer); computeShader.SetBuffer(0, "PerVertex_BlendShapeBuffer", perVertexBuffer); // Dispatch compute shader and access Blend Shapes on the GPU, both per vertex and per shape computeShader.Dispatch(0, 64, 1, 1); // Dispose buffers to avoid leaking memory perShapeBuffer.Dispose(); perVertexBuffer.Dispose(); }}
Additional Resources: Blend shapes, BlendShapeBufferLayout, Mesh.GetBoneWeightBuffer.

GetBlendShapeBuffer()

Retrieves a GraphicsBuffer that provides direct read and write access to GPU blend shape vertex data.
public GraphicsBuffer GetBlendShapeBuffer()

Returns

Type

Description

GraphicsBufferThe blend shape vertex data as a GraphicsBuffer.

Remarks

The buffer that this function returns is called the blend shape buffer. It contains blend shape vertices, which the GPU uses to deform the mesh into blend shapes.
There are two blend shape buffers that you can access. They use different layout patterns, and contain slightly different data. For more information, see BlendShapeBufferLayout.PerShape and BlendShapeBufferLayout.PerVertex. Compute shader support is required to access this buffer.
The version of this function that takes no parameter is equivalent to calling it with BlendShapeBufferLayout.PerShape as argument.
Mesh.isReadable does not need to be
true
to access this data.
After using this buffer, you should dispose of it.
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); // Fetch GraphicsBuffer with Blend Shape data, ordered per vertex, from the mesh var perVertexBuffer = mesh.GetBlendShapeBuffer(BlendShapeBufferLayout.PerVertex); // Set Blend Shape data buffers to a compute shader computeShader.SetBuffer(0, "PerShape_BlendShapeBuffer", perShapeBuffer); computeShader.SetBuffer(0, "PerVertex_BlendShapeBuffer", perVertexBuffer); // Dispatch compute shader and access Blend Shapes on the GPU, both per vertex and per shape computeShader.Dispatch(0, 64, 1, 1); // Dispose buffers to avoid leaking memory perShapeBuffer.Dispose(); perVertexBuffer.Dispose(); }}
Additional Resources: Blend shapes, BlendShapeBufferLayout, Mesh.GetBoneWeightBuffer.