0% found this document useful (0 votes)
66 views40 pages

Lec 3

An API allows applications to interact with computer systems. Graphics APIs like DirectX and OpenGL allow applications to interact with GPUs for rendering graphics. The graphics pipeline is the process of taking a 3D model and rendering it on a 2D display. It involves steps like geometry, projection, lighting and rasterization. Key concepts include vertices, triangles, textures, cameras and depth buffers. Graphics APIs and the pipeline are important for computer graphics, gaming and visualization applications.

Uploaded by

Maimoona Saeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views40 pages

Lec 3

An API allows applications to interact with computer systems. Graphics APIs like DirectX and OpenGL allow applications to interact with GPUs for rendering graphics. The graphics pipeline is the process of taking a 3D model and rendering it on a 2D display. It involves steps like geometry, projection, lighting and rasterization. Key concepts include vertices, triangles, textures, cameras and depth buffers. Graphics APIs and the pipeline are important for computer graphics, gaming and visualization applications.

Uploaded by

Maimoona Saeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Computer Graphics

API’s

► An Application Programming Interface (API) is


defined as the way that applications interact with the
main components of a computer system.
► There are many types of APIs but when it comes to
GPUs, people will generally refer to them as a
graphics API.
GPU

► Graphics processing unit, a specialized


processor originally designed to accelerate
graphics rendering.
► GPUs can process many pieces of data
simultaneously, making them useful for
machine learning, video editing, and gaming
applications.
What exactly is an API?

► API is the acronym for Application Programming Interface,


► which is a software intermediary that allows two applications to talk to each other.
► Each time you use an app like Facebook, send an instant message, or check the
weather on your phone, you're using an API.
Graphic API
Is DirectX an API?

► Microsoft DirectX is a collection of application programming interfaces (APIs) for handling


tasks related to multimedia, especially game programming and video, on Microsoft platforms.
What are the most efficient graphics APIs?

► DirectX 11 is the leading industry standard graphics API.


► Even alongside DirectX 12 Microsoft released DirectX 11.3 at the same time knowing that
the vast majority of people writing graphics engines would not have a requirement for
such low level control that DirectX 12 provides.
How do I choose graphics API?

► The Graphics API preference order can be overridden in the Player Settings (Edit >
Project Settings > Player).
► Select the platform from the tabs at the top (active build target is selected by default).
► You can then deselect Auto Graphics API and choose which Graphics APIs should be
supported for your game.
API’s In Computer Graphics

► These APIs for 3D computer graphics are particularly popular:


► Direct3D (a subset of DirectX)
► Glide.
► Mantle developed by AMD.
► Metal developed by Apple.
► OpenGL and the OpenGL Shading Language.
► OpenGL ES 3D API for embedded devices.
► QuickDraw 3D developed by Apple Computer starting in 1995, abandoned in 1998.
► RenderMan.
Graphics Pipeline
Computer Graphics Pipeline

► In computer graphics,
► a computer graphics pipeline,
► rendering pipeline (The Rendering Pipeline is the sequence of steps that OpenGL takes when rendering
objects. This overview will provide a high-level description of the steps in the pipeline).
► or simply graphics pipeline,
► is a conceptual model that describes what steps a graphics system needs to perform to render a 3D
scene to a 2D screen.
Computer Graphics Pipeline

► Once a 3D model has been created, for instance in a video game or any other 3D computer
animation, the graphics pipeline is the process of turning that 3D model into what the computer
displays.
► Because the steps required for this operation depend on the software and hardware used and the
desired display characteristics, there is no universal graphics pipeline suitable for all cases.
► However, graphics application programming interfaces (APIs) such as Direct3D and OpenGL were
created to unify similar steps and to control the graphics pipeline of a given hardware accelerator.
Structure

► A graphics pipeline can be divided into three main parts: Application, Geometry and Rasterization.
Application

► The application step is executed by the software on the main processor (CPU).
► In the application step, changes are made to the scene as required, for example, by user interaction by
means of input devices or during an animation.
► In a modern Game Engine such as Unity, the programmer deals almost exclusively with the application step,
and uses a high-level language such as C#, as opposed to C or C++.
► The new scene with all its primitives, usually triangles, lines and points, is then passed on to the next step in
the pipeline.
Geometry

► The geometry step (with Geometry pipeline (Geometric manipulation of modelling primitives, such as that
performed by a geometry pipeline, is the first stage in computer graphics systems which perform image generation
based on geometric models)), which is responsible for the majority of the operations with polygons and
their vertices , can be divided into the following five tasks.
► It depends on the particular implementation of how these tasks are organized as actual parallel pipeline steps.
Definitions

► A vertex (plural: vertices) is a point in the world.


► Many points are used to join the surfaces.
► In special cases, point clouds are drawn directly, but this is still the exception.
► A triangle is the most common geometric primitive of computer graphics.
► It is defined by its three vertices and a normal vector
► The normal vector serves to indicate the front face of the triangle and is a vector that is
perpendicular to the surface.
► The triangle may be provided with a color or with a texture (image "glued" on top of it). Triangles
are preferred over rectangles because the three points always exist on a single plane.
Point Cloud

► A point cloud is a set of data points in space.


► The points may represent a 3D shape or object.
► Each point position has its set of Cartesian coordinates (X, Y, Z).
► Point clouds are generally produced by 3D scanners or
by photogrammetry software, which measure many points on the
external surfaces of objects around them.
► As the output of 3D scanning processes, point clouds are used for
many purposes, including to create 3D CAD models.
An example of a 1.2 billion data point cloud render of Beit
Ghazaleh, a heritage site in danger in Aleppo (Syria)
Camera Transformation

