>> Welcome to another Unreal Tips and Tricks.
In this episode we'll discuss the exposure
controls available in Unreal Engine,
which will allow us to adjust exposure using settings
that accurately mimic real-world cameras.
Before we dive into those settings,
let's take a quick look at how exposure values are determined.
Exposure is simply the amount of time that light
is allowed to hit the sensor or film back of the camera
and it controls how dark or bright the final image is.
Exposure is calculated using two values, shutter speed
and f-stop or aperture diameter.
Shutter speed is simply the length of time in seconds
that the shutter stays open.
The longer it's open, the brighter the image will be,
but it will also produce more motion blur.
F-stop determines how wide the aperture is opened.
The wider the aperture, the more light is allowed in,
and thus again, a brighter image will be produced.
Keep in mind that lower f-stop values
represent wider aperture openings,
how wide the aperture is open will also affect
the depth of field of your images and finally,
ISO represents the sensitivity of your film or sensor.
Most cameras have a base ISO of 100
and this is usually the best setting to use.
Higher ISO values can brighten the image,
but they'll also cause more film grain to be noticed.
Now that we've got a basic understanding of exposure,
let's jump into Unreal Engine.
The first thing we need to do is take a look
at the Exposure Settings in our Project Settings.
You'll find these under Engine, Rendering.
Then scroll down to the Default rollout.
First up, we have Auto Exposure or eye adaptation controls.
We can enable or disable Auto Exposure
and change the method used for the entire project here.
Below this is an option that allows us
to extend the range of luminance
available for the minimum and maximum exposure values.
And finally, Pre-Exposure will apply exposure in the shaders
before the scene color is written.
This option can help improve
the quality of basic auto exposure.
Changing these options will require a restart of the Engine
and once it's restarted, shaders will likely need
to be recompiled for the project,
which can take a bit of time.
To use the exposure controls we'll either need a Camera
or a Post-Process Volume added to the scene.
In this example,
we'll be working with a post-process volume.
Be sure to set it to Unbound so that the effect is applied
whether we are inside the Volume or not.
We'll find the exposure settings
on the volume under the Lens rollout.
We'll open both Exposure and Camera
as we'll be working with both. Before we do though,
let's take a look at the viewport exposure controls.
You'll find these on the viewport view modes button
at the bottom under exposure.
Game Settings tells the viewport to use the exposure settings
as defined in the post-process volume or camera being used.
Turning this off will instead
allow us to tweak the exposure value using a simple slider.
Keep in mind that this is only a preview option for the viewport.
The setting of EV100 refers to an exposure value
using an ISO or film sensitivity of 100.
The lower the exposure value, the brighter the image will be.
Conversely, higher EVs produced darker images.
Remember the EV represents the F-stop and shutter speed.
An EV of zero represents an F-stop of one
or a wide-open aperture
and a shutter speed of one second,
producing a bright image as more light
is allowed in over a longer period.
Some other example of EVs include an EV of five
to seven for a typical home interior,
seven or eight for a typical office space,
and finally 15 for a typical outdoor sunny day.
Let's go ahead and return to Game Settings now
and discuss the options available to us
in the Post-Process Volume.
Under Exposure, the first option we have is Metering Mode.
This gives us a drop down with three different selections.
The first one is Auto Exposure Histogram.
The Auto Exposure Histogram option gives us access
to a lot of advanced settings
allowing us to really fine tune the exposure here.
A histogram essentially is just a bar graph
that represents the frequency of values
in this case exposure values.
Below this we have Auto Exposure Basic.
Selecting it is going to turn off the advanced options
and allows for a quicker, simpler way to adjust exposure.
And then finally we have Manual
which will disable all of these settings
and just give us controls using the cameras,
shutter speed, ISO, and f-stop.
And as you can see at the current settings,
the scene gets very dark. Let's go ahead and jump back up
however to the Auto Exposure Histogram.
Next up, we have Exposure Compensation.
We have a text entry field
as well as Exposure Compensation Curve here.
The curve is beyond the scope of this tips and tricks
so we're going to skip over that for now,
but the Exposure Compensation field here
will allow us to use a logarithmic adjustment
to tweak the exposure values.
Of course, generally you want to use this setting last,
but for now we're going to go ahead
and look at that, how it works.
If I put in a value of negative one,
that's going to make the scene twice as dark
because remember this is logarithmic.
For instance, if I put in a value of negative two
then the scene is now four times darker
than it was and conversely, putting in a value of one;
positive one, is going to make the scene twice as bright,
but we'll leave that at a value of zero for now
and use no compensation.
Next step we have the Min and Max EV100 values.
Now normally these are Min and Max Brightness,
but remember at the beginning
we went into the Project Settings
and we enabled the Extend Default Luminance Range option
which changes these options to Min and Max EV100.
For a minimum EV100
we want to find a dark area such as this closet
and it will adjust this value here.
You can see as I bring the value up higher,
the scene will get darker, and for controlling max EV100,
you'll want to find a bright area
and it adjust it from here.
And you can see as I bring this value down,
the scene is going to get much brighter.
In the Unreal documentation,
it recommends keeping these values
close to zero for the best effect.
And generally, you want to keep them in the positive range.
Next up we have Speed Up and Speed Down.
These control how long it takes the camera to adjust
when moving from a bright area to a dark area and vice versa.
Speed Up controls moving from a dark area to a light area
and generally that takes longer for your eye to adjust.
So, this takes three seconds, and then Speed Down controls
moving from a light area to a dark area.
Let's look at the visualization tool
we have available to us in the viewport.
If we go up to the Show button here
and then go down to Visualize,
we can enable HDR Eye Adaptation.
This is going to give us the information
that we're currently using here in our Post-Process Volume
as far as all the exposure settings,
we also have a picture in picture here
showing us a color-coded representation
of the exposure values. Green represents mid-tone values
and then blue represents your darker values.
We don't have any red values in the scene here,
but if we did, they would represent the brightest values.
Anything overblown basically.
And then below this we have a histogram.
Remember a histogram is just a bar graph
that represents the frequency of certain values
and in this case those values are our exposure values.
So, on the far left here we have an exposure value of -10.
That is our minimum exposure value currently defined
in the Advanced options for our auto exposure histogram.
If you look down here, you'll see Histogram Min EV100 -10.
So, if we change this to say -5,
you can see now the histogram has been adjusted.
Likewise, on the top here,
if we unselect our Post-Process Volume,
we'll be able to see that it is set to a value of 20.
We'll go back to our Post-Process Volume
and Histogram Max EV100
we'll change that to a value of 10.
Now in the center here, this white line represents
our current exposure value and of course the bar graph here
represents all the different exposure values in the scene.
So, as we move our viewport around,
we can see those bars are changing
based on the information being displayed at the time.
So, at the current Speed Up and Speed Down settings,
if I look towards a darker area,
you can see how long it takes for the adjustment to occur
and to bring us to the current level of exposure.
And if I go back to a brighter area,
you can see it happens much quicker.
So, to change that, I'm going to reduce the Speed Down
to a much lower value here,
to 0.1, which is going to adjust that speed by a factor of 10.
And so, if I look at the dark area now you can see
it's taking a lot longer, 10 times
as long to adjust the relative exposure
to match the exposure that it should be at.
Under Advanced we'll also find Low and High Percent.
These two values represent a range of luminance values
taken from the scene or from the histogram.
These values are then averaged together
to determine the current luminance value.
The Unreal documentation generally recommends
keeping these between 70 and 90%
so we'll go ahead and leave these at the default values.
Put simply, the auto exposure system works by first
determining the average luminance value
using the low and high percentage.
From here, the eye adaptation takes place using
that current luminance value,
and the eye adaptation will be clamped
between the Min and Max EV100 values.
Let's look now at using manual exposure controls.
Remember when we do that using the current camera settings,
the scene's going to get very dark.
Let's go ahead and tweak those settings now.
First of all, we'll go ahead
and set our Shutter Speed to one second
and we'll change our F-stop to a value of one.
Remember having an f-stop of one
and a shutter speed of one second at ESA 100
gives us an exposure value of zero.
But what if we want to mimic a typical sunny day?
Well, this brings in the sunny 16 rule from photography.
With the sunny 16 rule,
you can essentially mimic a sunny day in your photography,
whether you have a light meter or not.
The way we represent the sunny 16 rule in Unreal
is to set our Shutter Speed to a value of 100,
our ISO should be at 100
and our F-stop should be at 15.
Of course, this returns our scene to a very dark scene
and that's because our lights now need to be tweaked
to match these camera settings.
Before we go any further, however,
it's important to understand
that when working with manual exposure
to mimic a real-world cameras exposure,
the settings we'll be using will not work in all cases.
There are some systems in Unreal such as Fog Actors or Lightmass
that simply won't respond
correctly to real world camera values.
The settings I'm going to be using will work in this case.
Just keep that in mind as you may not be able to use
these real-world values in your particular scene.
So, we'll look for our sunlight here
and that's going to be a Directional Light
and you're going to notice the Intensity
is currently set to a value of 8 lux.
Now that is way too low for a sun
in a physically accurate representation
for our exposure settings.
With an exposure value of 15 the typical illuminance of the scene
should be about 82,000 lux,
so we're going to go ahead and change our sunlight.
Remember that value is coming all from the sun.
We're going to change that to 82,000
and you'll see when we do that, that brings our lights back in.
Now remember, using real world values like this
for the sun may cause Lightmass issues
when baking Lightmaps or other potential problems.
So again, it works fine in this scene,
but your mileage may vary.
And with a quick Lightmap bake, we can see that the lighting
is now beginning to bounce around the room
and lighten everything up
and everything looks like it's at the proper exposure.
In fact, if we go to our view mode options again
and we turn off Game Settings, we're going to see that
at an exposure value of one, the scene is much too bright.
However, if we match up the exposure value
from our Post-Process Volume,
we'll see that we get a much closer representation
of the same exposure value
that we have when we baked our Lightmap.
Alright, so that's going to do it for this episode.
We hope you enjoyed watching it
and we'll see you next time on Unreal Tips and Tricks.