what is computer graphics and image processing? lall visual computer output depends on computer...
TRANSCRIPT
What is Computer Graphics and What is Computer Graphics and Image Processing?Image Processing?
All visual computer output depends on computer graphics and image processing.
3D computer graphics is used in visualisation, simulation, CAD and entertainment.
Course StructureCourse Structure
Rendering: producing a ‘realistic’ image from a scene description
Modelling: defining scene objects mathematically.
Animation: controlling the evolution of objects over time.
Lectures: Rendering (4), Modelling (5), Animation (1)
Seminars:Guest Postgrads (2)Honours Groups (6)
Aims of RenderingAims of Rendering
Criteria for Rendering:Speed: Some applications (e.g. flight simulation) require
interactive (> 10 Hz) rendering updates.
Aesthetics: A subjective value attached by the viewer to the image. Difficult to measure.
Visual Realism: An image that captures the effects of light interacting with objects (‘photorealism’).
Information: How effectively the image conveys the required information.
These criteria are often in conflict.
Ray TracingRay Tracing
A powerful alternative to polygon scan-conversion techniques.
Given a set of 3D objects, shoot a ray from the eye through the centre of every pixel and see what it hits.
Enables: reflection, shadows, refraction, transparency.
Ray Tracing ExampleRay Tracing Example
From the Computer Animated Short Film “Tin Toy” (© Pixar)
Ray Tracing AlgorithmRay Tracing Algorithm
Select an eye point and a screen plane
FOR every pixel in the screen plane [num. pixels depends on image resolution]
determine the ray from the eye through the pixel’s centre
FOR every object in the scene [num. objects depends on scene size]
IF the object is intersected by the ray THEN
IF the intersection is the closest (so far) to the eye THEN
record the intersection point and object
ENDIF
ENDIF
ENDFOR
set pixel’s colour to that of the object at the closest intersection point
ENDFOR
Intersection of a ray with a sphereIntersection of a ray with a sphere
Sphere Ray (parametric):
Sphere (implicit):
Trick: substitute a parametric ray equation into an implicit sphere equation.
Derivation:
Result: real – two intersections, imaginary – no intersection, – one intersection
Cylinder, cone, torus are treated similarly
0,)( sDsOsP0)()( 2 rCPCP
a
bs
a
bs
acb
COCOcCODbDDa
rCODsCODs
2,
2
4
][][],[2,
0])[(])[(
21
2
2
0
Intersection of a ray with a polygonIntersection of a ray with a polygon
Plane: Ray: Plane: Derivation:
Does fall inside the polygon (check by clipping against its edges.
Box, polygon, polyhedron are treated as a set of bounded planes.
0,)( sDsOsP0 dNP
ND
NOds
NOdNDs
dNDsO
0)(
)(sP
Other implicit objects suited to Ray Other implicit objects suited to Ray TracingTracing
Quadrics: or Useful quadrics are the ellipsoid (sphere is a special
case), infinite cylinder and infinite cone. Various hyperbloids and parabloids are also defined by
these equations but they tend to be less useful.
Superquadrics:
Super-ellipsoids are the only ones used in practice. acts as a ‘pointiness’ parameter: more pointy,
more rounded (closer to a box), is octahedral.
kczbyax 222 kczbyax 22
kczbyax nnn )()()(
n 2n2n1n
Ray Tracing: shadingRay Tracing: shading
Once , the intersection point of ray with the closest object has been found it is possible to:1. Find the object’s surface
normal at
2. Shoot rays from to all light sources
3. Calculate the diffuse and specular lighting at . Along with ambient illumination this gives the colour of the object at .
iP i
N iP
iP
iP
iP
Ray Tracing: shadowsRay Tracing: shadows
If an object blocks the ray from the intersection point to a light source then it is casting a shadow over that point.
Also need to watch out for self-shadowing.
Recursive Ray Tracing: reflectionRecursive Ray Tracing: reflection
By spawning secondary (recursive) rays from a point of intersection reflection, transparency and refraction can be simulated.
A new ray aligned with the angle of reflection enables perfect (mirror) reflection.
Each new ray provides a scaled (distance attenuated) contribution to the pixel colour.
Recursive Ray Tracing: refractionRecursive Ray Tracing: refraction
Objects can be totally or partially transparent This allows objects behind
the current one to be seen through it.
Light rays which intersect transparent objects can have their contribution scaled.
Transparent objects can have refractive indices Bending the rays as they pass
through the objects.
Supporting transparency and reflection requires that a ray be split into two parts.
Sampling in Ray TracingSampling in Ray Tracing
Single Point Shoot a single ray through the pixel’s centre. Prone to aliasing
problems.
Super-sampling for anti-aliasing Shoot multiple rays through the pixel and average the results. Can use a regular grid, random, jittered or Poisson disc
distribution of rays.
Adaptive super-sampling Shoot a few rays through the pixel, check the variance of the
resulting values. If sufficiently similar then stop. Otherwise, shoot some more rays.
Trade-off the objectionable artefacts of aliasing for the less objectionable artefacts of noise.
Distributed Ray TracingDistributed Ray Tracing
Super-sampling (and anti-aliasing) is only one reason for taking multiple samples per pixel. Many effects can be achieved by distributing multiple ray samples
over some range. Called distributed ray tracing. The term distributed refers to the
stochastic distribution of rays.
Examples of distributed ray tracing:1. Distribute the rays from a light source over an area. Allows area
light sources and produces soft shadows with penumbrae.
2. Distribute the camera position over an area. Allows simulation of a camera with a finite aperture lens and produces depth of field effects.
3. Distribute the samples in time. Produces motion blur effects on moving objects.
4. Distribute reflected rays over a range of directions. Can simulate imperfect specular reflection.
Distributed Ray Tracing: area lightsDistributed Ray Tracing: area lights
Light rays coming from an area light source are distributed.
If some are blocked then the point is in a penumbrae.
If all are blocked then the point is in umbrae.
Allows area light sources, in addition to point and directional light.
Improving EfficiencyImproving Efficiency
Ray tracing (especially when distributed or recursive) is computationally costly. Naively, require a minimum of
intersection tests.
A small proportion of objects are intersected by a given ray. So, quickly identifying non-intersected objects is important.
Speedups: Intersect bounding boxes or spheres first. Only need to test the full
object if the bounding sphere is intersected. Spatial subdivision. Group objects into cells. If a ray does not pass
through a particular cell it cannot intersect the objects belonging to that cell.
Use Visibility pre-processing to cull out all objects and polygons invisible along a particular viewing direction.
numobjectsresolution
Exercise: Recursive Ray TracingExercise: Recursive Ray Tracing
Assuming all objects are perfect reflectors and have ambient, diffuse and specular (Phong model) lighting, show all rays and vectors needed to calculate the shading at P.
Solution: Recursive Ray TracingSolution: Recursive Ray Tracing
[A] Primary Intersection [B] Secondary Intersection