Week 15 -Wednesday
Week 15 -Wednesday What did we talk about last time? Review up to - - PowerPoint PPT Presentation
Week 15 -Wednesday What did we talk about last time? Review up to - - PowerPoint PPT Presentation
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,
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
- bjects
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
- n the light
- T = e-αcd
d
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:
2 1 2 1
sin sin n n = θ θ
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
Reflective: Refractive:
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
- bjects
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
- ther
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 Layers Billboards Triangles
Appearance Based
Lightfields
Physically Based
Global 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
- Minimum texture resolution (per cube face) =
tan(fov/2) resolution screen
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
- rientation
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
- n the fly by rendering a complex
- bject to a texture
Then, the impostor can be rendered
more cheaply
This technique should be used to
speed up the rendering of far away
- bjects
The resolution of the texture should
be at least:
tan(fov/2) distance 2 size
- bject
resolution screen ⋅ ⋅
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
- bjects 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
The more complicated problem is properly
rendering edges with a thick dark line
A number of different edges are of interest
- Boundary or border edges are edges where one
polygon is not adjacent to any other
▪ Not found in 3D solid objects
- A crease, hard, or feature edge is an edge between two
polygons that is sharper than some threshold angle
- A material edge is an edge between two polygons with
different materials
- A silhouette edge is when two neighboring polygons
face different directions, relative to the eye
Cel shading focuses on rendering silhouette edges Many of these techniques rely on manipulating back facing
polygons
- The crossover between front facing and back facing polygons is the
silhouette
- It's easy to determine which is which
After some manipulation of the backfaces, they are rendered
in black
If the backfaces are rendered in black without any change, they will be hidden Before rendering, all backfaces can be translated to be closer to the viewer Translation can be by
- A fixed amount
- An amount that takes into account non-linear z-depths
- An amount based on the angle of the polygon normal
None of these techniques give uniform thickness lines
Another approach is to fatten each backface triangle The slope of the triangle and the distance from the viewer
determine the expansion of each edge
It doesn't work well for thin traingles
A similar approach is to expand backface vertices along their
normals
- The expansion amount is proportional to their z-distance
This technique fails for situations like a cube, in which faces
with very different normals share vertices
Rather than using geometry, there is an image
processing approach
Render all the normal values or depth values to a
buffer and use edge detection algorithms to draw lines where the values change abruptly
- Using normal values can find crease edges
This technique works for many cases that failed
before
- Even GPU generated surfaces are not a problem
NPR techniques are very broad Many approaches try to recreate hand-drawn or hand-painted styles Silhouette lines can be drawn as paintbrush strokes of varying thickness Tonal art maps (TAMs) use palettes of hand-drawn textures to do black
and white crosshatch-style shading
For CAD programs and other 3D tools, we may want to
highlight certain lines or all polygon edges
Rendering polygon edges on top of existing polygons can be a
pain
- Z-buffer algorithms might hide the lines
In practice, a small bias is usually added to the polygons
For drawing simplified models, we may want to include or exclude
the hidden lines
Wireframe is the easiest, since it is just the lines Hidden-line uses the z-buffer directly Obscured-line renders twice, rendering z-fail lines in a lighter color Haloed lines also use the z-buffer, drawing thick white lines first
and then black lines on top
- Problems happen when lines get too close
Work day for Project 3
Fill out course evaluations! Finish Project 3
- Due Friday before midnight
Study for final exam
- 2:45 - 4:45 p.m., Monday, 12/09/2019