Search Unity

How do I change a default material and shader for my render pipeline?

Discussion in 'General Graphics' started by ArtyIF, Aug 18, 2019.

  1. ArtyIF

    ArtyIF

    Joined:
    Oct 13, 2014
    Posts:
    36
    Unity's HD and lightweight/universal render pipelines are somehow able to change the default material. For example, when you create an object through Create -> 3D Object in Hierarchy window, it already has a default material on it. They do the same with materials - any new materials you create have their shader assigned to it.

    I want to do the same thing for my pipeline. However, after looking in their source code the only thing I found is how they upgrade materials through menus. For now I have a pretty messy workaround after searching stuff in the script reference (I have a class that inherits UnityEditor.AssetModificationProcessor, which adds an asset string to a static list in a class that inherits UnityEditor.AssetPostprocessor when user is about to create an asset if it ends with .mat, then the asset postprocessor replaces the shader when it post-processes all assets. It also uses OnPostprocessMaterial, but it works only in models), but IIRC it doesn't have the same result.

    So, how do I properly change a default material and a default shader to my own?
     
  2. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
  3. ArtyIF

    ArtyIF

    Joined:
    Oct 13, 2014
    Posts:
    36
    Oh! I'm dumb. At first I did find these properties, but thought that they aren't referenced anywhere else. But I decided to check the script reference for RenderPipelineAsset and it turns out that it has some overridable properties. Thanks a lot!
     
  4. Piedpiperz80

    Piedpiperz80

    Joined:
    Mar 10, 2014
    Posts:
    4
    I don't get it...
     
    IPG2 likes this.
  5. Zee100

    Zee100

    Joined:
    Oct 11, 2012
    Posts:
    3
  6. tw00275

    tw00275

    Joined:
    Oct 19, 2018
    Posts:
    92
    Zee100 likes this.