AddGraphicsStates
Generates and adds new graphics states to the collection from arrays of assets.
Read time 4 minutesLast updated 11 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Rendering
- Assembly: UnityEngine.CoreModule
AddGraphicsStates(Mesh[], Material[], int, NativeArray<AttachmentDescriptor>, NativeArray<SubPassDescriptor>, int, int, int)
Generates and adds new graphics states to the collection from arrays of assets.
public bool AddGraphicsStates(Mesh[] meshes, Material[] materials, int samples, NativeArray<AttachmentDescriptor> attachments, NativeArray<SubPassDescriptor> subPasses, int subPassIndex = 0, int depthAttachmentIndex = -1, int shadingRateIndex = -1)
Parameters
An array of meshes to generate graphics states from. This array must be the same length as the array.
materialsAn array of materials specifying the shader variant(s) for each generated graphics state. This array must be the same length as the array.
meshesThe number of samples per pixel in this rendering configuration.
The array of color attachments used in this rendering configuration.
The array containing information of each subpass.
The index of the active subpass in this rendering configuration.
The index of the attachment to be used as the depth/stencil buffer for this rendering configuration.
The index of the attachment to be used as the shading rate image for this rendering configuration.
Returns
Type | Description |
|---|---|
| bool | True if at least one new graphics state was successfully added, false otherwise. |
Remarks
This method creates and attempts to add graphics states by processing arrays of assets. This is a convenient way to populate the collection without constructing each GraphicsStateCollection.GraphicsState object manually. Each GraphicsStateCollection.GraphicsState is populated with data from the mesh, render state, and render pass, and sets any remaining fields to their default values. To set remaining fields to specific values instead, use GraphicsStateCollection.AddGraphicsStatesFromReference.
-
When you provide a VisualEffectAsset array, this function scans each asset to get pairs of shaders and geometry used in the render outputs.
For each individual pair, the function generates graphics states for all combinations of that mesh's submeshes and that material's shader passes. The generated shader variants use the set of enabled keywords for each Material and include the global shader keywords that are currently enabled in the active context if they are not explicitly provided. Finally, the function will not add a graphics state if an identical one already exists for a given shader variant.
If a list of GraphicsStateCollection.GraphicsState objects is already available, then GraphicsStateCollection.AddGraphicsStateForVariant can instead be used to add to the collection.
Additional Resources: GraphicsStateCollection.AddGraphicsStatesFromReference, GraphicsStateCollection.AddGraphicsStateForVariant, CommandBuffer.BeginRenderPass.
AddGraphicsStates(Mesh[], Material[], GlobalKeyword[], int, NativeArray<AttachmentDescriptor>, NativeArray<SubPassDescriptor>, int, int, int)
Generates and adds new graphics states to the collection from arrays of assets.
public bool AddGraphicsStates(Mesh[] meshes, Material[] materials, GlobalKeyword[] globalKeywords, int samples, NativeArray<AttachmentDescriptor> attachments, NativeArray<SubPassDescriptor> subPasses, int subPassIndex = 0, int depthAttachmentIndex = -1, int shadingRateIndex = -1)
Parameters
An array of meshes to generate graphics states from. This array must be the same length as the array.
materialsAn array of materials specifying the shader variant(s) for each generated graphics state. This array must be the same length as the array.
meshesAn array of GlobalKeyword objects to use in conjunction with each material's enabled keywords when generating shader variants.
The number of samples per pixel in this rendering configuration.
The array of color attachments used in this rendering configuration.
The array containing information of each subpass.
The index of the active subpass in this rendering configuration.
The index of the attachment to be used as the depth/stencil buffer for this rendering configuration.
The index of the attachment to be used as the shading rate image for this rendering configuration.
Returns
Type | Description |
|---|---|
| bool | True if at least one new graphics state was successfully added, false otherwise. |
Remarks
This method creates and attempts to add graphics states by processing arrays of assets. This is a convenient way to populate the collection without constructing each GraphicsStateCollection.GraphicsState object manually. Each GraphicsStateCollection.GraphicsState is populated with data from the mesh, render state, and render pass, and sets any remaining fields to their default values. To set remaining fields to specific values instead, use GraphicsStateCollection.AddGraphicsStatesFromReference.
-
When you provide a VisualEffectAsset array, this function scans each asset to get pairs of shaders and geometry used in the render outputs.
For each individual pair, the function generates graphics states for all combinations of that mesh's submeshes and that material's shader passes. The generated shader variants use the set of enabled keywords for each Material and include the global shader keywords that are currently enabled in the active context if they are not explicitly provided. Finally, the function will not add a graphics state if an identical one already exists for a given shader variant.
If a list of GraphicsStateCollection.GraphicsState objects is already available, then GraphicsStateCollection.AddGraphicsStateForVariant can instead be used to add to the collection.