Opal is a sedimentary stone. Under proper conditions, water percolates through the earth, becoming rich in dissolved silicates. When it enters a cavity, the silicates are deposited as tiny spheres. If they are uniform in size and shape, they will diffract light. If they are random in shape and arrangement, we have common opal.opal

... Volcanic ash gives black opal its color, but inclusions have nothing to do with the play of color. That is due entirely to the tiny spheres. They must be smaller than 1500 angstroms for blue and violet colors, but no larger than 3500 angstroms to produce oranges and reds. To put that in perspective, 20,000 spheres are about the size of the period at the end of this sentence.
... Opal grows by filling in cavities, regardless of their shape. Hence, we have many pseudomorphs, materials with shapes that are unrelated to the chemical content. The most common are opalized wood and seashells.