This thread is to discuss lighting in the current passes and how to improve it, fix bugs or add features.
I really would like to see this added to some kind of roadmap. Most information in this post comes from the this Frostbite 3 presentation, the blender source code or the GDC18 talk about Detroit Become Human
We have a good basic Light representation in Rust with
amethyst_rendy::light::Light. The following list is only valid in terms of the docs from the actual code in
We have 3 kind of lights implemented in there:
- Point Lights
They act as punctual light spreading in every direction. Like an open light bulb.
The Rust implementation has parameters for color (srgb), intensity (lumens), radius (no unit, describe the area of effect) and smoothness (a factor, e.g. 4 in Frostbite 3)
- Spot Lights
Spot lights are punctual lights too, but spread in only one direction lighting up a cone. Like a light bulb in a lamp.
We have the following parameters implemented: angle (opening angle of the cone in radians), color (srgb), direction (vector), intensity (in lumens), range (no unit), smoothness (a factor, similar to the point light)
- Directional Lights
Our directional light lights from one direction, like the sun, but without specific sunlight features. It has no falloff.
We have the following parameters: color (srgb), intensity (no unit), direction (vector)
Our different shaders support different lights.
Only supports directional light (using all of the parameters from the Rust implementation) and point lights (with only color, position and intensity from the Rust implementation)
Supports all three lights but point light is missing the range and smoothness values as well.
The current shader for PBR does not have a falloff for point lights, as the squared distance uses the normalized distance of vertex and camera position and thus is 1. This leads to an equally lit scene when using a point light. The only difference between the point light and directional light is the radial lighting area instead of a fixed light direction. This needs to fixed, but is only small PR.
Comparable light levels between passes
Imagine we have a directional light in our scene. If we find a well suited intensity value for a PBR pass, switching to a shaded pass will result in an over saturated scene. The power levels across passes are very different. I really would like to have similar lighting levels. A perfect match is not possibly because auf different equations, but the intensity value should be modified for one of those to kind of match the same output level.
The current rust implementation has some values attributed with units they represent. We should adapt Frostbites way of use of real world units for every aspect, like settle with meters for 1 unit in our world and then use meters for the range value in spot lights. Make sure we have lumens and get real world comparable results with them. This makes it easier for artist to design scenes.
Fix point lights in the PBR pass.
Take radius and smoothness in account when calculation the point light in PBR.
Maybe add the spot light to the shaded pass.
Define units and and make sure everything is homogeneous across the whole calculation.
Not so imminent, but our shaders could use a better doc style. Regarding what function does what and maybe the source of the used equations.
Point lights act as if they have no physical area. Area lights are the opposite and have a physical shape and area.
Frostbite 3 supports sphere, disc, tube and rectangle area lights. I thing it would be nice if we would support them as well.
Frostbite allows to set either the luminous power in lumens which is independent of the actual area of the light or luminance which depends on the area of the light body.
IIUC Blender calculates a power dependent on the area of the light body and then multiplies it with the value (e.g. watts) set by the user in the properties tab.
The sun acts, because of its distance to the earth, like a directional lights. But using a directional light or point lights can cause problems with mirror-like surfaces.
Frostbite 3 defines sun lights as a disc area light perpendicular to the hemisphere. The illuminance is set in lux for a surface perpendicular to the sun direction and can be compared to real world values using a light meter.
These lights use real world profiles for their intensity distribution. This way the specific lighting pattern of a real world lamp can be used inside of the engine.
For lights with a range, do not pass lights outside of this range to draw calls. This can be problematic with batching. We should come up with a solution for this.
e.g. Detroit Become Human offers 4 different exposure types to the dev.
Exposure value in EV100, can be controlled by animated curves
Computed from physical camera settings (f stop, ISO, shutter time)
- Auto Average
Computed from Log average luminance of the scene
- Auto EVZone
Computed from exposure values provided in a scene based on position
I really would like to see the area and sun light implemented as well as the problems fixed.
As the Frostbite 3 paper is from 2014 I am really interested if there are new better calculations out there. There is a presentation from the shading of UE4 from 2013 but I am not sure if this has changes since then. I could not find a paper on for Unity.
Im not sure which paper is the current source for our calculations.
@Frizi do we have a discussion for shadows?