In this video we're going to introduce Dynamic Lighting, a method of lighting models and materials in realtime as opposed to baking lighting into their textures.
Dynamic lighting is an awesome way to get your 3D models looking more realistic.
Following this simple example you'll learn about the different lighting material types as well as the different types of lights that can be placed in your scene.
Before we dive into Studio we're going to take a closer look at the 3D model we'll be using in this demo.
While models with baked lighting will often use a single texture, the Standard Lighting Material can be composed of up to 7 different textures, each describing how the surface of the model will react to lighting. For more information on how the different texture maps effect the model, please check out our Lighting Materials documentation.
The model we'll be using is of an engine and has been created with all 7 textures in mind, though you don't need to include all of them when making your own models. As the number of textures for a model can greatly increase when using lighting materials it's worth bearing that in mind when trying to keep your filesize down, lowering the resolution of the textures where possible is a must.
Importing a Model
Here we have a project with a tracking image already trained and placed in the Hierarchy ready for our model to be placed on it.
We're going to import our model by dragging the
FBX file into the Media Library import box and giving it a name. We highly recommend the
FBX filetype when exporting your model to ensure all textures are correctly identified during the import process.
We're then presented with an import window that lets us select the material we want to use. By default the Unlit Material is selected but we want to use the Standard Lighting Material.
When we select our material the import panel is then updated to show all the detected textures. We can drag all of our textures at once into the import box at the top, this will then begin to assign the textures and update the 3D model preview on the right. When this is completed we can see how our model is going to look and can then hit finish.
Placing a 3D Model on a Tracking Image
Dragging the model subsymbol into the tracking image node in the Hierarchy and rotating it by 90 degrees in the x-axis will place our model nicely on top of the image.
Emissive Maps and Simulated Light
You've probably noticed that the majority of the model is black, this is because there are currently no lights in our scene to light the model. The red wires that you can see are the part of the model defined by the emissive texture map, which defines areas of the object's surface that appear self-illuminated.
We can quickly light the rest of the model by clicking the lightbulb dropdown above the 3D view and selecting Add simulated light if none in Hierarchy. This is a handy setting for previewing what your model will look like in the 3D view before you've added any lights to your Hierarchy. Once we add a light to the Hierarchy this simulated light will then be removed.
Note that the simulated light will not appear in the app so if we were to preview or publish this experience right now the model would appear unlit like we saw before.
Adding a Directional Light
We're now ready to add our first light and we can do so by right-clicking on our tracking image and selecting New > Lights > Directional Light and selecting OK. This right-click menu can be accessed from any group node including the root node, we selected the tracking image as we want the light tracked to the image so we can demonstrate it better.
A directional light simulates a strong distant light source and is often used to represent sunlight. The position of a directional light does not affect the light on a model but the rotation does.
Before we add any further lights we're going to make our directional light invisible.
Adding a Point Light
Next we'll add a point light from the same right-click menu. A point light simulates a light source emitting equally in all directions from a centre point and is a great way to represent a candle or lamp.
A point light's position and range, accessible from the Property panel, determine its effect on lighting in the scene; its rotation has no impact.
Let's now make this point light invisible before adding the final light in this tutorial.
Adding a Spot Light
The final light we're going to cover is the spot light that simulates a direct light source emitting light through a cone. Spot lights are used to represent their real life counterparts as well as flashlights and other artificial light sources.
A spot light's angle and range determine the area of illumination.
Setting the other two lights back to visible we can see how all three interact with the model together. It is recommend to keep the number of lights in a scene to under 5 as each light interacting with a model increases the computational effort it takes to run the experience.
Light Color and Intensity
The last thing we're going to look at is the Light Color and Intensity properties that these three lights all have.
With the Light Color property we can change the color of the light.
The Intensity property allows us to increase or decrease the brightness of the light.
We've now successfully added a model that supports dynamic lighting and added a few lights to the scene and can preview our experience, rotating the tracking image to show off the lights.
Dynamic lighting comes with a whole bunch of new settings, materials and node types, not all of which have been covered here, so we highly recommend you check out our Lighting documentation for more info.