Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 33

Computer Graphics:

Rasterization of 3D Images
Week 3

Presentation By: Ms.Ifrah Mansoor


Topics to be covered
• Rasterization of 3D images
• Shading Techniques
• Lightning
• Computer Graphic as an Art
• Elements of Computer Drawing
• Active vs Passive Graphics
Rasterization of 3D images
• What is Raster image?
Raster graphics, also
called bitmap graphics, a
type of digital image that uses
tiny rectangular pixels, or
picture elements, arranged in a
grid formation to represent an
image.
Rasterization of 3D images
• Raster vs Vector?
Raster files display a
wider array of
colors, permit
greater color editing,
and show finer light
and shading than
vectors — but they
lose image quality
when resized.
Rasterization of 3D images
• What is Rasterization?
• When you take a vector image and convert it into a raster image, you convert
shapes and lines into pixels and dots. This process is called Rasterization.
• Why Rasterization?
• Rasterization is useful for video display, printing, and storage.
Example: Some printers may require you to raster your lines and shapes for the
purpose of securing the size and layout of the whole image.

• Raster graphics are easy to use and easy to edit. It is also commonly used in real-
time 3D graphics processing, as rasterization is an easy and fast way to convert
images for display
Rasterization of 3D images
What is Rasterization?
• First job: enumerate the pixels covered by a primitive
– Simple definition: pixels whose centers fall inside
• Second job: interpolate values across the primitive

Vector Image Rasterized Vector Image


Rasterized Image
There are different techniques on how to assign a color to the
rasterized pixels:

•Shading model – technique that defines when and where do we calculate the components needed for light
calculations.
•Lighting model – technique that defines how do we calculate the final color given all the components
required for it.
•Material properties – properties of the material that determine how much an object with this material
reflects a light from different channels.
•Light properties – properties of a light source that determine how much this light source emits light from
different channels
Shading
• In computer graphics, shading refers to the process of altering
the color of an object/surface/polygon in the 3D scene, based
on the surface's angle to lights, its distance from lights, its angle
to the camera and material properties.

• We use these techniques to create more realistic 3D effect


images.
Shading Techniques
• There are three main shading models that are used for different
results:
• Flat shading,
• Gouraud shading
• Phong shading.
Shading Techniques

