I would imagine most of the coloration is genetically contributed, similar to humans. While we primarily have one type of pigment (in the form of the pigment-containing cells, melanocytes), chameleons have, I believe, four (iridophores, melanophores, erythrophores, and xanthophores). Similar to how our skin color resembles a mix between our parents, so too should chameleons. There's is just a little bit more complex, but their pigments originate from the same transient stem cell type as ours. The individual variation is then due to the particular way the chameleons' parents' DNA recombines during embryogenesis, which leads to the unique color pallets we see in our chams!
As for environmental contribution, these changes typically occur over a larger time scale ("evolutionary time") and act as adaptations to changing environments. I could be wrong, but I doubt their particular environment affects particular chameleons' innate markings on such a short timeline.