Directional | Directional light source | |
Point | Point light source | |
Spot | Spot light source | |
Lighting Group | Define a group of light sources | |
PBR Directional | Directional PBR light source | |
PBR Point | PBR Point light source | |
PBR Spot | PBR Spot light source | |
PBR Ambient | PBR Ambient light source |
Lighting in Realtime Rendering is a very efficient approximation of real life lighting. There are no global effects like one object casting a shadow onto another or light bouncing of one surface and lighting another. It is therefore often called direct lighting opposed to global lighting as used by raytracing software.
A triangle can be lit by one or multiple light sources. The final color of a pixel in a triangle is dependent on the shape of the objects surface, the characteristics of the light sources, the Material applied to the object as well as the Engine-Settings in the Layer Root of the 3D Layer. For each light source, a number of terms is calculated:
When there is no light source node in the scene, Ventuz uses an internal default light source. This so called head light is positioned at the exact position of the camera, therefore shiny objects (with a high specular amount) can appear completely white. To disable the default lighting set the DefaultLight to "none" in the 3D Layer Root Node
Both the light source and the material have a color assigned to all of these terms. In addition, the material of an object can have an Emissive term that simulates light coming from the object itself.
This is about how light gets darker with distance. We use different formulas for different engine modes. Below is an explanation for the formulas. You can skip the math, but remember the following:
Every light source now has a gain property. Gain 0 will not change the light, every positive step will double the intensity of the light and every negative step will half it. So a gain of 3 will increase the intensity by a factor of 8. This is especially useful to adjust HDR lights.
In reality, light intensity decreases with the square of the distance: I = I0 * 1 / d2. Doubling the distance will quarter the light intensity.
Ventuz light-sources define a maximum radius. If the simply cut the light at a distance, we might see the cut-off point. To avoid this, we subtract the amount of light at the maximum distance (dmax), the corrected formula is:
This is the formula we use in HDR.
If we do not render in HDR, we do light calculation with gamma 2.2 colors. Unfortunately, with this the physically correct formula produces bad results, as it only applies to linear colors. Instead, we use a simple linear falloff formula: The light is just faded out by distance :
This produces good results and naturally has no cut-off point at the maximum light range.
In order to make lighting calculation feasible, the travel of light rays through a scene cannot be simulated. Instead the terms above try to simulate the variation of brightness on a surface. The role of the light source is to specify from what direction the light falls on to the surface.
Lightsources are immaterial and therefore no geometry is rendered for them. To see the orientation and shape of a light source activate the show non-render objects.
The Directional light represents a light source that is so far away that the light rays are completely parallel to each other and the actual position of the light source becomes irrelevant. The most prominent analogy is the sun.
The Point light represent a lamp that is infinitely small in size. It emits rays into all directions, originating from a single point in space. Same as the Directional light, it has no surface area to simplify the calculation. The direction of light for a point light at any given point on a surface is equal to the vector from the point lights position to that point on the surface. A rough analogy might be a light bulb or a candle.
The Spot light differs from the point light in that it only emits light in a cone shaped volume instead of all directions uniformly. The InnerCone specifies the radius of the region that is lit at full intensity which then decreases to the OuterCone radius where the light influence of the spot ends. It also simulates brightness decreasing the farther away something is from the spot (Attenuation) and the more it is offset from the center axis of the spot towards the boundary (FallOff).
All lightsources have the Gain parameter in common. If your lightsources appear to dark while using the HDR mode, you can adjust and boost the gain of the intensity here.
An additional way of lighting your scene is by using the Sky Box and an HDRI/Irradiance Map as a lightsource.
The example below shows the same scene lit by a Direction light coming hard from the left, a Point light above the scene and a Spot light coming from the right.
If ApplyAxis is active, the light source will be transformed by the World Matrix as for example influenced by Axis Nodes.
Multiple lightsources can be added to a scene, for example as main and fill lights as often used in a photo shoot. However, they can also be used to light separate parts of a scene differently. For example, a spot light may be used to light only one object but not affect another object, although it would theoretically be in the cone of the spot. Instead the second object could be rendered using a completely different light setup.
Lightsources are special in that they affect all nodes that are rendered after them, not just their child nodes. They are not deactivated once their subtree has been processed.
Each light source has an Input Property Index which specifies whether the light should be used in addition to existing lights (Next) or should replace the last activated light (Override). To limit the effect of light sources to certain parts of a scene, Lighting Group nodes can be used. If their Inherit property is deactivated, lights defined outside the lighting group will have no effect on the objects rendered within the lighting group. The example below shows a scene with four differently colored light sources. In the top row, each light source illuminates each sphere that comes after it in the rendering order. In the bottom row, Lighting Groups have been used to isolate each sphere together with one light source in a separate group.
For each lightsource you can enable shadows. Shadows in Ventuz are based on Shadowmaps.
Click the Shadow drop down menu in the Lightsource Properties and select Shadowmap to enable Shadows.
You can adjust the Properties for each lightsource individually.
The Amount is the overall intensity of the shadows. Resolution is the shadowmap resolution and should be as small as possible. With the DepthBias and SlopeBias you adjust the sampling of the shadowmap (see How To Use Shadows for more details). You can define to have the shadows in a group by the Select drop down menu. You can set the Shadowmap in the A or B group or have it off any group. The grouping works together with the Shadow Filter. The Filter drop down menu affects the shadowmap filtering and you can select between Samples 1, Samples 4 and Samples 8. When Samples 4 or Samples 8 is selected you can also adjust the quality of the sampling by changing the AntiAliasScale and FilterScale. If the values for the Scales is 0 and not bound, the sampling scale is completely turned off in the shader and therefor the performance increases.
The Pointlight needs to render one shadowmap for each of its six sides. This can affect the performance a lot! The shadowmap resolution becomes even more critical here!
With the help of the Tint properties you can tint your shadows. This will apply the specified TintColor to the BaseColor of the affected objects after multiplying it with the AmbientColor of your light. The TintMode defines how the Tint should be applied: Full will apply the Tint Color everywhere in the same amount. Attenuated will linearly fade out the amount of the Tint over the distance to the light source.
Since Shadows are working in conjunction with Lightsource as Source, Object as Shadowcaster and at least one receiver to apply the shadow to (except for selfshadowing) you should read the See Also sections as well.
You can define a shadow volume for the directional light source. Enable the LightVolume by selecting the Light Relative Volume from its drop down menu.
The so called shadow volume can be visualized by enabling the Show non-render objects button in the top bar.
This will show the shadow volume by rendering infinte lines, which visualize the volume bounds. By using the Width, Height and Depth properties, you can adjust the volume's boundaries. Everything that is inside the volume will act as a shadow caster. It is therefore possible to have just a part of an object throw a shadow, as long as it is inside the volume. See the screenshot below:
This way you can limit the boundaries of a directional shadow. Instead of using the whole scene boundaries to create the shadow map, you can now limit it and therefore safe shadow map precision, therefore performance. Before, you would need to increase the shadow Map Resolution to have at least more details when using a very huge scene. Now you can safe performance and or the resolution, by defining the volume for the directional light shadow.
Below we compare a scene, one without- and one with LightVolume used. The scene is VERY huge because the groundplane has a size of 400 units. The torus is compared really small:
Both scenes use the same settings for the Shadow Map Resolution of _2048, same Directional Light Source and positions. The upper screen shows the Directional Light Source without the LightVolume while the lower screen shows the exact same Directional Light Source with the LightVolume enabled and adjusted to be at 10x10 units (the boundaries are indicated by the yellow lines).
While the upper screen result is more of a blocky and pixelated shadow map, compared to the crisp and high resolution shadow map for the other, you can see, that without a defined LightVolume the whole scene (in this case the 400unit ground floor) is taken into account for the shadow map calculation. Therefore you have less pixels in the same shadow map available - since it has to cover the whole scene. If you define a LightVolume for the shadow map calculation you can define specific areas that really advance of a shadow map or are point of interest, while not wasting the space on the shadow map or resolution in other areas in the scene, which are out of focus or point of interest.
The PBR Light sources share the most properties shown above, they are just arranged slightly different to the traditional phong light sources above. PBR Light sources differ that they have just a single Color property, which links the Diffuse and Specular color and doesnt apply any kind of Ambient light. PBR Materials usally do not need any ambient since the usecase is to have a PBR SkyBox which lights up the material. Still, one can use the PBR Ambient to have a global ambient lighting for the PBR Material if needed.
PBR Light has a property group to select which light source should be used. Available are Directional-, Point-, Spot- and Ambient- shape. Each light shape property group has its own properties, which vary depending on the light shape. Basically they consist of position, orientation and other light type related properties as a traditional phong light.
The General properties are Color, Gain and ApplyAxis. As mentioned above the Color is just a single value since the specularity and diffuse would be controlled by the PBR Material properties.