Object Representation and Ray Tracing
Object Representation and Ray Tracing
• Implicitly f(x,y,z)=0 – i.e. all points in 3D space • Implicitly f(x,y,z)=0 – i.e. all points in 3D space
where some function is zero. where some function is zero.
• e.g. sphere (x2+y2+z2)=r2 • e.g. sphere (x2+y2+z2)=r2
• Any guesses for?: • Any guesses for?:
z-axis
Modelling: 3D Primitives Explicit Representation
• Triangle • Quad • Cube (6 faces / quads) (0,1,1)
(1,1,1)
• These explicit representations class Quad{ • (0,0,0) (0,0,1) (1,0,1) (1,0,0) (1,1,0)
• (1,0,0) (1,1,0) (0,1,0) (0,0,0) (0,1,0)
lead to duplicated points private:
Point P1, P2, P3, P4; • (1,1,0) (1,1,1) (0,1,1) (0,1,0)
• This problem is examined in ...
• (1,1,1) (1,0,1) (0,0,1) (0,1,1)
the next slides };
(0,0,1)
• (1,0,0) (1,0,1) (1,1,1) (1,1,0) (1,0,1)
class Triangle { • (0,0,1) (0,0,0) (0,1,0) (0,1,1)
private: P2 P3 (0,0,0) (1,0,0)
Point P1, P2, P3; • Drawbacks:
... • 3D transformations of 24 vertices
P3
}; (not 8)
• Draw 24 edges (rather than 12)
• Rounding errors – consider
P1 P4
picking vertices
P1 P2
Animation Textures
Lighting Rendering
• We will study two forms of rendering – rasterization (briefly)
and ray tracing (in detail)
• Rasterization consists of several steps:
– Transformation, clipping and scan conversion
• Matrices for scaling, translation and rotation are applied to
each vertex within the object during transformation
• After transformation each vertex (x,y) gives the screen
• Range coordinate, and z gives the depth
• Clipping removes any part of the scene not visible within the
• Light source and intensity image
• Scan conversion colours pixels according to the object’s colour
and the lighting model
Such that (x,y) give the position View reference point (VRP)
Object and within the view (image) and z
camera are gives the depth to that position.
defined in “World The depth can be used to make
Space” sure that occluded surfaces are
View plane normal (VPN) (vector). This
hidden by closer surfaces
can be calculated from the position
GPUs provide hardware support for transformation, (point) the camera looks at minus the
clipping and rasterization allowing scenes of millions of view reference point of the camera
triangles to be rendered in real-time
Transformation Ray Tracing
• The transformation matrix can be calculated from the
view plane normal (=look at – vrp), the view up vector
and the view right vector
• For rasterization, each vertex is multiplied by the
matrix (in GPU hardware)
• The resulting (x,y,z) points can be clipped and scan
converted
• In ray tracing, rays are sent out from the view plane,
into the scene to detect which objects are hit
• Ray tracing is studied in more detail in the next
lectures Eyepoint Screen Scene