# GetPreviousVertexBuffer()

> Retrieves direct access to this renderer's deformed vertex data from the previous frame.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public GraphicsBuffer GetPreviousVertexBuffer()
```

### Returns

| Type                                                                            | Description                                                                                                                                                                 |
| ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [GraphicsBuffer](/engine/6000.7/script-reference/unityengine/graphicsbuffer.md) | The previous frame's deformed vertex buffer. If no previous-frame buffer exists, returns the current frame's buffer. If Unity hasn't deformed the mesh yet, returns `null`. |

### Remarks

Use this method to retrieve the deformed vertex buffer from the previous frame. Deformed vertex data is the vertex data after Unity applies skinning and blend shapes. Use [SkinnedMeshRenderer.GetVertexBuffer](/engine/6000.7/script-reference/unityengine/skinnedmeshrenderer/getvertexbuffer.md) to access the current frame's deformed vertices.

A previous-frame buffer is available only when [SkinnedMeshRenderer.skinnedMotionVectors](/engine/6000.7/script-reference/unityengine/skinnedmeshrenderer/skinnedmotionvectors.md) is enabled and Unity is rendering motion vectors. Unity renders motion vectors while at least one enabled [Camera](/engine/6000.7/script-reference/unityengine/camera.md) has [DepthTextureMode.MotionVectors](/engine/6000.7/script-reference/unityengine/depthtexturemode/motionvectors.md) set. Render pipelines typically set this mode when they render a motion vector pass for an effect such as motion blur or temporal anti-aliasing.

While rendering motion vectors, Unity alternates between two GPU vertex buffers that store the deformed vertex data for the current and previous frames. If Unity isn't rendering motion vectors, or if double buffering has only just started and no previous-frame data is available yet, this method returns the same buffer as [SkinnedMeshRenderer.GetVertexBuffer](/engine/6000.7/script-reference/unityengine/skinnedmeshrenderer/getvertexbuffer.md). If Unity hasn't deformed the mesh yet, no vertex buffer exists and this method returns null.

If the buffer has a target that allows compute access, such as [GraphicsBuffer.Target.Raw](/engine/6000.7/script-reference/unityengine/graphicsbuffer/target/raw.md) or [GraphicsBuffer.Target.Structured](/engine/6000.7/script-reference/unityengine/graphicsbuffer/target/structured.md), you can use it to access the previous frame's deformed vertex data in a [ComputeShader](/engine/6000.7/script-reference/unityengine/computeshader.md) or another shader. When Unity deforms the mesh on the GPU, the buffer already has such a target; otherwise, request one with [SkinnedMeshRenderer.vertexBufferTarget](/engine/6000.7/script-reference/unityengine/skinnedmeshrenderer/vertexbuffertarget.md) or [EditorGraphicsSettings.defaultMeshBufferTarget](/engine/6000.7/script-reference/unityeditor/rendering/editorgraphicssettings/defaultmeshbuffertarget.md). Bind the buffer as a shader parameter by using [ComputeShader.SetBuffer](/engine/6000.7/script-reference/unityengine/computeshader/setbuffer.md), [Material.SetBuffer](/engine/6000.7/script-reference/unityengine/material/setbuffer.md), or a similar method.

Additional Resources: [SkinnedMeshRenderer.vertexBufferTarget](/engine/6000.7/script-reference/unityengine/skinnedmeshrenderer/vertexbuffertarget.md), [SkinnedMeshRenderer.GetVertexBuffer](/engine/6000.7/script-reference/unityengine/skinnedmeshrenderer/getvertexbuffer.md), [SkinnedMeshRenderer.skinnedMotionVectors](/engine/6000.7/script-reference/unityengine/skinnedmeshrenderer/skinnedmotionvectors.md).