• Flat Shading:
• The lighting is evaluated only once for
each polygon (usually for the first vertex
in the polygon based on the polygon's
surface normal and on the assumption
that all polygons are flat.

• The computed color is used for the whole


polygon, making the corners look sharp
Shading Techniques
• Gouraud shading:
• is a type of interpolated shading where
the values inside of each polygon are a
blend of its vertex values.
• Each vertex is given its own normal
consisting of the average of the surface
normals of the surrounding polygons.
• The lighting and shading at that vertex is
then calculated using the average normal
and the lighting model of choice
Shading Techniques
• Phong shading:
• Phong shading is similar to Gouraud
shading, except that instead of
interpolating the light intensities the
normals are interpolated between
the vertices and the lighting is
evaluated per-pixel.
• Thus, the specular highlights are
computed much more precisely than
in the Gouraud shading model.
Gouraud Vs Phong Shading

At Gouraud shading the light is calculates per vertex (Vertex


shader), at Phong shading the light is calculates per
fragment (fragment shader).

Therefore, Gouraud shading calculates the light for the


vertices (corners) of a primitive and interpolates the light for
the fragments covered by the primitive.
With Phong shading, the light is calculated separately for
each fragment.
Shading and Lightning
• Shading is performed during the rendering process by a program called a shader.
• Shading alters the colors of faces in a 3D model based on the angle of the surface to a light source or
light sources

Surface angle to a light source


• The first image below has the faces of the box rendered, but all in the same color. Edge lines have been
rendered here as well which makes the image easier to see.

• The second image is the same model rendered without edge lines. It is difficult to tell where one face of
the box ends and the next begins.

• The third image has shading enabled, which makes the image more realistic and makes it easier to see
which face is which
Shading and Lightning
What is Object Silhouette?
A silhouette is an object or scene represented as a solid shape of a single color, usually black,
with its edges matching the outline of the subject. We cannot determine the edges or patterns
in the object.

In the given figure, we cant identify the shape of the object. As the object is in solid color and
edges color are same as the surface color. Such objects are called Object Silhouette.

However, by using shading and lightning techniques the object shape and color can be
determined.
Lightning
• When a shader computes the result color, it uses a lighting model to determine the amount of light
reflected at specific points on the surface.

• Different lighting models can be combined with different shading techniques — while lighting says how
much light is reflected, shading determines how this information is used in order to compute the final
result.

• It may for example compute lighting only at specific points and use interpolation to fill in the rest. The
shader may also decide about how many light sources to take into account etc
Lightning
• Types of Lightning in OpenGL:
1. Ambient lighting
An ambient light source represents an omni-directional, fixed-intensity and fixed-color light
source that affects all objects in the scene equally
Lightning
• Types of Lightning in OpenGL :

2. Point lighting
Light originates from a single point and spreads outward in all directions
Lightning
• Types of Lightning in OpenGL :

3. Spotlighting
Models a spotlight: light originates from a single point and
spreads outward in a cone.

4. Area lighting
Light originates from a small area on a single plane.
(A more realistic model than a point light source.)
Lightning
• Types of Lightning in OpenGL :

5. Directional lighting
A directional light source illuminates all objects equally from a given direction, like an area light
of infinite size and infinite distance from the scene; there is shading, but cannot be any distance
falloff. This is like the sun.
Lightning
• Lighting Interactions in OpenGL :
In computer graphics, the overall effect of a light source on an object is
determined by the combination of the object's interactions with it usually
described by at least three main components:
1. Ambient
2. Diffuse
3. Specular
Lightning
• Lighting Interactions in OpenGL :

• Ambient
As ambient light is directionless, it interacts uniformly across all surfaces, with its intensity determined by the
strength of the ambient light sources and the properties of objects' surface materials

• Diffuse
Diffuse lighting or diffuse reflection is the direct illumination of an object by an even amount of light interacting
with a light-scattering surface.

• Specular
The specular lighting component gives objects shine and highlights. This is distinct from mirror effects
because other objects in the environment are not visible in these reflections. Instead, specular lighting
creates bright spots on objects based on the intensity of the specular lighting component and the
specular reflection coefficient of the surface.
Lightning
• Lighting Interactions in OpenGL :
EXAMPLE:
Computer Graphics is an Art
• Art is the term for a range of human activities that express human
creativity and imagination in forms such as painting, music, dance,
and literature
• Computer graphics deals with generating images and art with the aid
of computers.
• A computer graphic artist primarily creates artwork with computer
software. He or she may work in the multimedia, film, or game
animation industries.
• Hence, Art is an application of Computer graphics.
Computer Graphics is an Art
Elements of Drawing Pictures
• Point
It is a basic element in graphics. To draw a line, you need two points between which you can draw a
line. In the following three algorithms, we refer the one point of line as (X0,Y0) and the second
point of line as (X1,Y1).

• Line
In graphics, a line can be described as a single point that continues for a distance, or
as the connection between two points
Elements of Drawing Pictures
• Polygon
Polygons are used in computer graphics to compose images that are three-
dimensional in appearance.

• Polyline
A polyline is a list of points, where line segments are drawn between
consecutive points. A polyline has the following properties: Points. The
vertices of the line. Line segments are drawn between consecutive
points.
Elements of Drawing Pictures
Examples:
Elements of Drawing Pictures
• Pixel
A pixel is the smallest unit of a digital image or graphic that can be displayed and
represented on a digital display device. Pixels are combined to form a complete
image, video, text, or any visible thing on a computer display.

• Picture
A computer image is a picture composed of an array of elements called pixels.

• Resolution
Resolution indicates the number of pixels that are displayed per inch for an
image (or pixels per centimeter).
Pixels VS Resolution
• Pixels
• Graphic images are made up of tiny dots called pixels.
• Each pixel has a particular address on the screen.
• Resolution
• It is defined as the maximum number of pixels or dots can be displayed on the
screen.
• Examples:800 by 600 pixels,1024 by 768 pixels,1152 by 864 pixels etc.
Elements of Drawing Pictures

Pixel
Active and Passive Graphic System
(a) Non-Interactive/ Passive Computer Graphics:
• In non-interactive computer graphics, the picture is produced on the monitor, and the
user does not have any controlled over the image, i.e., the user cannot make any change
in the rendered image. One example of its Titles shown on T.V.
• Non-interactive Graphics involves only one-way communication between the computer
and the user, User can see the produced image, and he cannot make any change in the
image.
(b) Interactive / Active Computer Graphics:
• In interactive Computer Graphics user have some controls over the picture, i.e., the user
can make any change in the produced image. One example of it is the ping-pong game.
• Interactive Computer Graphics require two-way communication between the computer
and the user. A User can see the image and make any change by sending his command
with an input device

You might also like