Parameter | Description |
---|---|
name | Name of kernel function as defined in the compute shader source file. |
int The Kernel index. If the kernel is not found, Unity logs a "FindKernel failed" error message and raises an ArgumentException.
Find ComputeShader kernel index.
A single compute shader can contain many "kernels" (functions that do the computation);
FindKernel returns kernel index given the name.
Additional resources: Dispatch.
using UnityEngine;
public class ComputeShaderExample : MonoBehaviour { public ComputeShader computeShader;
void Start() { // Find the kernel named "CSMain" in the compute shader int kernelHandle = computeShader.FindKernel("CSMain");
// Log the kernel index Debug.Log($"Kernel 'CSMain' found at index: {kernelHandle}"); } }