I recently rewrote a shared I was using into Shader Graph. As an example I carried out the color as an external parameter.

In my traditional shader to set the color I would call something like

MyMaterial.SetColor("_NewColor", color)

In the new code, I could not figure out the name of the parameter until I looked at the generated code. Turns out my Color parameter was actually named "Color_D027E98" So now my code is

MyMaterial.SetColor("Color_D027E98", color);

Not very pretty and I don't know how constant D027E98 is. Is this the correct way of changing a shader's parameter? Should I be doing something different using Shader Graph - Is this number going to change on me as if I update my shader?

  • \$\begingroup\$ Based on this question, Shader Graph makes me sad. Shader Forge at least let you name nodes intelligently so that you actually knew what they were for precisely this purpose. \$\endgroup\$ – Draco18s no longer trusts SE May 29 '18 at 14:24
  • \$\begingroup\$ @Draco18s I am guessing shader forge won't work with the new pipeline, this is the future. Also shader forge did not seem to work for me \$\endgroup\$ – Andrey May 29 '18 at 14:45
  • \$\begingroup\$ From the title this looked like a duplicate of Unity Shader Graph, set blackboard properties from code, but from your description it sounds like you're actually asking "How to control names assigned to parameters in a shader graph" or something similar. Is that accurate? \$\endgroup\$ – DMGregory May 29 '18 at 16:26
  • 1
    \$\begingroup\$ @DMGregory I did miss that question. I does at least answer my question to the fact that the name is persistent., What I am really asking is what is the right way of working with it. Having the weird code name that you have to get out of source feels very ugly \$\endgroup\$ – Andrey May 29 '18 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.