Global Illumination with THETA and Unity

After stumbling through some outdated tutorials, I finally figured out how to use an equirectangular 360 image as a skybox in Unity. It’s pretty cool (and surprisingly simple) - if you do it right, you should see the colors of the 360 image reflected on any CGI object you put into the scene, which will make the object look more real. If you start getting interested in this, you’re going to end up reading plenty about physically-based rendering (PBR) and global illumination (GI).

Physically-Based Rendering

This has to do with the behavior of light and the surfaces it hits. What it really comes down to is reflection. When light hits an object, some of that light is absorbed, which is light that we don’t see. The light we do see is the light that’s been reflected by the object’s surface - for example, my wireless mouse is blue because that’s the part of the light spectrum it doesn’t absorb, in other words the light that’s been reflected. The kind of reflection we usually picture when we think “reflection” - light that has been reflected at a direct angle, without penetrating the surface - is called “specular reflection.”

So some of the light that hits an object gets reflected, and some of it gets absorbed. But there’s another kind of reflection, called “diffuse” reflection, that’s somewhere in the middle. Here the light makes its way past the surface of the object, but then gets scattered back through the surface in an indirect manner, becoming visible to us. Diffuse light like this is softer than specular light. Highly reflective surfaces have very little diffuse light, because very little light has managed to penetrate the surface before scattering.

Here’s a much more in-depth look at PBR

Global Illumination

PBR and GI go hand in hand. GI has to do with aspects of reflected light, like color bleeding. When light hits a surface and gets reflected, that reflected light carries some of the color from the surface of the object with it, imparting it to the next surface it comes in contact with. This continues until the light gets absorbed, which can lead to a kind of chain of reflections that can make for some pretty complex lighting if you’re gunning for a photorealistic CGI scene.

If you want to learn more about global illumination, you can look at this GI Tutorial

THETA for Skybox and Global Illumination in Unity

A “skybox” is basically what you use in a CGI scene as a background. To make my skybox, I took this image I shot with the THETA and dropped it into Unity.

All you have to do is drag and drop the image into Unity, and it will show up in the “Assets” section of the screen. When it does, set its “texture type” to “Cubemap” and hit “Apply.”

After that processes, head up to the menu tabs and click on “Assets,” then scroll down to “Create” and click on “Material.” Once you have your new material, set the “Shader.” Scroll down the menu to “Skybox” and click “Cubemap.”

After you do that, there should be a a box that reads “None (Cubemap).” That’s where you want to drag and drop your equirectangular image.

Click your new material in the “Assets” box and drop it into the scene. If you’ve done these steps correctly, you should end up with something like this.

Now you can see if your skybox is working in terms of GI, if the colors of the skybox will be reflected in CG object that you drop into the scene. Head up to “GameObject” and scroll down to “3D Object,” then click on “Sphere.”

You might want to make the sphere bigger using the “scale” X, Y, and Z input boxes. This will help you see the reflected colors more clearly. I set all of mine to 5. If you don’t have a directional light in your scene (although you probably started with one) the sphere will look something like this.

You can see how the lower part of the sphere is tinted orage (from the boat) while the rest of it is tinted blue (from the water and sky). If you don’t have a directional light, you can add one by clicking “GameObject,” scrolling to “Light,” and clicking “Directional Light.” I moved mine up to where the sun is in my skybox.

This will help make your sphere more realistic, like it’s actually in the scene.

You can mess with the “Intensity” of the directional light to change how washed out the sphere is, but there you have it! You’ve managed to get a CG sphere to reflect the colors of your THETA skybox! You’ve single-handedly managed to bridge the divide between computer graphics and reality.

If you’re interested in doing more projects with THETA and Unity, take a look at using THETA live view with Unity and this demo of WiFi streaming with THETA and Unity

##THETA Developer Ecosystem Registration

1 Like

Nice. Consider making a screencast style video tutorial of this as well and
upload it to our new YouTube channel

I used OBS for my first tutorial, but there are many alternatives out
there. OBS is free and open source.

Do you have a technique for navigating the skybox? I’ve been using FPSController, but am wondering if there’s a better technique. With my technique, I need to have the player on a plane to walk around on. Is there a way to just move the view of the skybox with mouse or arrow keys when the application is being played? If you don’t play the application, do you export the image as a jpeg? What do you do with the image?

I had plenty of trouble navigating the skybox, too. I found this in the Unity manual:

Use Flythrough mode to navigate the Scene View by flying around in first-person, similar to how you would navigate in many games.

  • Click and hold the right mouse button.
  • Move the view around using the mouse, the WASD keys to move left/right/forward/backward, and the Q and E keys to move up and down.
  • Hold down Shift to move faster.

Holding the right mouse button lets you pivot on the point you’re on, and the keyboard lets you move in any direction.

1 Like

Thanks. This works. This article has some info on optimizing the use of the right mouse button with special mice. I’m using a Evoluent vertical 5-button mouse and have mapped the button.

I tested it out on a scene my daughter created. You can see her in the background. Maybe you can insert Hercules AND a 3D cat in a single scene.

Do you have some 360 images of your cat?