► In addition to the objects, the scene also defines a


virtual camera or viewer that indicates the position
and direction of view relative to which the scene is
rendered.
► The scene is transformed so that the camera is at the
origin looking along the Z axis.
► The resulting coordinate system is called the camera
coordinate system and the transformation is ► Left: Position and direction of the virtual viewer
called camera transformation or View (camera), as defined by the user. Right: Positioning the
Transformation. objects after the camera transformation. The light gray
area is the visible volume.
Projection

► The 3D projection step transforms the view volume into a cube with the corner point
coordinates (-1, -1, 0) and (1, 1, 1); Occasionally other target volumes are also used.
► This step is called projection, even though it transforms a volume into another volume, since
the resulting Z coordinates are not stored in the image, but are only used in Z-buffering in
the later rastering step.
► To limit the number of displayed objects, two additional clipping planes are used; The
visual volume is therefore a truncated pyramid (frustum).
► The parallel or orthogonal projection is used, for example, for technical representations
because it has the advantage that all parallels in the object space are also parallel in the
image space, and the surfaces and volumes are the same size regardless of the distance from
the viewer.
frustum
► Maps use, for example, an orthogonal projection (so-called orthophoto), but oblique images
of a landscape cannot be used in this way - although they can technically be rendered, they
seem so distorted that we cannot make any use of them.
3D projection

► A 3D projection (or graphical projection) is a design technique used to


display a three-dimensional (3D) object on a two-dimensional (2D) surface.
► These projections rely on visual perspective and aspect analysis to project a
complex object for viewing capability on a simpler plane.
► This concept of extending 2D geometry to 3D was mastered by Heron of
Alexandria in the first century.
► Heron could be called the father of 3D.
► 3D Projection is the basis of the concept for Computer Graphics simulating
fluid flows to imitate realistic effects.
► Lucas Films 'ILM group is credited with introducing the concept (and even the
term "Particle effect").
Z Buffer

► A depth buffer, also known as a z-buffer, is a type of data buffer used in computer graphics to
represent depth information of objects in 3D space from a particular perspective.
► Depth buffers are an aid to rendering a scene to ensure that the correct polygons properly occlude
other polygons.
► Z-buffering was first described in 1974 by Wolfgang Straßer in his PhD thesis on fast algorithms for
rendering occluded objects.
Lighting

► Often a scene contains light sources placed at different positions to make the lighting of the objects appear
more realistic.
► In this case, a gain factor for the texture is calculated for each vertex based on the light sources and the
material properties associated with the corresponding triangle.
► In the later rasterization step, the vertex values of a triangle are interpolated over its surface.
► A general lighting is applied to all surfaces.
► It is the diffuse and thus direction-independent brightness of the scene.
► The sun is a directed light source, which can be assumed to be infinitely far away.
► The illumination effected by the sun on a surface is determined by forming the scalar product of the
directional vector from the sun and the normal vector of the surface.
► If the value is negative, the surface is facing the sun.
Window-Viewport transformation

► In order to output the image to any target area (viewport) of


the screen, another transformation, the Window-Viewport
transformation, must be applied.
► This is a shift, followed by scaling.
► The resulting coordinates are the device coordinates of the
output device.
► The viewport contains 6 values: height and width of the
window in pixels, the upper left corner of the window in
window coordinates (usually 0, 0) and the minimum and
maximum values for Z (usually 0 and 1).
Rasterization

► Raster Images
► These are the types of images that are produced
when scanning or photographing an object.
► Raster images are compiled using pixels, or tiny dots,
containing unique color and tonal information that
come together to create the image.
► Since raster images are pixel based, they are
resolution dependent.
Rasterization using top left rule

► its center lies completely inside the triangle.


► its center lies exactly on the triangle edge (or
multiple edges in case of corners) that is (or, in
case of corners, all are) either top or left edge.
Rasterization of 3D images

► Rasterization is one of the typical techniques of rendering 3D models.


► Compared with other rendering techniques such as ray tracing, rasterization is extremely fast and therefore used in
most real time 3D engines.
► However, rasterization is simply the process of computing the mapping from scene geometry to pixels and does not
prescribe a particular way to compute the color of those pixels.
► The specific color of each pixel is assigned by shading (which in modern GPUs is completely programmable).
► Shading may be based on physical laws, their approximations or purely artistic intent.
Shading: Flat Shading

► It describes a number of simple lighting


techniques.
► In this case, the lighting value is determined
once for each face.
► The color value can also be determined per
object or per vertex.
Gouraud shading

► (1917) improved the appearance of curved


objects
Phong shading interpolation

► Phong shading interpolation, a more realistic


shading technique developed by Bui Tuong
Phong in 1973
Surface angle to a light source

► Rendered image of a box.


► This image has no shading on its faces, but instead
uses edge lines (also known as wireframe) to separate
the faces and a bolder outline to separate the object
from the background.
Surface angle to a light source

► This is the same image with the lines removed;


the only indication of the interior geometry are
the points of the object's silhouette (the image
of a person, animal, object or scene
represented as a solid shape of a single colour,
usually black, with its edges matching the
outline of the subject).
Surface angle to a light source

► This is the same object rendered with flat


shading.
► The color of the 3 visible front faces has been
set based on their angle (determined by
the normal vector) to the light sources.
Surface angle to a light source

► Shading alters the colors of faces in a 3D model based on


the angle of the surface to a light source or light sources.
► 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

You might also like