---
title: AddComputeVariants
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addcomputevariants
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addcomputevariants.md
last_updated: 2026-11-13
generated_at: 2026-11-26T06:40:52.284Z
locale: en-us
---

# AddComputeVariants

> Adds to the collection the compute shader variants that the visual effect assets dispatch.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.VFX](/engine/7000.0/script-reference/unityengine/vfx.md)
* **Assembly:** UnityEngine.VFXModule

## AddComputeVariants(GraphicsStateCollection, VisualEffectAsset\[])

Adds to the collection the compute shader variants that the visual effect assets dispatch.

```csharp
public static bool AddComputeVariants(this GraphicsStateCollection graphicsStateCollection, VisualEffectAsset[] visualEffectAssets)
```

### Parameters

**** (\[GraphicsStateCollection]\(/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection)): The GraphicsStateCollection in which to add the compute shader variants.**** (\[VisualEffectAsset\[]]\(/engine/7000.0/script-reference/unityengine/vfx/visualeffectasset)): An array of [VisualEffectAsset](/engine/7000.0/script-reference/unityengine/vfx/visualeffectasset.md) files to scan for compute shaders.

### Returns

| Type                                                          | Description                                                                              |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if at least one new compute shader variant was successfully added, false otherwise. |

### Remarks

For each compute shader task in each [VisualEffectAsset](/engine/7000.0/script-reference/unityengine/vfx/visualeffectasset.md), this method adds the variant for kernel 0 with the compute shader's enabled local keywords and the global shader keywords that are currently enabled in the active context. For update tasks that can compute ray tracing bounding boxes, it adds the variants both with and without the `VFX_COMPUTE_AABBS` keyword. The method doesn't add compute shaders that the Visual Effect Graph runtime shares between all effects, such as sorting and indirect argument shaders. To record them, trace the collection at runtime. The method doesn't add a variant that the collection already contains.

Additional Resources: [GraphicsStateCollection.AddComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/addcomputevariant.md)

## AddComputeVariants(GraphicsStateCollection, VisualEffectAsset\[], GlobalKeyword\[])

Adds to the collection the compute shader variants that the visual effect assets dispatch.

```csharp
public static bool AddComputeVariants(this GraphicsStateCollection graphicsStateCollection, VisualEffectAsset[] visualEffectAssets, GlobalKeyword[] globalKeywords)
```

### Parameters

**** (\[GraphicsStateCollection]\(/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection)): The GraphicsStateCollection in which to add the compute shader variants.**** (\[VisualEffectAsset\[]]\(/engine/7000.0/script-reference/unityengine/vfx/visualeffectasset)): An array of [VisualEffectAsset](/engine/7000.0/script-reference/unityengine/vfx/visualeffectasset.md) files to scan for compute shaders.**** (\[GlobalKeyword\[]]\(/engine/7000.0/script-reference/unityengine/rendering/globalkeyword)): An array of [GlobalKeyword](/engine/7000.0/script-reference/unityengine/rendering/globalkeyword.md) objects to use with each compute shader's enabled local keywords when the method generates compute shader variants.

### Returns

| Type                                                          | Description                                                                              |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if at least one new compute shader variant was successfully added, false otherwise. |

### Remarks

This method operates like [VFXGraphicsStateCollectionBindings.AddComputeVariants](/engine/7000.0/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addcomputevariants.md), but uses the provided global keywords instead of the global shader keywords that are currently enabled.

Additional Resources: [GraphicsStateCollection.AddComputeVariant](/engine/7000.0/script-reference/unityengine/rendering/graphicsstatecollection/addcomputevariant.md)
