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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

ColorMask override impossible in surface shader

Discussion in 'Shaders' started by brianchasalow, Jan 19, 2019.

  1. brianchasalow


    Jun 3, 2010
    While working on a project recently, I wanted to change the ColorMask in a surface shader. I recall this being an issue several years ago and assumed it would have been fixed by now. Turns out, this is not the case. You can theoretically view compiled / generated code from a surface shader, and then save that with a modified ColorMask, but that’s not really usable.

    I couldn’t find much info on the forums about this particular issue. Curious if anyone else has run into this, or if a graphics engineer from Unity would like to comment on it. Thanks!
  2. bgolus


    Dec 7, 2012
    Surface shaders do a lot of stuff that can't be overridden. Unfortunately it's just the nature of surface shaders. I generally avoid using them these days for that reason, or just assume I'm using a surface shader to do an initial "layout" and that I'll be using the modified generated code.
  3. MUGIK


    Jul 2, 2015
    That's genius! For some reason, I had never thought about using generated code of surface shader. Now it's easy peasy to set proper ColorMask. Thanks!

    For anyone else: You can view the generated code of surface shader, copy it, and paste in a new shader file with proper name.
    Select your surface shader in Project View. In the inspector you should have this: