# All that doesn't glitter isn't gold

I would like to color some objects in metallic shades like gold and silver. Various web sources suggest that the gold is a variant of yellow with RGB values 83.14% red, 68.63% green, and 21.57% blue. Similarly, silver is claimed to be a variant of grey with 75.3% of each red, green, and blue. However, when I try to color disks with these values, the representation is more dull-yellow and flat-grey than metallic silver or gold:

gold = RGBColor[0.8314, 0.6863, 0.2157];
silver = RGBColor[0.753, 0.753, 0.753];
Graphics[{gold, Disk[{0, 0}, 0.5], silver, Disk[{1, 0}, 0.5]}]


How can I get the colors to glitter like gold and sparkle like silver?

• “Glitter” and “sparkle” would imply that there is a light source of some sort—have you tried the new materials functionality that came with v12.3? Jun 16, 2021 at 14:55
• The real problem is that "gold" and "silver" are not colors, but specific reflectance properties (common for all "metals"). Maybe see metalbyexample.com/reflection-and-refraction or en.wikipedia.org/wiki/Reflection_(physics) Jun 19, 2021 at 9:21

Here is a possible approach using MaterialShading new in version 12.3.

It is easier to get nice results on curved surfaces like a sphere without too much input. To get a flat surface to give the results you want may require you to play with the material shade and parameters.

We will modify the example from the documentation to give an interesting result by modifying the "SurfaceNormals" and "MetallicCoefficient"to give a textured surface with variable reflection properties.

### Metallic coefficient

We need to work in 3D for the lighting to work so your disk becomes a cylinder.

sn = Import["https://i.stack.imgur.com/Bfcrl.png"];
mc = Import["https://i.stack.imgur.com/DF9Fs.png"];
Graphics3D[{MaterialShading[<|"BaseColor" -> {Hue[0.125, 1, 1], 1},
"SurfaceNormals" -> Texture[sn],
"RoughnessCoefficient" -> 0.65,
"MetallicCoefficient" -> Texture[mc] |>], Cylinder[]},
Lighting -> "ThreePoint", Boxed -> False, ViewPoint -> Top]


# Something fancier

I found this tutorial and how to create a surface normal map for a coin.

### Surface normals for a coin

We can use the same technique from above to create a gold and silver coin.

sn = Import["https://i.stack.imgur.com/DhDI7.png"];
mc = Import["https://i.stack.imgur.com/DF9Fs.png"];
Graphics3D[{MaterialShading[<|"BaseColor" -> {Hue[0.125, 1, 1], 1},
"SurfaceNormals" -> Texture[sn],
"RoughnessCoefficient" -> 0.65,
"MetallicCoefficient" -> Texture[mc] ,
"SpecularAnisotropyCoefficient" -> {0.3, 0}|>], Cylinder[]},
Lighting -> "ThreePoint", Boxed -> False, ViewPoint -> Top]
"SurfaceNormals" -> Texture[sn],
"RoughnessCoefficient" -> 0.65,
"MetallicCoefficient" -> Texture[mc] ,
"SpecularAnisotropyCoefficient" -> {0.3, 0}|>], Cylinder[]},
Lighting -> "ThreePoint", Boxed -> False, ViewPoint -> Top]


• I clicked out of curiosity and I have to say that this is a beautiful presentation of what one could do in mathematica. well done.
– alex
Oct 9, 2021 at 14:56

You could build up your own procedural texture from random stripy patterns, specks from a power-law distribution and a linear gradient:


SeedRandom[1];
d = 1024;
gold = RGBColor[0.8314, 0.6863, 0.2157];

stripes = GaussianFilter[ImageResize[
RandomImage[{1, 1.2}, {1, d}], {d, d}], 3];

Image@RandomVariate[ParetoDistribution[0.01, 5.0], {d, d}], 3];

ImageMultiply[
Image[ConstantArray[gold, {d, d}]],
stripes],
specks]
, 0.25];

Graphics[{
}]


• Tim Laska's answer, which requires working in 3D is probably the "right" way to do this, but your answer is very useful because it can be applied to 2D graphics. So while I ended up accepting Tim's answer, this is the one I ended up using so that I didn't have to redo all the already coded graphics. Thanks! Jun 21, 2021 at 11:41

I wonder if one could do a pretty simple workaround for the limits of applying a Texture to Disk.

Maybe something as simple as:

Graphics3D[{
Darker[gold],
Glow[Darker[gold]],
Sphere[]},
Boxed -> False]


You could then fool around with other Graphics3D properties like Lighting, or Opacity.

Or...

ParametricPlot3D[
0.99 {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {u, 0, 2 \[Pi]}, {v,
0, \[Pi]},
Mesh -> None,
TextureCoordinateFunction -> ({#4, 1 - #5} &),
PlotStyle -> Directive[
Specularity[gold, 500],
Texture[texture]],
Lighting -> "Neutral",
Axes -> False,
Boxed -> False]


• Your last picture looks more like the basis of a wooden ball or a simple planet than like gold to me.
– Mast
Jun 19, 2021 at 8:39