Week 15 -Wednesday
What did we talk about last time? Review up to Exam 2
We already talked about reflections! Environment mapping was our solution But it only works for distant objects
The reflected object can be copied, moved to reflection space and rendered there Lighting must also be reflected Or the viewpoint can be reflected
This problem can by solved by using the stencil buffer The stencil buffer is set to areas where a reflector is present Then the reflector scene is rendered with stenciling on
Ray tracing can be used to create general reflections Environment mapping can be used for recursive reflections in curved surfaces To do so, render the scene repeatedly in 6 directions for each reflective object
Transmittance is the amount of light that passes through a sample When the materials are all a uniform thickness, a simple color filter can be used Otherwise, the Beer-Lambert Law must be used to compute the affect on the light d T = e - α cd
Refraction is how a wave bends when it the medium it is traveling through changes Examples with light: Pencil looks bent in water Mirages
The amount of refraction is governed by Snell's Law It relates the angle of incidence and the angle of refraction of light by the equation: θ sin n = 1 1 θ sin n 2 2
Light is focused by reflective or refractive surfaces A caustic is the curve or surface of concentrated light The name comes from the Greek for burning Refractive: Reflective:
Subsurface scattering is where light enters an object bounces around and exits at a different point than it entered Causes: Foreign Particles (pearls) Discontinuities (air bubbles) Density variations Structural changes
To create a realistic scene, it is necessary for light to bounce between surfaces many times This causes subtle effects in how light and shadow interact This also causes certain lighting effects such as color bleeding (where the color of an object is projected onto nearby surfaces)
Radiosity simulates this Turn on the light sources and allow the environmental light to reach equilibrium (stable state) While the light is in stable state, each surface may be treated a light source The equilibrium is found by forming a square matrix out of form factors for each patch times the patch’s reflectivity Gaussian Elimination on the resulting matrix gives the exitance (color) of the patch in question
Trace rays from the camera through the screen to the closest object, the intersection point . For each intersection point, rays are traced: A ray to each light source If the object is shiny, a reflection ray If the object is not opaque, a refraction ray Opaque objects can block the rays, while transparent objects attenuate the light Repeat recursively until all points on the screen are calculated
Classical ray tracing is relatively fast but performs poorly for environmental lighting and diffuse interreflections In Monte Carlo ray tracing, ray directions are randomly chosen, weighted by the BRDF This is called importance sampling . Monte Carlo ray tracing gets excellent results but takes a huge amount of time
Full global illumination is expensive If the scene and lighting are static, much can be precomputed Simple surface prelighting uses a radiosity render to determine diffuse lighting ahead of time Directional surface prelighting stores directional lighting information that can be used for specular effects Much more expensive in memory Volume information can be precomputed to light dynamic objects
Global illumination algorithms precompute various quantities other than lighting Often, a measure of how much parts of a scene block light are computed Bent normal, occlusion factor These precomputed occlusion quantities can be applied to changing light in a scene Create a more realistic appearance than precomputed lighting alone
Precomputed ambient occlusion factors are only valid on stationary objects Example: a racetrack For moving objects (like a car), ambient occlusion can be computed on a large flat plane This works for rigid objects, but deformable objects would need many precomputed poses Example: a human Also can be used to model occlusion effects of objects on each other
The total effect of dynamic lighting conditions can be precomputed and approximated This method is trying to take into account all possible lightings from all possible angles Computing all this stuff is difficult, but a compact representation is even more difficult Spherical harmonics is a way of storing the data, sampled in many directions Storage requirements can be large Results generally hold only for distant lights and diffuse shading
We can imagine all the different rendering techniques as sitting on a spectrum reaching from purely appearance based to purely physically based Sprites Billboards Appearance Physically Based Based Layers Triangles Global Lightfields illumination
When objects are close to the viewer, small changes in viewing location can have big effects When objects are far away, the effect is much smaller As you know by now, a skybox is a large mesh containing the entire scene Some skyboxes look crappy because there isn't enough resolution screen resolution Minimum texture resolution (per cube face) = tan(fov/2)
If you are trying to recreate a complex scene from reality, you can take millions of pictures from of it from many possible angles Then, you can use interpolation and warping techniques to stitch them together Huge data storage requirements Each photograph must be catalogued based on location and orientation High realism output!
A sprite is an image that moves around the screen Sprites were the basis of most old 2D video games (back when those existed, before the advent of Flash) By putting sprites in layers, it is possible to make a compelling scene Sequencing sprites can achieve animation
Applying sprites to 3D gives billboarding Billboarding is orienting a textured polygon based on view direction Billboarding can be effective for objects without solid surfaces If the object is supposed to exist in the world, it needs to change as the world changes For small sprites (such as particles) the billboard's surface normal can be the negation of the view plane normal Larger sprites should have different normals that point the billboard directly at the viewpoint
In a particle system, many small, separate objects are controlled using some algorithm Applications: Fire Smoke Explosions Water Particle systems refer more to the animation than to the rendering Particles can be points or lines or billboards Modern GPUs can generate and render particles in hardware
An impostor is a billboard created on the fly by rendering a complex object to a texture Then, the impostor can be rendered more cheaply This technique should be used to speed up the rendering of far away objects The resolution of the texture should be at least: object size screen resolution ⋅ ⋅ 2 distance tan(fov/2)
Impostors have to be recomputed for different viewing angles Certain kinds of models (trees are a great example) can be approximated by a cloud of billboards Finding a visually realistic set of cutouts is one part of the problem The rendering overhead of overdrawing is another Billboards may need to be sorted if transparency effects are important
Image processing takes an input image and manipulates it Blurring Edge detection Color correction Tone mapping Much of this can be done on the GPU
Lens flare is an effect caused by bright light hitting the crystalline structure of a camera lens The bloom effect is where bright areas spill over into other areas Depth of field simulates a camera's behavior of blurring objects based on how far they are from the focal plane Motion blur blurs fast moving objects Fog can be implemented by blending a color based on distance of an object from the viewpoint
Most of the work we've focused on all semester is doing rendering that in some way mirrors the natural world However, a wide area of rendering is non- photorealistic rendering (NPR) Goals: Simplified technical drawings Simulating artistic styles
The most common form of NPR in video games is toon shading Also called cel shading The goal is to render 3D models as if they were cartoons Shading is often done with either a single color or a two tone (color and shading) approach Then a thick black silhouette is added around edges
The color is often determined by the dot product n · l (surface normal dot light vector) If negative, the surface should be darkened Otherwise, it's some flat color Or a threshold other than 0 can be used A more complex system uses a one dimensional texture indexed into with the dot product Highlight Normal Shadow
Recommend
More recommend