Shininess is based on a Pokemon's Trainer ID, Secret ID and Personality Value.

The equation used is:

>(TrainerID xor SecretID) xor (PersonalityValue*>>16 xor (PersonalityValue** mod 65536))*

First 16 bits of PV.

**Last 16 bits of PV.

I don't understand what any of that says, but the resulting number of that equation is a number between 0 and 65355. If the result of the equation is 8 or below, it's shiny. That's an 8/65355 chance of it appearing, or more commonly known as 1/8192.

You can't really control it, but that's the science behind the Shiny Pokemon in in Gen III.

Hope I helped. :)

Source