Search Unity

Is there a "Material" equivalent for exposing parameters on Compute Shaders

Discussion in 'Shaders' started by pakfront, Sep 29, 2019.

  1. pakfront

    pakfront

    Joined:
    Oct 6, 2010
    Posts:
    551
    I have a compute shader with a number of parameters I would like to be able to adjust in the Editor's Inspector. Obviously I can write a ScriptableObject or MonoBehaviour with an Editor extension to do that and hardcode all the parameters. But that is essentially what a Material does automatically.

    Is there a way to use a Material to set parameters on a compute shader (or an instance of), or an equivalent to Materials for compute shaders?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    You could just make public variables (or mark them with [SerializeField]) and then set those in the code when you call your compute shader in Update, for example. I do it that way. I don't see why you would have to use specifically Material to control this? You can have color pickers and enums etc. visible in the properties.
     
  3. pakfront

    pakfront

    Joined:
    Oct 6, 2010
    Posts:
    551
    Thanks, I'm aware I can do that, was just hoping there was a system in place for automatically exposing parameters.