Lighting And Shadows Flashcards
What is Global Illumination (GI)
Gi is a system that models how light is bounced off of surfaces onto other surfaces, Indirect light, rather than being limited to just the light that hits a surface directly from a light source
Modeling indirect lighting allows for effects that make the virtual world seem more realistic and connected, since objects affect each other’s appearance
True. An example is color bleeding, where sunlight hitting a red sofa will cause red light to be bounced onto the wall behind it.
Color bleeding is where light is leaked or bounced off one surface onto another
Another example is when sunlight hits the floor at the opening of a cave and bounces around inside so the inner parts of the cave are illuminated too.
Limitations of baked GI
Both Baked GI and precomputed real-time GI have the limitation that only static objects can be included in the bake/precomputation.
Moving objects cannot bounce light onto other objects and vice versa.
But they can still pick up bounce light from static objects using light probes
What are light probes
Light probes are positions in the scene where the light is measured, or probed, during the bake/precomputation, and then at runtime the indirect light that hits non static objects is approximated using the values from the probes that the object is closest to at any given moment.
Examples of GI effects.
Changing the direction and color of a direction and color of a directional light to simulate the effect of the sun moving across the sky.
By modifying the skybox along with the directional light it is possible to create a realistic time of day effect that is updated at runtime.
As the day progresses the sunlight streaming in through a window moves onto the floor and bounced across the room and onto the ceiling.
When te sunlight reaches a red sofa, the red light is bounced onto the walls behind it.
Emissions in lighting
Animating the emissiveness of a neon signs materials so it starts glowing onto its surroundings when it’s turned on is an example of GI effects aswell
How are shadow’s formed in unity
Unitys lights can cast Shadows from an object onto other parts of itself or onto other nearby objects.
Shadows add a degree of depth and realism to a scene since they bring out the scale and position of objects that otherwise look flat
How do shadow’s work
The simplest case is of a scene with a single light source.
Light rays travel in straight lines from that source and may eventually hit objects in the scene.
Once a ray has hit an object, it can’t travel any further to illuminate anything else, it bounces off the first object and doesn’t pass through. The shadows cast by the object are simply the areas that are not illuminated because the light couldnt reach them.
What is a shadow map
The light uses the same principle as a camera to render the scene internally from its point of view.
A depth buffer system, as used by the scene camera, keeps track of the surfaces that are closest to the light, surfaces in a direct line of sight receive illumination but all the others are in shadow.
The depth map is also known as a shadow map
Enable the shadow properties using the inspector
Use the shadow type property in the inspector to enable and define shadows for an individual light
You can change the shadow type, strength, resolution, bias, normal bias and shadow near plane
Mesh renderer for shadows
Each mesh renderer in the scene also has a cast shadow and a receive shadows property, which must be enabled as appropriate.
Mesh renderer property in the inspector must have cast Shadows on. Receive shadows can be turned on and off
Casting shadows
Enable cast Shadows by selecting On from the drop down menu to enable or disable shadow casting for the mesh. Alternatively select Two Sided to allow shadows to be cast by either side of the surface, so backface culling is ignored for shadow casting purposes, or shadows only to allow shadows to be cast by an invisible gameObject
What are the Shadow mapping and Bias property
The shadows for a given Light are determined during the final scene rendering.
When the scene is rendered to the main camera view, each pixel position in the view is transformed into the coordinate system of light.
The distance of a pixel from the light is then compared to the corresponding pixel in the shadow map.
If the pixel is more distant than the shadow map pixel, then it is presumably obscured from the light by another GameObject and it obtains no illumination.
Shadows on GameObjects
Correct shadowing. A surface directly illuminated by a light sometimes appears to be partly in shadow. Pixels that should be exactly at the distance specified in the shadow map are sometimes calculated as being further away, this is a consequence of using shadow filtering, or a low resolution image for the shadow map. The result is arbitrary of pixels in the shadow when they should really be lit, giving a visual effect known as Shadow Acne.
Shadow acne in the form of false self shadowing artifacts.
How to prevent shadow acne
To prevent shadow acne, a bias value can be added to the distance in the shadow map to ensure that pixels on the borderline definitely pass the comparison as they should, or to ensure that while rendering into the shadow map, gameObjects can be inset a little bit along their normals.
These values are set by the Bias AND Normal bias properties in the light inspector window when shadows are enabled.
Bias with shadows
Do not set the Bias value too high, because areas around a shadow near the GameObject casting it are sometimes falsely illuminated.
This results in a disconnected shadow, making the GameObject look as if it is flying above the ground.
A high Bias value makes the shadow appear disconnected from the GameObject
Normal Bias with shadows
Setting the Normal Bias value too high makes the shadow appear too narrow for the GameObject..
Normal Bias can cause unwanted effects called, light bleeding, where light bleeds through the nearby geometry into areas that shouldn’t be shadowed.
A potential solution is to open the GameObjects mesh renderer and change the cast Shadows property to Two Sided.
This can sometimes help, although it can be more resource intensive and increase performance overhead when rendering the scene.
Bias values
Bias values for a light may need tweaking to make sure that unwanted effects do not occur. It is generally easier to gauge the right value by eye rather than attempting to calculate it.