Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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.