Adding Lighting
Last updated
Last updated
Lighting plays a huge part in the appearance of a space. The issue is that real time lighting, or lighting that is processed every frame, is very expensive. Getting a balance between lighting quality that runs well is an art in itself.
Note that it is recommended to use no more than 4 realtime lights in a space. Usually 1-2 is enough. We will take a quick look at alternative approaches to more performant lighting towards the end.
Unity has a number of light types to use in your scene. These include the following :
A Directional Light is the most performant. And is light coming from one direction.
A Point Light is light coming from one point.
A Spot Light is a light that looks like a spotlight.
An Area Light is more like a rectangle or oval of light. Note that this light is only used for Baked lighting which we’ll get into with the Lightmapping section.
You can of course edit the directional light that is present in the Mona SDK space. Otherwise you can add your own.
Right click on an asset location in the hierarchy window.
Under ‘Light’ you will have access to the lights mentioned.
Once you have added the light you can use the standard position and rotation tools, as well as modify its settings in the Inspector. Each light is slightly different but most have the same aspects such as Color, Range, Mode, Intensity, and Shadow Type.
Color is exactly that. What color is the light.
Range, depending on the light type, is how far do you want the light to travel.
Intensity is how strong the light is.
Shadow type is what kind of shadows, if any, does the light project. No shadows are the most performant of course. Hard shadows are a little more performant than soft shadows, but don’t look as nice.
Mode is used when setting if the light is Realtime. Baked is used for lightmapping. Mixed is both realtime and baked.
There are others but we will save those for another time.
If you want an even better lighting result, that doesn’t cost as much in performance, you can use Lightmapping. Lightmapping is a technique that creates, or bakes, light information into textures. Spaces will run better and look great, at the expense of filesize.
You may recall using UVs to assign where the texture goes on an 3D model, lightmapping will bake the light information into a 2nd UV map that you can make manually in your 3D Creation tool, or Unity can create it for you.
The only issue with lightmaps is that they are static, meaning they cannot change. So dynamic objects, such as the avatars or animated objects, do not cast a shadow in realtime with this lighting information. A good compromise is creating a single directional light that casts a shadow, with much more complicated lighting being baked into the lightmap. This is the best of both worlds.
Note that only realtime lights will light dynamic objects. Lightmaps will not be considered.
You can work around this by adding light probes. Light probes can be placed around the space to take in the light information at that point in space, and light dynamic objects accordingly. This would allow a space that has no realtime lights to light dynamic objects properly.
The last thing to add into this section, which is on par with lighting but not exactly part of lighting, is reflection probes. Realtime reflections are very expensive, and generally not recommended to use in WebGL based spaces at all. It is best to use reflection probes to once again bake the information into a texture to reflect onto assets in the space and keep performance at the cost of filesize.
Reflection probes use the physics based rendering techniques in the materials to show polished and metallic surfaces well.
Lightmapping, lightprobes, and Reflection probes are not recommended for your first space due to the complexity that they bring, but they are good to know about for when you feel like creating better visuals in your space.
For more information on lightmapping, go to Lightmaps (Unity Lightmapper).
For more information on light probes, go to Light Probes.
For more information on reflection probes, go to Reflection Probes.
In this tutorial we looked at the different light types, how to add them to the scene and how to modify them. We also introduced lightmapping, light probes, and reflection Probes so that you know what to look for when you are ready to take your lighting to the next level.