Creating metal in a shader

Just for the fun of it … I could probably go all out and do some crazy stuff, but just in case people would use this as a starter for something!

  • The selected nodes (orange) show what I’ve added in addition to the lecture
  • Here’s my train of thought, more or less
    • Mix node (bottom) → I wanted to pick a color “based on something” to basically show the wooden texture in some areas, but then have some metal in other places
    • Separate XYZ and Color Ramp → to determine this “something”: the separate allows me to only pick the X-component from my UVs (because, in my UV-unwrap, the “up-and-down” parts of my barrel run from left to right) … The color ramp then translates this: everything below 0.1 or above 0.9 gets alpha 0, everything else gets alpha 1
      • so now that mix node will pick my texture from 10% up to 90% up the barrel
    • Multiply Add → step 2, I want to use 0 and 1 to set “metallic”, but the values had to be turned around so I multiply all by “-1” (so I get 0 and -1) and I add “1” (so I get 1 and 0) … Now my metal bands are metallic
    • Float Curve → step 2, I want to set the roughness; I could just plug in that alpha value but then my metal is fully smooth and my wood is fully rough; with my float curve I basically set the metal roughness at the left side, and the wood roughness at the right side (the rest of the curve actually doesn’t matter)


I’m pretty sure there are better nodes for doing the things I’m trying to do (or even use different approaches to achieve the same) … Of course I could also just add a 2nd material (which is probably the “logical” solution here, I just wanted to play around to see if it’s at all possible); obviously here I have the freedom of playing with values somehow (maybe the line between metal and wood should be more wavy and irregular? Could be harder to do with just adding a material).

I could also plug in an actual metal texture instead of providing that dark grey color … There may even be a smart math method to get a metal border in the top and bottom parts. The possibilities are endless :smiley:

1 Like

Nice solution.

You could also do:

  • Add multiple materials to the object and assign them to specific faces
  • Create besides a diffuse map (colors) a roughness map

Privacy & Terms