Download - unixjava.ppt
-
8/12/2019 unixjava.ppt
1/75
1Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
UNIT-1
-
8/12/2019 unixjava.ppt
2/75
2Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
A graphics system
A computer graphics system is a
computer system.
There are five major elements
- Input devices
- Processor
- Memory
- Frame buffer- Output devices
-
8/12/2019 unixjava.ppt
3/75
3Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Basic Graphics System-
High level view
Input devices
Output device
Image formed in FB
-
8/12/2019 unixjava.ppt
4/75
4Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pixels and frame buffer
Image produced as an array (the raster)
of picture elements (pixels) in the frame
buffer
-
8/12/2019 unixjava.ppt
5/75
5Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pixels and frame buffer
Frame buffer The pixels are stored in a part of memory called the frame
buffer.
core elements of a graphics system.
Its resolution- the no of pixels in the frame buffer. The
max no of points that can be displayed without overlap on aCRT.
Depth or precision of the frame buffer
The number of bits that are used for each pixeldetermines properties such as how many colorscan be
represented on a given system. For example- 1 bit deep frame buffer allows only two colors.
- 8 bit deep frame buffer allows 256 colors.
-
8/12/2019 unixjava.ppt
6/75
6Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pixels and frame buffer
Full color system or true color or RGB color system
There are 24 bits per pixel .such systems can displaysufficient colors to represent most images realistically.
High dynamic range applications require more than 24-bitfixed point.
The frame bufferis implemented with special types ofmemory chips.
In simple systems- the frame buffer holds only the coloredpixels
In most systems-the frame buffer holds far moreinformation.
-
8/12/2019 unixjava.ppt
7/75
7Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pixels and frame buffer
Color buffer
Frame buffer comprises multiple buffers, one or moreof which are color buffers that hold the colored pixelsthat are displayed.
In simple systemonly one processor- CPU must donormal processing and the graphical processing.
The main graphical function of the processor is takespecificationof graphical primitives generated byapplication programs and to assign values to the thepixels in the frame buffer.
-
8/12/2019 unixjava.ppt
8/75
8Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pixels and frame buffer
For example a triangle is specified by its three
vertices,but to display its outline by the three line
segments connecting the vertices, the graphics
system must generate set of pixels that appear as line
segments to the viewer. The conversion of geometric entities to pixel colors
and locations in the frame buffer is known as
rasterization or scan conversion.
In early systemframe buffer was part of the stdmemory
Today-Special purpose graphics processing
units(GPUs)-
-
8/12/2019 unixjava.ppt
9/75
9Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Output devices-CRT
Can be used either as a line-drawing device
(calligraphic) or to display contents of frame buffer
(raster mode)
-
8/12/2019 unixjava.ppt
10/75
10Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Refreshing
CRT emit light for only a short time-few milliseconds afterthe phospher is excited by the electron beam.
The same path must be retraced or refreshed by the beamat a sufficiently high rate ,the refresh rate.
Older system- 60 Hz in US and 50Hz in rest of the world
Modern -85hz.
Non interlaced or progressive display
Pixels are displayed row by row or scan line by scan line at
the refresh rate.Interlaced
Odd rows and even rows are refreshed alternately
Used in tv -60hz
-
8/12/2019 unixjava.ppt
11/75
11Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Shadow Mask CRT
-
8/12/2019 unixjava.ppt
12/75
12Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Flat panel monitors
LED,LCD PLASMA PANELS
The two outside plates contain parallel grids of
wires that are perpendicular to each other.
By sending electrical signals to the grid-tocontrol the corresponding element in the middle.
The middle plate in an LED panel contains light
emitting diods that can be turned on and off by
electrical signals sent to the grid.
LCDLiquid crystals
Plasma panel -gas
-
8/12/2019 unixjava.ppt
13/75
Most projection systems are also raster devices.-DLP
Hard copy devices such as printers and plotters- also
raster based- cannot be refreshed.
Aspect ratio
Most displays had a 4:3 width to height ratio.
width to height ratio- horizontal to vertical point ratio.
VGA resolution- 640x480
Computer resolution-XGA-1024X768- SXGA-1280X1024
HDTV-16:9
13Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
-
8/12/2019 unixjava.ppt
14/75
14Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Input devices
Common input devices are-
keyboard,mouse,the joystick and the data
tablets.
Data gloves-include many sensors andcomputer vision systems.
-
8/12/2019 unixjava.ppt
15/75
15Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Images: physical and
synthetic
Traditional approach- how to construct rasterimages of simple two-dimensional geometricentities.
Two and three dimensional mathematical
objects in the computer .Modern systems- to create realistic image
- It involves many aspects of image formation, such aslighting,shading and properties of materials.
Computer generated images are synthetic orartificial, in the sense that objects beingimaged may not exist physically.
-
8/12/2019 unixjava.ppt
16/75
16Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Objects and viewers
Two basic entities must be part of any image formationprocess.
- Object
- Viewer
The object exists in space independent of any viewer andany image formation method.
In CG, where we deal with synthetic objects, we formobjects by specifying the positions in space of variousgeometric primitives such as points, lines and polygons.
Vertices is sufficient to define or approximate most objects. To form an image we need a person or a camera or adigitizer.it is the viewer that forms the image of our objects.
-
8/12/2019 unixjava.ppt
17/75
17Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
In the human visual system, the image is formedon the back of the eye.
In a camera the image is formed in the filmplane.
The image is what is seen by observer A.
All three images contain same building, butimage of the building is different in all three.
The specification of object is combined with thespecification of the viewer to produce a twodimensional image is the essence of imageformation.
-
8/12/2019 unixjava.ppt
18/75
18Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Light and images
A camera system with an object and a light source
-
8/12/2019 unixjava.ppt
19/75
19Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Light and images
Light from light source strikes various surfaces
of the objects and a portion of the reflected light
enters the camera through the lens.
The details of the interaction between light andthe surfaces of the objects determine how much
light enters the camera.
Light is a form of electromagnetic radiation.
The electromagnetic energy travels as wavesthat can be characterized by either wavelengths
or their frequencies.
-
8/12/2019 unixjava.ppt
20/75
20Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
The electromagnetic spectrum includes radiowaves, infrared and a portion that causes aresponse in our visual systems.
The visible spectrum which has wavelengths in
the range of 350 to 780 nanometers(nm) iscalled light.
A given light source has a color determined bythe energy that it emits at various wavelengths.
520nm green
350 blue
780 red
-
8/12/2019 unixjava.ppt
21/75
21Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Point source emits energy from a single
location at one or more frequencies
equally in all directions.
A light bulb can be characterized asemitting light over an area and by
emitting more light in one direction than
another.
-
8/12/2019 unixjava.ppt
22/75
22Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Image formation
model
One way to form an image is to
follow rays of light from a
point source finding which
rays enter the lens of the
camera. However, each
ray of light may havemultiple interactions with objects
before being absorbed or going to infinity.
-
8/12/2019 unixjava.ppt
23/75
23Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Image formation model
A ray is a semi-infinite line that emanates from a point andtravels to infinity in a particular direction.
Portion of these infinite rays contributes to the image on thefilm plane of our camera
For example if the source is visible from camera, some ofthe rays go directly from the source through the lens of thecamera and strike the film plane.
Most rays go off to infinity neither entering the cameradirectly nor striking any of the objects. These rayscontribute nothing to the image.
Reflection and scattering
Transparent surface light pass through it and may interactwith other objects.
-
8/12/2019 unixjava.ppt
24/75
24Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Ray tracing and photon mapping are image formationtechniques that are based on these ideas.
Tracing rays can provide a close approximation to thephysical word. But not suited for real time computation.
Radiositythis method works best for surfaces that scatterthe incoming light equally in all directions.
More computations.
Given time constraints in image formation, we are satisfiedwith images that look reasonable rather than that arephysically correct.
Real time needhours of computer time for each frame.
With the increased speed of present hardware, we can getcloser to physically correct images in real time systems.
-
8/12/2019 unixjava.ppt
25/75
25Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Imaging systems- Pinhole
Camera
xp= -x/z/d yp= -y/z/d
Use trigonometry to find projection of point at (x,y,z)
These are equations of simple perspective
zp= -d
-
8/12/2019 unixjava.ppt
26/75
26Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pinhole camera provides an example of image formation.A pinhole camera is a box with a small hole in the center of
one side of the box.
The film is placed inside the box on the side opposite thepinhole.
Initially the pinhole is covered. It is uncovered for a shorttime to expose the film.
Suppose that we orient our camera along the Z-axis withthe pinhole at the origin of our coordinate system.
Assume hole is small that only a single ray oflight,emanating from apoint, can enter it.
The film plane is located a distance d from the pinhole.
-
8/12/2019 unixjava.ppt
27/75
27Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Side view allows us to calculate where the
image of the point(x,y,x) is on the film plane z=-d
Two triangles are similar.
We find that the y coordinate of the image is atypwhere
A similar calculation ,using a top view
A point (xp,yp, -d) is called the projection of the
point (x,y,z)
xp= - x/z/d
yp= -y/z/d
-
8/12/2019 unixjava.ppt
28/75
28Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
All points along the line between(x,y,z) and
(xp,yp, -d) project to (xp,yp, -d) .
The color on the film plane at this point will be
the color of the point (x,y,z) The field or angle of view of our camera is the
angle made by the largest object that our
camera can image on its film plane.
If the h is the height of the camera, then theangle of view is
= 2tan-1h/2d
-
8/12/2019 unixjava.ppt
29/75
29Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Disadvantage Because the pinhole is so small.it admits only a single ray
from a point source-almost no light enters the camera.
The camera cant be adjusted to have a different angle ofview.
By replacing the pinhole with lens we solve the twoproblems of the pinhole camera.
1. the lens gathers more light than can pass through thepinhole. the larger aperture of the lens, the more lens cancollect.
2.By picking a lens with the proper focal length. A selectionequivalent to choosing d for the pinhole color. We canachieve any desired angle of view(180).
-
8/12/2019 unixjava.ppt
30/75
30Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Human visual system
Human visual system has two types of
sensors
- Rods: monochromatic, night vision
- Cones Color sensitive
Three types of cones
Only three values (the tristimulus
values) are sent to the brain
Need only match these three values
- Need only threeprimarycolors
-
8/12/2019 unixjava.ppt
31/75
31Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Synthetic Camera Model
center of projection
image plane
projector
p
projection of p
-
8/12/2019 unixjava.ppt
32/75
32
Creating a computer generated image as being similar to formingan image using an optical system. This paradigm has becomeknown as the synthetic camera model.
Viewer is bellows camera. the image is formed on the film planeat the back of the camera.
To create artificial image, we need to identify a few basic
principles.1.The specification of the objects is independent of thespecification of the viewer. There will be separate functions forspecifying the object and viewer.
2.We can compute the image using simple geometric calculations.
In real camera the image of the object is flipped relative to the
object. In synthetic camera we draw another plane in front of the lens
and work in 3D
Projector
we find the image of a point on the object on the virtual imageplane by drawing a line called a projector, from the point to the
center of the lens or the center of projection(COP).
-
8/12/2019 unixjava.ppt
33/75
33Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Projection plane the virtual image plane that we have moved in front of the lens is
called the projection plane.
Clipping rectangle (or) clipping window
We must also consider the limited size of the image. Not allobjects can be imaged onto the pinhole cameras film plane.
The angle of view expresses this limitation.
In the synthetic camera, we can move this limitation to the frontby placing a clipping rectangle (or) clipping window in theprojection plane.
Rectangle acts as a window ,through which a viewer located atthe center of projection sees the world.
Given the location of the center of projection, the locationand orientation of the projection plane and size of theclipping rectangle, we can determine which objects willappear in the image.
-
8/12/2019 unixjava.ppt
34/75
34Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
API(application programmers
interface)
- Programmer sees the graphics system through a
software interface: (API)
- The interface between an application program and
a graphics system.- It can be specified through a set of functions that
resides in a graphics library.
- The application programmer sees only the API .
- It is shielded from the details of both the hardwareor the software implementation of the graphics
library.
-
8/12/2019 unixjava.ppt
35/75
35Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Application programmers
model of graphics system
The software drivers are responsible forinterpreting the output of the API and
converting these data to a form that is
understood by the particular hardware.
-
8/12/2019 unixjava.ppt
36/75
36Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pen-plotter model
A pen plotter produces imagesby moving a pen held by agantry,a structure that canmove the pen in two orthogonaldirections across the paper.
The plotter can raise and lowerthe pen as required to create thedesired image.
Still in use.
They are well suited for drawinglarge diagrams such asblueprints.
-
8/12/2019 unixjava.ppt
37/75
37Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Drawing function- moveto(x,y)
- lineto(x,y)
Execution of the moveto function moves the pen to the location(x,y)on the paper without leaving a mark.
Lineto function moves the pen to (x,y) and draws a line from the old
to the new location of the pen.Simple program
moveto(0,0);
lineto(1,0);
lineto(1,1);
lineto(0,1);lineto(0,0);
O/p of pen plotter program:square
-
8/12/2019 unixjava.ppt
38/75
38Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
If we added the code, we will get cubemoveto(0,1);
lineto(0.5,1.866);
lineto(1.5,1.866);lineto(1.5,0.866);
lineto(1,0);
moveto(1,1);
lineto(1.5,1.866);
-
8/12/2019 unixjava.ppt
39/75
39Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
For certain applications, such as page layout in the printingindustry, systems built on this model work well.
Alternative
2D model relies on writing pixels directly into a frame buffer.
write_pixel(x,y,color)
Where x,y is the location of the pixel in the frame bufferand color gives the color to be written there.
Suited to writing the algorithms for rasterization andprocessing of digital images.
Disadvantage
The pen- plotter model does not extend well to three
dimensional graphics systems. 2D points are the projections of points in three dimensionalspace. the mathematical process of determining projections isan application of trigonometry.
We prefer to use an API that carry out the projection processautomatically without any trigonometric calculation.
-
8/12/2019 unixjava.ppt
40/75
40Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Three dimensional APIs
The synthetic camera model is the basis for all the popularAPIs,including OpenGL,Direct3D, and Open Scene Graph.
We need functions in the API to specify the following:- Objects
- Viewer
- Light Source(s)
- Material properties .
Objects are defined by sets of vertices.
Most APIs support a limited set of primitives including- Points
- Line segments
- Polygons
- Some curves and surfaces
Quadrics Parametric polynomials
Complex object- Circle can be defined by three points on its circumference, or by its center and
one point on the circumference.
-
8/12/2019 unixjava.ppt
41/75
41Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Example
glBegin(GL_POLYGON)
glVertex3f(0.0, 0.0, 0.0);glVertex3f(0.0, 1.0, 0.0);
glVertex3f(0.0, 0.0, 1.0);
glEnd( );
type of object
location of vertex
end of object definition
-
8/12/2019 unixjava.ppt
42/75
42Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
The function glBegin specifies the type ofprimitive that the vertices define.
Each subsequent execution of glVertex3f
specifies the x,y,z coordinates of a location. The function glEnd ends the list of vertices.
Example type
GL_LINE_STRIP
GL_POINTS
-
8/12/2019 unixjava.ppt
43/75
43Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Camera Specification
We can identify four typesOf necessary specification
1.Position-COP
2.Orientation
-Coordinate system3.Focal length
Determine size of the
image on the film plane.
4.Film plane
Back of the camerahas a height and a width
-
8/12/2019 unixjava.ppt
44/75
44Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Camera Specification
TWO WAYS
1.To develop the specifications for the camera
location and orientation uses a series of
coordinate system transformation.
2. OpenGL API
gluLookAt(cop_x,cop_y,cop_z,at_x,at_y,at_z,up_x,up_y,
up_z);
gluPerspective(field _of_view,aspect_ratio,near,far);
-
8/12/2019 unixjava.ppt
45/75
45Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
The first function call points the camerafrom a center of projection toward a
desired point(the at point),with a
specified up directionfor the camera. The second selects a lens for a
perspective view(the field of view) and
how much of the world that the camerashould image.
-
8/12/2019 unixjava.ppt
46/75
46Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Lights and Materials
Types of lights- Point sources vs distributed sources
- Spot lights
- Near and far sources
- Color properties
Material properties- Absorption: color properties
- Scattering- Diffuse
- Specular
Th M d li R d i
-
8/12/2019 unixjava.ppt
47/75
47Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
The Modeling-Rendering
paradigm
Modeling-rendering pipeline
Modeler Renderer
Interface file
-
8/12/2019 unixjava.ppt
48/75
48Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
In CAD and movie ,we can separate the modeling
of the scene from theproduction of the image or
the rendering of the scene.
For example, consider the production of a singleframe in an animation.
- Design and position our objects . we do not need to work
with detailed images of the objects.
- Render it ,adding light sources, material properties, othereffects to form a production quality image. It requires more
computation time.
-
8/12/2019 unixjava.ppt
49/75
49Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Interface file- produced by modeler . Describes the objects and that contains additional
information important only to the renderer, such as lightsources,viewer location and material properties.
Advantage-same file for different renderer.
This paradigm has become popular as a method forgenerating computer games and images over the internet.
Models, including the geometric objects, lights, cameras,and material properties are placed in a data structurecalled a scene graphthat is passed to a renderer or agame engine.
-
8/12/2019 unixjava.ppt
50/75
50Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
A SEQUENCE OF IMAGES
Color plate 1 shows an image of an artistscreation of a sun-like object.
Color plate 2 shows the object rendered usingonly line segments. The rendered object shows
only the outlines of the parts.This type ofimage is known as a wireframe image .
Color plate 3 the same object has beenrendered with flat polygons. Certain surfaces
are not visible becausethere is a solidsurface between them an the viewer.
-
8/12/2019 unixjava.ppt
51/75
51Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Color plate 4 illustrates smooth shadingof the polygonsthat approximate the object.
Color plate 5 shows a more sophisticated wireframemodel .
Color plate 6 and 7 we add surface textureto our object.
Color plate 6 use a technique called bump mappingthatgives the appearance of a rough surface.
Color plate 7 uses an environment mapwhich gives thesurface of a mirror.
Color plate 8 shows a small area of the rendering of theobject.
-
8/12/2019 unixjava.ppt
52/75
52Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
THE GRAPHICS
ARCHITECTURES
Early graphics system
Display processor architecturePipeline architecture
-
8/12/2019 unixjava.ppt
53/75
53Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
THE GRAPHICS ARCHITECTURES
One side of API is the application program.
On the other side is some combination of
hardware and software that implements the
functionality of the API. Fig:Early graphics system
HostDigital to
analog Monitor
-
8/12/2019 unixjava.ppt
54/75
54Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
THE GRAPHICS ARCHITECTURES
The display in early graphics system wasbased on a calligraphic CRT display.
the job of the host computer was to run
the application program and to computethe endpointsof the line segments inthe image.
This information had to be sent to the
display at a rate highenough to avoidflickeron the display.
Refreshing is very slow.
-
8/12/2019 unixjava.ppt
55/75
55Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pipeline Architectures
Pipelining is similar to an assembly line ina car plant.
As the chassis passes down the line ,
series of operations is performed on it,each using specialized tools andworkers, until at the end, the assemblyprocess is complete.
Throughput-the number of carsproduced in a given time.
Display processor
-
8/12/2019 unixjava.ppt
56/75
56Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Display processor
architecture
HostDisplay
processor
Display
list
Monitor
-
8/12/2019 unixjava.ppt
57/75
57Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
These Display processors had conventional
architectures but included instructions to display
primitives on the CRT.
Advantage- The instructions to generate the image could be
assembled once in the host and sent to the display
processor, where they were stored in the display
processors own memory as a display list or display file
The display processor would then execute repetitivelytheprogram in the display list, at a rate sufficient to avoid
flicker.
-
8/12/2019 unixjava.ppt
58/75
58Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Pipeline Architectures
Fig: Arithmetic pipelineb a
c
In the pipeline ,there is an adder and a multipler.
we have to carry out the same computation with manyvalues of a,b, and c.
The multiplier can pass on the results of its calculationto the adder and can start its next multiplication while theadder carries out the second step of the calculation on thefirst set of data.
* +
-
8/12/2019 unixjava.ppt
59/75
59Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
The graphics pipeline
Each object comprises a set of graphical primitives.
Each primitive comprises a set of vertices.
Process all these vertices in a similar manner to form an imagein the frame buffer.
All steps can be implemented in hardware on the graphicscard.
-
8/12/2019 unixjava.ppt
60/75
60Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
The graphics pipeline
Four major steps in the imaging process:- Vertex processing
- Clipping and primitive assembly
- Rasterization- Fragment processing
-
8/12/2019 unixjava.ppt
61/75
61Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Vertex processing
Each vertex is processed independently. Major function
Coordinate transformations
Compute a color for each vertex
We can represent each change of coordinate systems
by a matrix. We can represent successive changes in coordinate
systems by multiplying, or concatenating,theindividual matrices into a single matrix.
After multiple stages of transformation, the
geometry is transformed by a projectiontransformation.
The assignment of vertex colors can besimple.
Clipping and primitive
-
8/12/2019 unixjava.ppt
62/75
62Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Clipping and primitive
assembly
Must do clipping because of the limitation that noimaging system can see the whole world at once.
The human retina-90 degree field of view.
Cameras have film of limited size.
In the synthetic camera ,clipping volume is
considered. The projections of objects in this volume appear in
the image.
Those that are outside do not and are said to beclipped out.
Clipping must be done on a primitive by primitive basisrather than on vertex by vertex basis.
The output of this stage is a set of primitives whoseprojections can appear in the image.
-
8/12/2019 unixjava.ppt
63/75
63Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Rasterization
If an object is not clipped out, the appropriate pixels in theframe buffer must be assigned colors
Rasterizer produces a set of fragments for each object
Fragments are potential pixels- Have a location in frame bufffer
- Color and depth attributes
Vertex attributes are interpolated over objects by therasterizer.
For example,- if three vertices specify a triangle filled with a solid color,the rasterizer must
determine which pixels in the frame buffer are inside the polygon.
The output of the rasterizer is a set of fragments for each primitive. Fragment-pixel location,color,depth information.
-
8/12/2019 unixjava.ppt
64/75
64Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Fragment Processing
The final block takes in the fragments generatedby rasterizer updates the pixels in the framebuffer.
The color of the fragment may be altered bytexture mapping or bump mapping.
The color of the pixel that corresponds to afragment can also be read from the frame bufferand blended with the fragments color to createtranslucenteffect.
Fragments may be blocked by other fragmentscloser to the camera
- Hidden-surface removal
-
8/12/2019 unixjava.ppt
65/75
65Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
PROGRAMMABLE PIPELINES
The commodity graphics market is dominated by graphicscardsthat have pipelines built into the graphics processingunit.
Pipeline architectures had a fixed functionality. Basic operationsavailable with in the pipeline were fixed.
For example, there was only one lighting model for how to
compute a shade using the specified light sources andmaterials.
Recently, both the vertex processor and the fragmentprocessorare now programmable by the application program.
Vertex programs can alter the location or color of each vertex asit flows through the pipeline.
Thus we can implement a variety of light material models orcreate new kinds of projections.
Fragment programs allows us to use textures.
PERFORMANCE
-
8/12/2019 unixjava.ppt
66/75
66Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
PERFORMANCE
CHARACTERISTICS There are two fundamentally different types of processing in our pipeline
architecture.- Front end processing
- Back end processing
Front end processing
Geometric processing, based on processing vertices through the varioustransformations, vertex shading, clipping, and primitive assembly.
it involves floating point calculation.
VLSI implementation for many of these operations in a specialpurposechip .
Today Graphics workstations and commodity graphics cards use graphicsprocessing units(GPUs).
GPUs perform most of the graphics operations at the chip level.
Back end processing
different from front end, it moves block of bits quickly using architectures.
The overall performance of a system is characterized by how fast we canmovegeometric entities through the pipeline and by how many pixels persecond we can alterin the frame buffer.
Graphics cards use GPUs that contain the entire pipeline within a single chip.
GRAPHICS PROGRAMMING-
-
8/12/2019 unixjava.ppt
67/75
67Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
SIERPINSKI GASKET
The sierpinski gasket is an object that can bedefined recursively or randomly.
Suppose start with three points in space. As
long as three the points are not collinear, they
are vertices of a unique triangleand also
define a unique plane. Assume that this plane
is the plane z=0.
Three points are (x1,y1,0),(x2,y2,0),(x3,y3,0)
-
8/12/2019 unixjava.ppt
68/75
68Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Algorithm1.pick an initial point(x,y,z) at random inside the triangle.
2.select one of the three vertices at random.
3.Find the location halfway between the initial point and therandomly selected vertex.
4.Display this new point by putting some sort ofmarker,such as a small circle,at the correspondinglocation on the display.
5.Replace the point at(x,y,z) with this new point.
6.Return to step 2.
Each time that we generate a new point,we display it on theoutput devices.
Where po is the initial location,and p1and p2are the first twolocations generated by our algorithm.
-
8/12/2019 unixjava.ppt
69/75
69Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Main(){
initialize_the_system();
for(some_number_of_points)
{
pt=generate_a_point();
display_the_point(pt);
}
cleanup();
}
PROGRAMMING TWO-
-
8/12/2019 unixjava.ppt
70/75
70Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
PROGRAMMING TWO-
DIMENSIONAL APPLIACATION
Represent a point in the plane z=0 as p=(x,y,0) in the 3Dworld,or as p=(x,y) in two dimensional plane.
P=(x,y,z) or column matrix.
A vertex is a position in space. We use 2 ,3,4D spaces in CG.
Simplest geometric primitive is a point in space. which isspecified by a single vertex.
General formglVertex*();
where * can be interpreted as either nt or ntv.
n--- number of dimensions (2,3,4)
t --- datatypeinteger,float,double
VIf present ,indicates that the variable are specified through apointer to an array.
-
8/12/2019 unixjava.ppt
71/75
71Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
#define GLfloat float
glVertex2i(GLint xi,GLint yi);
glVertex3f(GLfloat x,GLfloat y,GLfloat z);
array
GLfloat vertex[3];
we can use
glVertex3fv(vertex);
Gasket program- random
-
8/12/2019 unixjava.ppt
72/75
72Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Gasket program random
method
In this application,because we are working inthe plane z=0 we could use either the form
glVertex3f(x,y,0)
Or the form glVertex2f(x,y)
We could also define a new data type
typedef GLfloat point[2];
and use some thing like
point p; glVertex2fv(p);
-
8/12/2019 unixjava.ppt
73/75
73Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Void display()
{GLfloat vertices[3][3] = {{0.0,0.0,0.0}, {25.0,50.0,0.0} , {50.0,0.0,0.0}};
GLfloat p[3]={7.5,5.0,0.0};
Int j,k;
glBegin(GL_POINTS);
for(k=0;k
-
8/12/2019 unixjava.ppt
74/75
74Angel: Interactive Computer Graphics 4E Addison-Wesley 2005
Coordinate systems
The users coordinate system became known as the worldcoordinate systemor the application ,model, or objectcoordinate system.
The space in which the objects are described is calledworldcoordinate system- Cartesian x, y coordinates.
Units on the display were first called physical-device coordinatesor device coordinates.
For raster devices, such as most CRT displays,we use the termwindow coordinates or screen coordinates.
The values in the world coordinates must be mappedto screen
coordinates. Mapping is performed automatically as part of the rendering
process.
Mapping from worlddi t t
-
8/12/2019 unixjava.ppt
75/75
coordinates to screen
coordinates