Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Set compute shader threads from C#?

Discussion in 'Shaders' started by TheCelt, Mar 20, 2019.

  1. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    741
    Is it possible to set compute shader numthreads from the C# side ? I know we can dispatch groups but seems threads is not a dynamic option?

    For example for an image i process i use [numthreads(1,16,1)] but i would like the y term to change depending on the image size... is that possible?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    the number of threads is a static thing in the kernel
    you can make several kernels if you want it to be more flexible
     
    acnestis likes this.
  3. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    741
    Ah i guess thats a simple enough solution to the problem, thanks.