Search Unity

Question How Do I Display A Material's Inspector Fields In A Renderer Feature?

Discussion in 'General Graphics' started by QuariYune, May 22, 2023.

  1. QuariYune

    QuariYune

    Joined:
    Jul 1, 2021
    Posts:
    20
    I'm creating a post process effect that uses ScriptableRendererFeatures and ScriptableRenderPasses. I'd like to create a material using CoreUtils.CreateEngineMaterial, that way I don't need to create a material asset and hook it up to the renderer feature every time I reuse this code.

    But I'd also like to have the ability to change and save shader property values in the material's inspector. I don't want to have to rely on creating another class for renderersettings and setting each shader property one by one in a c# script, nor does the post processing really need to use volumes at the moment. It would be nice to just have access to the underlying material in the inspector.

    Is there any way to do this?

    On a side note: Would this actually work? I noticed in documentation the ScriptableRendererFeature.Create function gets run every time serialization happens. If I were to create the engine material in that function, and got shader properties to show in the inspector, would those values actually serialize and transfer over to the newly created CoreUtils.CreateEngineMaterial? Or would I need to save the material in the ScriptableRendererFeature class and null check so CreateEngineMaterial doesn't run again? If so, are there any things to watch out for with this caching?