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

Override Shaders instead of Materials for Custom Pass

Discussion in 'Universal Render Pipeline' started by Toesty5, May 3, 2022.

  1. Toesty5

    Toesty5

    Joined:
    Oct 2, 2017
    Posts:
    2
    Hi there! I'm using custom render passes in URP on 2020.3.33f1 to make a shader that has sketchy lines in shadowed areas. I have been using overrideMaterial in my pass to render everything with a lit white material to make a global texture that essentially has the shadow information in the scene.

    However, I want to combine it with per-object textures as well! I have been struggling with this because whatever material I use in overrideMaterial does not have unique settings per object, since it's just a single material. What I would like to do instead is override the shaders of my objects, so they could keep their individual material settings with a different shader. I have looked into the SetReplacementShaders method, and it seems like it would do what I need, but apparently URP does not support it.

    Is there another way for me to apply specific shaders to objects? Is there a way I can give objects the override material I want, while keeping their textures? Thanks!
     
    Tamago-Jam likes this.
  2. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    295
    the object render feature of 2022.2 supports using a shader as an override. However I think it breaks srp batching...
     
    Toesty5 likes this.
  3. Toesty5

    Toesty5

    Joined:
    Oct 2, 2017
    Posts:
    2
    Thank you! I'll check it out.