# AddGraphicsStatesFromReference

> Generates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values.

## Definition

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

## AddGraphicsStatesFromReference(GraphicsStateCollection, GraphicsState, VisualEffectAsset\[], int, NativeArray\<AttachmentDescriptor>, NativeArray\<SubPassDescriptor>, int, int, int)

Generates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values.

```csharp
public static bool AddGraphicsStatesFromReference(this GraphicsStateCollection graphicsStateCollection, GraphicsStateCollection.GraphicsState refState, VisualEffectAsset[] visualEffectAssets, int samples, NativeArray<AttachmentDescriptor> attachments, NativeArray<SubPassDescriptor> subPasses, int subPassIndex = 0, int depthAttachmentIndex = -1, int shadingRateIndex = -1)
```

### Parameters

**** (\[GraphicsStateCollection]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection)): The GraphicsStateCollection in which to add the graphics state.**** (\[GraphicsState]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate)): The reference [GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) to use as a template for initializing unspecified values.**** (\[VisualEffectAsset\[]]\(/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset)): An array of [VisualEffectAsset](/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset.md) files to scan for each unique mesh and shader pairs.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of samples per pixel in this rendering configuration.**** (\[NativeArray\<AttachmentDescriptor>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The array of color attachments used in this rendering configuration.**** (\[NativeArray\<SubPassDescriptor>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The array containing information of each subpass.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the active subpass in this rendering configuration.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the attachment to be used as the depth/stencil buffer for this rendering configuration.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the attachment to be used as the shading rate image for this rendering configuration.

### Returns

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

### Remarks

This function operates like [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), but instead of using default values for [GraphicsStateCollection.GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) fields, it copies values from the provided `refState` for any fields not determined by the input parameters.

Additional Resources: [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), [CommandBuffer.BeginRenderPass](/engine/6000.7/script-reference/unityengine/rendering/commandbuffer/beginrenderpass.md)

## AddGraphicsStatesFromReference(GraphicsStateCollection, GraphicsState, VisualEffectAsset\[], GlobalKeyword\[], int, NativeArray\<AttachmentDescriptor>, NativeArray\<SubPassDescriptor>, int, int, int)

Generates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values.

```csharp
public static bool AddGraphicsStatesFromReference(this GraphicsStateCollection graphicsStateCollection, GraphicsStateCollection.GraphicsState refState, VisualEffectAsset[] visualEffectAssets, GlobalKeyword[] globalKeywords, int samples, NativeArray<AttachmentDescriptor> attachments, NativeArray<SubPassDescriptor> subPasses, int subPassIndex = 0, int depthAttachmentIndex = -1, int shadingRateIndex = -1)
```

### Parameters

**** (\[GraphicsStateCollection]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection)): The GraphicsStateCollection in which to add the graphics state.**** (\[GraphicsState]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate)): The reference [GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) to use as a template for initializing unspecified values.**** (\[VisualEffectAsset\[]]\(/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset)): An array of [VisualEffectAsset](/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset.md) files to scan for each unique mesh and shader pairs.**** (\[GlobalKeyword\[]]\(/engine/6000.7/script-reference/unityengine/rendering/globalkeyword)): An array of [GlobalKeyword](/engine/6000.7/script-reference/unityengine/rendering/globalkeyword.md) objects to use in conjunction with each material's enabled keywords when generating shader variants.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of samples per pixel in this rendering configuration.**** (\[NativeArray\<AttachmentDescriptor>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The array of color attachments used in this rendering configuration.**** (\[NativeArray\<SubPassDescriptor>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The array containing information of each subpass.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the active subpass in this rendering configuration.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the attachment to be used as the depth/stencil buffer for this rendering configuration.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the attachment to be used as the shading rate image for this rendering configuration.

### Returns

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

### Remarks

This function operates like [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), but instead of using default values for [GraphicsStateCollection.GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) fields, it copies values from the provided `refState` for any fields not determined by the input parameters.

Additional Resources: [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), [CommandBuffer.BeginRenderPass](/engine/6000.7/script-reference/unityengine/rendering/commandbuffer/beginrenderpass.md)

## AddGraphicsStatesFromReference(GraphicsStateCollection, GraphicsState, VisualEffectAsset\[])

Generates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values.

```csharp
public static bool AddGraphicsStatesFromReference(this GraphicsStateCollection graphicsStateCollection, GraphicsStateCollection.GraphicsState refState, VisualEffectAsset[] visualEffectAssets)
```

### Parameters

**** (\[GraphicsStateCollection]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection)): The GraphicsStateCollection in which to add the graphics state.**** (\[GraphicsState]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate)): The reference [GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) to use as a template for initializing unspecified values.**** (\[VisualEffectAsset\[]]\(/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset)): An array of [VisualEffectAsset](/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset.md) files to scan for each unique mesh and shader pairs.

### Returns

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

### Remarks

This function operates like [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), but instead of using default values for [GraphicsStateCollection.GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) fields, it copies values from the provided `refState` for any fields not determined by the input parameters.

Additional Resources: [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), [CommandBuffer.BeginRenderPass](/engine/6000.7/script-reference/unityengine/rendering/commandbuffer/beginrenderpass.md)

## AddGraphicsStatesFromReference(GraphicsStateCollection, GraphicsState, VisualEffectAsset\[], GlobalKeyword\[])

Generates and adds new graphics states from arrays of assets, using a reference graphics state to initialize unspecified values.

```csharp
public static bool AddGraphicsStatesFromReference(this GraphicsStateCollection graphicsStateCollection, GraphicsStateCollection.GraphicsState refState, VisualEffectAsset[] visualEffectAssets, GlobalKeyword[] globalKeywords)
```

### Parameters

**** (\[GraphicsStateCollection]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection)): The GraphicsStateCollection in which to add the graphics state.**** (\[GraphicsState]\(/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate)): The reference [GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) to use as a template for initializing unspecified values.**** (\[VisualEffectAsset\[]]\(/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset)): An array of [VisualEffectAsset](/engine/6000.7/script-reference/unityengine/vfx/visualeffectasset.md) files to scan for each unique mesh and shader pairs.**** (\[GlobalKeyword\[]]\(/engine/6000.7/script-reference/unityengine/rendering/globalkeyword)): An array of [GlobalKeyword](/engine/6000.7/script-reference/unityengine/rendering/globalkeyword.md) objects to use in conjunction with each material's enabled keywords when generating shader variants.

### Returns

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

### Remarks

This function operates like [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), but instead of using default values for [GraphicsStateCollection.GraphicsState](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection/graphicsstate.md) fields, it copies values from the provided `refState` for any fields not determined by the input parameters.

Additional Resources: [VFXGraphicsStateCollectionBindings.AddGraphicsStates](/engine/6000.7/script-reference/unityengine/vfx/vfxgraphicsstatecollectionbindings/addgraphicsstates.md), [CommandBuffer.BeginRenderPass](/engine/6000.7/script-reference/unityengine/rendering/commandbuffer/beginrenderpass.md)
