Eventually the red giant sheds its outer layers of gas , which become a planetary nebula , while the core cools and contracts into a compact , dense white dwarf .
Eventually the red giant will lose its outer layers of gas , which will become a planetary nebula , while the inside of the star ( also known as the core ) will cool and shrink into a small , very heavy white dwarf .