Adding rings to Saturn

Saturn's rings have a diameter of about 282,000 km and are about 2.35 times the diameter of Saturn, the planet (282,000 / 120,000). We have a texture, saturn_rings.png, that we can render on a flat plane to display as rings. In Unity, a 1x-sized plane actually measures 10 units across. So, we will set the plane's Scale to 0.235.

For the rings to have transparency, we can change Rendering Mode to Cutout. This will use the alpha channel of the image as a threshold to determine whether that pixel of the texture is displayed or not. The shader lets you choose the Alpha Cutoff value as shown ahead:

  1. In Hierarchy, right-click on Saturn, then 3D Object | Plane.
  2. Choose Transform Reset, then scale to (0.235, 0.235, 0.235).
  3. Import saturn_rings.png into SolarSystem/Textures and drag saturn_rings onto the SaturnRings object.
  4. Open its material, then uncheck Specular Highlights and Reflections.
  5. Change Rendering Mode to Cutout.
  6. Adjust Alpha Cutoff to something like 0.3.

The resulting settings are shown in the following screenshot. Now, we have Saturn rings.

However, if you have an issue, if you look at them from underneath (pan or rotate the view in the Scene window), you'll see that they disappear. This is because the plane is only rendered on its front-facing side (this is an optimization in computer graphics, called back-face culling, which determines whether a polygon of a graphical object is visible). To resolve the issue, we could write a custom shader that does not perform back-face culling. Instead, we will duplicate our rings and flip them over for the underside.

  1. Right-click on SaturnRings and select Duplicate (or Ctrl+D).
  2. Set its Transform Rotation to X = 180.

Saturn with its double-sided rings is shown in the following screenshot:

Note that our rings rotate with the planet. If you want to correct this, you could make a SaturnAndRings parent and move the rings so they are no longer a direct child of the planet, similar to what we did for earth-moon.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset