SlideShare a Scribd company logo
1 of 24
Download to read offline
1
IMPLEMENTATION OF PHONG
SHADING MODEL OVER ANY
POLYGONAL SURFACE
By
Bhuvnesh Pratap Singh
Undergraduate Student
Department of Computer Science & Engineering
PDPM IIIT DM, Jabalpur
Submitted to Prof. Aparajita Ojha
Department of Computer Science & Engineering
PDPM IIIT DM, Jabalpur
2
Abstract
Using OpenGL Graphics API in C++, the Phongs shading was performed over
polygonal surfaces formed with mesh which skinned the surface. Two mesh
objects such as a pyramid and a round octahedron were taken and the surfaces
were stored in the terms of vertices, edges, and faces. For any object the mesh file
created was read in the programme to obtain the vertices, and then the face normals
were calculated so that finally vertex normal for each vertex could be obtained .
Light source was set up at a desired location in the scene to alleviate the lightning
effect in the scene . Calculation of vertex normals facilitated the application of
Phongs illumination model by interpolating the normals and applying the Phongs
illumination equations at each point on the surface .However the process of
applying Phongs equation at each and every point suffered from graphics card
hardware limitation because of extensive calculations per pixel.
3
TABLE OF CONTENTS
OpenGL …………………………………… 4
Modeling Shapes With Polygonal Meshes…………………………………. 5
Illumination Models………………………………………… 8
Shading Models & Phongs Shading ……………………………………………11
Comparison Between Shading Models…………………………………………17
The key Programming Portion………………………………………………….20
Results & Outputs………………………………………………………… 21
Summary………………………………………………………………… 23
References……………………………………………………………24
4
OpenGL
OpenGL is strictly defined as “a software interface to graphics hardware.” In
essence, it is a 3D graphics and modeling library that is extremely portable and
very fast. Using OpenGL, we can create elegant and beautiful 3D graphics with
nearly the visual quality of a ray tracer. The greatest advantage to using OpenGL is
that it is orders of magnitude faster than a ray-tracer. It uses algorithms carefully
developed and optimized by Silicon Graphics, Inc.(SGI), an acknowledged world
leader in computer graphics and animation.
OpenGL is not a programming language; it is an API (Application Programming
Interface).Whenever we say that a program is OpenGL-based or an OpenGL
application, we mean that it was written in some programming language (such as
C or C++) that makes calls to one or more of the OpenGL libraries. We are not
saying that the program uses OpenGL exclusively to do drawing. It may combine
the best features of two different graphics packages. Or it may use OpenGL for
only a few specific tasks and environment-specific graphics (such as the Windows
GDI) for others.
OpenGL has been extensively used in the creation of this project, in fact most of
the graphics work has been made trivial with the help of OpenGL.
5
Modeling Shapes with Polygonal Meshes
A polygon mesh or unstructured grid is a collection of vertices, edges and faces
that defines the shape of a polyhedral object in 3D Computer Graphics and solid
modeling. The faces usually consist of triangles, quadrilaterals or other simple
convex polygons, since this simplifies rendering, but may also be composed of
more general concave polygons, or polygons with holes.
Fish model using triangular mesh
Triangle meshes:
• Relevant properties:
_ Exactly 3 vertices per face.
_ Any number of faces per vertex.
• Easy adjacency structure
_ Faces store refs to vertices and neighboring faces.
_ Can find most adjacencies in constant time.
6
Triangular Mesh
Polygon meshes may be represented in a variety of ways, using different methods
to store the vertex, edge and face data one of them is:
Face-Vertex Meshes - A simple list of vertices, and a set of polygons that point to
the vertices it uses , and this is the way in which mesh has been stored in this
project.
In the project a 3D pyramid mesh has been used to successfully render the phongs
shading model which is shown in the picture below:
A 3D pyramid mesh used in the Project.
7
This mesh stores vertices list and face list in the following manner :
Vertices list:
Vertex Index X Coordinate Y Coordinate Z Coordinate
1 -1 0 1
2 -1 0 -1
3 1 0 -1
4 1 0 1
5 0 1 0
Similarly the Face list is as follows :
Face Index Type Vertex 1 Vertex 2 Vertex 3 Vertex 4
1 Triangle 1 2 5
2 Triangle 2 3 5
3 Triangle 3 4 5
4 Triangle 4 1 5
5 Quadrilateral 1 2 3 4
Similarly the edge list can also be formulated.
8
Illumination Models
An illumination model (equation) expresses the components of light reflected from
or transmitted(refracted) through a surface. There are three basic light components:
ambient, diffuse, and specular. We will develop local illumination models that
contain some or all of these components. The models are local in that they do not
consider light from objects in the scene. Only light sources generate
light. Light reflected from other objects does has no effect on other objects. Ray
tracing and radiosity models provide these global lighting effects.
Ambient Reflected Light
Ambient light component - non-directional light source that is the product of
multiple reflections from the surrounding environment.
- Assume the intensity Ia of ambient light is constant for all objects
- The ambient-reaction coefficient Ka, which ranges from 0 to 1, determines
the amount of ambient light reflected by the object's surface.
- The ambient-reflection coefficient is a material property.
- The ambient illumination equation is I =KaIa where I is the intensity of
reflected light from a surface with ambient-reflection coefficient ka in an
environment with ambient intensity Ia
Diffuse light
Diffuse light is reflected (or transmitted) from a point with equal intensity in all
directions. Diffusely reflected light is typical for dull, matte surfaces such a paper
or a at wall paint. Diffusely refracted light is typical for frosted glass. Diffuse
reaction is modeled by the Lambert's laws, which basically states that brightness
depends only on the angle θ between the light source direction L and the surface
normal N .
9
Diffuse Illumination Model.
What all this means is that the diffuse illumination equation we'll
use is I = kdIp cos θ;
where
1. θ is the angle between the surface normal N and the light vector L;
2. Ip is the intensity of a point light source.
3. kd is the diffuse-reaction coefficient or diffuse reactivity of the surface which
varies between 0 and 1 and depends on the surface material .Assuming that ~N and
~L are unit length vectors, we can write the cosine as a simple dot product and the
diffuse illumination equation as
I = kd.Ip(N .L)
Specular Light
The specular component of reflection (or refracted) light accounts for highlights
caused by light reflecting (or refracting) primarily in one direction. Specular
reflection is mirror-like; it gives rise to shiny spots on surfaces. The amount of
specularly reflected light seen by a viewer depends on the angle θ between L and N
and the angle φ between the viewer V and the reflected ray R.
Specularly reflected light, unlike diffusely reflected light, is view dependent. In
drawing the specular component we often refer to the “specular bump" which
shows that most light is reflected in a particular direction.
Bui-Thong Phong developed a popular approximation to the specular component of
light. Phong's model is
I = W(θ)Ip cos
n
(φ);
where W(θ) is the fraction striking the surface that is specularly reflected, and n is
the Phong specular-reflection exponent. W(θ) is often set to a constant, call it ks,
and refer to it as the specular-reflection coefficient or specular reflectivity between
1 and several hundred. The Phong exponent n varies from 1 to several hundred.
10
A setting n = 1 gives broad gentle fall off to the highlight, while large settings of n
give focused highlight.
The Complete Illumination Model
Light is additive. To model reflected light we simply add the ambient, diffuse, and
specular terms. That is, our basic illumination model is
Iβ = ka. Iaβ .Odβ + Ipβ [ kd .Odβ .(N . L) + ks . Osβ .(R .V )n
]
Where O sβ is the object specular color component and β represents color
component.
11
Shading Models & Phongs Shading
Basically OpenGL supports have two types of shading techniques :
1. Flat Shading
2. Smooth Shading
We may choose either, but smooth shading is usually more pleasing and can be
more realistic. Unless there is a sound reason to use flat shading in order to
represent data or other communication concepts more accurately, we will probably
want to use smooth shading for our images.
Flat shading of a polygon displays all the points in a polygon with a single color.
This is the effect if you set a color for the polygon, or define a polygon with
glMaterial calls, and then display the polygon with a simple glBegin(...) - glEnd()
pair that includes one single normal vector definition for each polygon.
Smooth shading of a polygon displays the points in a polygon with smoothly-
changing colors across the surface of the polygon. This requires us to define a
separate color for each vertex of our polygon, because the smooth color change is
computed by interpolating the vertex colors across the interior of the triangle.
Computing the color for each vertex is done as usual for a full lighting model, with
the material properties defined, but it requires us to define a normal vector for each
vertex of the polygon because the color of the vertex is determined by the lighting
model that includes this normal.
Figure 8.1 shows see two different images of the same function surface, one with
flat shading (left) and one with smooth shading (right), to illustrate the difference.
12
Clearly the smooth-shaded image is much cleaner, but there are still some areas
where the triangles change direction very quickly and the boundaries between the
triangles still show in the smoothly-shaded image. Smooth shading is very nice,
but it isn't perfect.
The difference between the programming for these two shading models is that the
flat-shaded model uses only one normal per polygon and the smooth-shaded model
uses a separate normal per vertex. It can take a bit more work to compute the
normal at each vertex instead of only once per polygon, but that is the price for
smoothing.
Smooth shading attempts to de-emphasize edges between faces by computing
colors at more points on each face. The two principal types of smooth shading are
Gouraud shading and Phong shading .OpenGL supports only Gouraud shading.
Gouraud Shading
Gouaraud shading computes a different value of color for each pixel. Gouraud
applies the illumination only at triangle vertices, and linearly interpolates the
resulting colors across the triangle. Linear interpolation, however, cannot express
the light intensity peaks, or highlights, at regions of high curvature. Gouraud
shading has a common artifact that it is easy to recognize the underlying triangular
mesh, particularly for low-resolution meshes. This results from the fact that the
derivative of the piece-wise linear color function is not continuous across the
triangle edges. These discontinuities are accentuated by the human visual system,
through a psychophysical Phenomenon know as Mach banding .
Triangle in Gouraud shading
13
In the triangle shown above in the figure in Gouraud shading the three vertex
normals for the vertex A,B,C will be calculated , so that the color at these vertices
can be known and then this color can be interpolated across at each point on the
surface of the triangle.
The above picture demonstrate the assignment of vectors per vertex of the triangle
in the presence of a light source while the picture below demonstrate the process of
interpolation.
14
Phongs Shading
Phong shading was introduced by Phong as the appropriate shading method to go
along with his illumination model. Triangles are shaded by linearly interpolating
the surface normal, defined at each vertex, and re-evaluating the illumination
equation at each pixel. Qualitatively, images generated using Phong shading are
superior to those generated by other methods in the standard rendering pipeline.
However, Phong shading is computationally demanding and it does not run in real-
time even on modern hardware.
Phong shading is expensive not only because illumination has to be evaluated at
each pixel, but also because linearly interpolating the normal is not as simple as
linearly interpolating a scalar. Most commonly, the normal is interpolated by
linearly interpolating each of its scalar components and re-normalizing at each
pixel. Normalization includes a divide, a square root, and a few multiplications and
additions.
15
Some Common aspects of Phongs shading model are as follows:
Phongs shading is a normal - vector interpolating shading.
The normals at vertices are computed as in Goaraud shading.
The normals are interpolated across triangle edges and between edges on
scan line.
The interpolation can be done incrementally for each scan line.
At each pixel, the normal is made to be unit vector and inversed mapped into
world coordinates.
The illumination equation is evaluated to determine the intensity at the pixel.
Phong shading is better than Gouraud when specular components appear in
the illumination model.
*) Gouraud shading may miss highlight altogether if they don’t appear at vertices.
*) Gouraud shading spreads the highlights at a vertex across the surface.
*)Mach bands are reduced in most cases.
16
The above three pictures describe and demonstrate the phongs shading procedure.
17
Comparison between Flat , Gouraud and phongs
shading model generated pictures
A cow generated by Flat Shading
18
A cow generated by Gouraud shading
19
A cow generated by Phongs shading
20
The Key Programming Portion
Since the major aim of this project was to shade any polygonal surface with the
phongs shading model so much obviously it becomes the most important part of
the programming part indeed .
As the theory above states that to implement phongs shading we must find the
intensity per pixel by interpolating the vertex normals all across the surface ; so in
the code written in C++ for this project a function called
void phong(float p[3][3],float n[3][3])
has been created to accomplish this task , this is done by a triangle subdivision
technique which specifically is to divide the mesh triangle in to 9 smaller triangles
as shown in the picture below:
And this way only the trialgle is recursively subdivided until the it goes to the pixel
level.this is how exactly phongs shading has been done in this project.
The second comes computing vertex normals which is done by the function
void computeVertexNormals()
21
Results & Outputs
The pyramid and round octahedron meshes are used for the shading purpose and
below are the results of them along with their Gouraud counterpart:
Pyramid with phong shading
Pyramid with Gouraud shading
22
Round Octa with Phongs shading
Round Octa with Gouraud shading
The above results clearly show that the phongs shading generarated results are far
better then generated with Gouraud shading.
23
Summary
The quality of rendering good 3D scenes with OpenGL is directly proportional to
the amount of time spend with 3D and OpenGL text and programming
environment .To shade any polygonal surface by Phongs shading and by storing
the surface characteristics in face list ,vertex list and edge list requires a thorough
understanding of meshes used to skin the surfaces.
The real chore is to make the Phongs shading happen , since OpenGL itself does a
lot of work ,in fact flat and Gouraud shading are what OpenGL does on its own
just by using few simple predefined functions .But the process of implementing of
Phongs shading is what which can be regarded as the findings of the project. The
way in which almost each and every pixel of the surface is reached and the
interpolation of the vertex normals is carried out to conduct the action is the heart
and soul of the whole task.
To get done with the shading it’s really vital to know that where in the graphics
pipeline the shading is done, in OpenGL the shading process is applied during the
projection matrix after which it’s clipped and viewed . One major problem that
came up during the course of this work was the limitation of separate dedicated
graphics card for high computations because of per pixel shading but this problem
could be rectified by using high end hardware support and the graphics support.
24
References
Accomplishment of any work requires the efforts accumulated from various
sources and this piece of work is no exception either, the project is developed with
the help from following source:
Books
*) “Computer Graphics using OpenGL” by F.S.Hill ,Jr.
*) “OpenGL Super bible” by Richard .S. Wright.
*)“The Red Book”.
Web pages:
. http://local.cis.strath.ac.uk/teaching/ug/classes/52.359/lect13.pdf
. http://groups.csail.mit.edu/graphics/pubs/thesis_drdaniel2.pdf
. http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490-
95to96/guo/report.html
. http://www.cc.gatech.edu/classes/AY2004/cs4451a_fall/smodels/linint.html
The notes provided by Prof. Suzuki Hiromasa during his recent visit to PDPM
IIITDM, Jabalpur on OpenGL programming.

More Related Content

What's hot

Graphics_3D viewing
Graphics_3D viewingGraphics_3D viewing
Graphics_3D viewingRabin BK
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalPunyajoy Saha
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphicanku2266
 
DIGITAL IMAGE PROCESSING - LECTURE NOTES
DIGITAL IMAGE PROCESSING - LECTURE NOTESDIGITAL IMAGE PROCESSING - LECTURE NOTES
DIGITAL IMAGE PROCESSING - LECTURE NOTESEzhilya venkat
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Curves and fractals b spline and bezier
Curves and fractals b spline and bezierCurves and fractals b spline and bezier
Curves and fractals b spline and bezierMr. Amol Sawant
 
Recognition as Graph Matching
  Recognition as Graph Matching  Recognition as Graph Matching
Recognition as Graph MatchingVishakha Agarwal
 
Bezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesBezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesSyed Zaid Irshad
 
Lecture 11 Perspective Projection
Lecture 11 Perspective ProjectionLecture 11 Perspective Projection
Lecture 11 Perspective Projectionguest0026f
 
Hidden lines & surfaces
Hidden lines & surfacesHidden lines & surfaces
Hidden lines & surfacesAnkur Kumar
 
Parallel projection
Parallel projectionParallel projection
Parallel projectionPrince Shahu
 

What's hot (20)

Anti aliasing Computer Graphics
Anti aliasing Computer GraphicsAnti aliasing Computer Graphics
Anti aliasing Computer Graphics
 
Shading
ShadingShading
Shading
 
Graphics_3D viewing
Graphics_3D viewingGraphics_3D viewing
Graphics_3D viewing
 
3 d display methods
3 d display methods3 d display methods
3 d display methods
 
GRPHICS06 - Shading
GRPHICS06 - ShadingGRPHICS06 - Shading
GRPHICS06 - Shading
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
3 d viewing
3 d viewing3 d viewing
3 d viewing
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
DIGITAL IMAGE PROCESSING - LECTURE NOTES
DIGITAL IMAGE PROCESSING - LECTURE NOTESDIGITAL IMAGE PROCESSING - LECTURE NOTES
DIGITAL IMAGE PROCESSING - LECTURE NOTES
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
3 d display-methods
3 d display-methods3 d display-methods
3 d display-methods
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Curves and fractals b spline and bezier
Curves and fractals b spline and bezierCurves and fractals b spline and bezier
Curves and fractals b spline and bezier
 
Recognition as Graph Matching
  Recognition as Graph Matching  Recognition as Graph Matching
Recognition as Graph Matching
 
Bezier and Spline Curves and Surfaces
Bezier and Spline Curves and SurfacesBezier and Spline Curves and Surfaces
Bezier and Spline Curves and Surfaces
 
Ray tracing
 Ray tracing Ray tracing
Ray tracing
 
Lecture 11 Perspective Projection
Lecture 11 Perspective ProjectionLecture 11 Perspective Projection
Lecture 11 Perspective Projection
 
Hidden lines & surfaces
Hidden lines & surfacesHidden lines & surfaces
Hidden lines & surfaces
 
fractals
fractalsfractals
fractals
 
Parallel projection
Parallel projectionParallel projection
Parallel projection
 

Similar to Phong Shading over any Polygonal Surface

Lighting and shading
Lighting and shadingLighting and shading
Lighting and shadingeshveeen
 
7 illumination and-shading computer graphics
7 illumination and-shading computer graphics7 illumination and-shading computer graphics
7 illumination and-shading computer graphicscairo university
 
Deferred Pixel Shading on the PLAYSTATION®3
Deferred Pixel Shading on the PLAYSTATION®3Deferred Pixel Shading on the PLAYSTATION®3
Deferred Pixel Shading on the PLAYSTATION®3Slide_N
 
Visual hull construction from semitransparent coloured silhouettes
Visual hull construction from semitransparent coloured silhouettesVisual hull construction from semitransparent coloured silhouettes
Visual hull construction from semitransparent coloured silhouettesijcga
 
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_r
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_rHeckbert p s__adaptive_radiosity_textures_for_bidirectional_r
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_rXavier Davias
 
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfUNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfSayantanMajhi2
 
Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes  Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes ijcga
 
Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes  Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes ijcga
 
Computer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and MotionComputer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and MotionDamian T. Gordon
 
Neural Radiance Fields & Neural Rendering.pdf
Neural Radiance Fields & Neural Rendering.pdfNeural Radiance Fields & Neural Rendering.pdf
Neural Radiance Fields & Neural Rendering.pdfNavneetPaul2
 
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdfPapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdfAdam Hill
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3stevemcauley
 
APPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWS
APPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWSAPPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWS
APPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWSijcga
 
Two marks with answers ME6501 CAD
Two marks with answers ME6501 CADTwo marks with answers ME6501 CAD
Two marks with answers ME6501 CADPriscilla CPG
 
Fisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous DrivingFisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous DrivingYu Huang
 

Similar to Phong Shading over any Polygonal Surface (20)

Light effect
Light effectLight effect
Light effect
 
CS 354 Lighting
CS 354 LightingCS 354 Lighting
CS 354 Lighting
 
Lighting and shading
Lighting and shadingLighting and shading
Lighting and shading
 
graphics notes
graphics notesgraphics notes
graphics notes
 
7 illumination and-shading computer graphics
7 illumination and-shading computer graphics7 illumination and-shading computer graphics
7 illumination and-shading computer graphics
 
Deferred Pixel Shading on the PLAYSTATION®3
Deferred Pixel Shading on the PLAYSTATION®3Deferred Pixel Shading on the PLAYSTATION®3
Deferred Pixel Shading on the PLAYSTATION®3
 
Visual hull construction from semitransparent coloured silhouettes
Visual hull construction from semitransparent coloured silhouettesVisual hull construction from semitransparent coloured silhouettes
Visual hull construction from semitransparent coloured silhouettes
 
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_r
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_rHeckbert p s__adaptive_radiosity_textures_for_bidirectional_r
Heckbert p s__adaptive_radiosity_textures_for_bidirectional_r
 
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfUNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
 
Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes  Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes
 
Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes  Visual Hull Construction from Semitransparent Coloured Silhouettes
Visual Hull Construction from Semitransparent Coloured Silhouettes
 
Computer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and MotionComputer Vision: Shape from Specularities and Motion
Computer Vision: Shape from Specularities and Motion
 
Neural Radiance Fields & Neural Rendering.pdf
Neural Radiance Fields & Neural Rendering.pdfNeural Radiance Fields & Neural Rendering.pdf
Neural Radiance Fields & Neural Rendering.pdf
 
Notes04.pdf
Notes04.pdfNotes04.pdf
Notes04.pdf
 
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdfPapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
 
TransNeRF
TransNeRFTransNeRF
TransNeRF
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
 
APPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWS
APPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWSAPPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWS
APPEARANCE-BASED REPRESENTATION AND RENDERING OF CAST SHADOWS
 
Two marks with answers ME6501 CAD
Two marks with answers ME6501 CADTwo marks with answers ME6501 CAD
Two marks with answers ME6501 CAD
 
Fisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous DrivingFisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous Driving
 

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Phong Shading over any Polygonal Surface

  • 1. 1 IMPLEMENTATION OF PHONG SHADING MODEL OVER ANY POLYGONAL SURFACE By Bhuvnesh Pratap Singh Undergraduate Student Department of Computer Science & Engineering PDPM IIIT DM, Jabalpur Submitted to Prof. Aparajita Ojha Department of Computer Science & Engineering PDPM IIIT DM, Jabalpur
  • 2. 2 Abstract Using OpenGL Graphics API in C++, the Phongs shading was performed over polygonal surfaces formed with mesh which skinned the surface. Two mesh objects such as a pyramid and a round octahedron were taken and the surfaces were stored in the terms of vertices, edges, and faces. For any object the mesh file created was read in the programme to obtain the vertices, and then the face normals were calculated so that finally vertex normal for each vertex could be obtained . Light source was set up at a desired location in the scene to alleviate the lightning effect in the scene . Calculation of vertex normals facilitated the application of Phongs illumination model by interpolating the normals and applying the Phongs illumination equations at each point on the surface .However the process of applying Phongs equation at each and every point suffered from graphics card hardware limitation because of extensive calculations per pixel.
  • 3. 3 TABLE OF CONTENTS OpenGL …………………………………… 4 Modeling Shapes With Polygonal Meshes…………………………………. 5 Illumination Models………………………………………… 8 Shading Models & Phongs Shading ……………………………………………11 Comparison Between Shading Models…………………………………………17 The key Programming Portion………………………………………………….20 Results & Outputs………………………………………………………… 21 Summary………………………………………………………………… 23 References……………………………………………………………24
  • 4. 4 OpenGL OpenGL is strictly defined as “a software interface to graphics hardware.” In essence, it is a 3D graphics and modeling library that is extremely portable and very fast. Using OpenGL, we can create elegant and beautiful 3D graphics with nearly the visual quality of a ray tracer. The greatest advantage to using OpenGL is that it is orders of magnitude faster than a ray-tracer. It uses algorithms carefully developed and optimized by Silicon Graphics, Inc.(SGI), an acknowledged world leader in computer graphics and animation. OpenGL is not a programming language; it is an API (Application Programming Interface).Whenever we say that a program is OpenGL-based or an OpenGL application, we mean that it was written in some programming language (such as C or C++) that makes calls to one or more of the OpenGL libraries. We are not saying that the program uses OpenGL exclusively to do drawing. It may combine the best features of two different graphics packages. Or it may use OpenGL for only a few specific tasks and environment-specific graphics (such as the Windows GDI) for others. OpenGL has been extensively used in the creation of this project, in fact most of the graphics work has been made trivial with the help of OpenGL.
  • 5. 5 Modeling Shapes with Polygonal Meshes A polygon mesh or unstructured grid is a collection of vertices, edges and faces that defines the shape of a polyhedral object in 3D Computer Graphics and solid modeling. The faces usually consist of triangles, quadrilaterals or other simple convex polygons, since this simplifies rendering, but may also be composed of more general concave polygons, or polygons with holes. Fish model using triangular mesh Triangle meshes: • Relevant properties: _ Exactly 3 vertices per face. _ Any number of faces per vertex. • Easy adjacency structure _ Faces store refs to vertices and neighboring faces. _ Can find most adjacencies in constant time.
  • 6. 6 Triangular Mesh Polygon meshes may be represented in a variety of ways, using different methods to store the vertex, edge and face data one of them is: Face-Vertex Meshes - A simple list of vertices, and a set of polygons that point to the vertices it uses , and this is the way in which mesh has been stored in this project. In the project a 3D pyramid mesh has been used to successfully render the phongs shading model which is shown in the picture below: A 3D pyramid mesh used in the Project.
  • 7. 7 This mesh stores vertices list and face list in the following manner : Vertices list: Vertex Index X Coordinate Y Coordinate Z Coordinate 1 -1 0 1 2 -1 0 -1 3 1 0 -1 4 1 0 1 5 0 1 0 Similarly the Face list is as follows : Face Index Type Vertex 1 Vertex 2 Vertex 3 Vertex 4 1 Triangle 1 2 5 2 Triangle 2 3 5 3 Triangle 3 4 5 4 Triangle 4 1 5 5 Quadrilateral 1 2 3 4 Similarly the edge list can also be formulated.
  • 8. 8 Illumination Models An illumination model (equation) expresses the components of light reflected from or transmitted(refracted) through a surface. There are three basic light components: ambient, diffuse, and specular. We will develop local illumination models that contain some or all of these components. The models are local in that they do not consider light from objects in the scene. Only light sources generate light. Light reflected from other objects does has no effect on other objects. Ray tracing and radiosity models provide these global lighting effects. Ambient Reflected Light Ambient light component - non-directional light source that is the product of multiple reflections from the surrounding environment. - Assume the intensity Ia of ambient light is constant for all objects - The ambient-reaction coefficient Ka, which ranges from 0 to 1, determines the amount of ambient light reflected by the object's surface. - The ambient-reflection coefficient is a material property. - The ambient illumination equation is I =KaIa where I is the intensity of reflected light from a surface with ambient-reflection coefficient ka in an environment with ambient intensity Ia Diffuse light Diffuse light is reflected (or transmitted) from a point with equal intensity in all directions. Diffusely reflected light is typical for dull, matte surfaces such a paper or a at wall paint. Diffusely refracted light is typical for frosted glass. Diffuse reaction is modeled by the Lambert's laws, which basically states that brightness depends only on the angle θ between the light source direction L and the surface normal N .
  • 9. 9 Diffuse Illumination Model. What all this means is that the diffuse illumination equation we'll use is I = kdIp cos θ; where 1. θ is the angle between the surface normal N and the light vector L; 2. Ip is the intensity of a point light source. 3. kd is the diffuse-reaction coefficient or diffuse reactivity of the surface which varies between 0 and 1 and depends on the surface material .Assuming that ~N and ~L are unit length vectors, we can write the cosine as a simple dot product and the diffuse illumination equation as I = kd.Ip(N .L) Specular Light The specular component of reflection (or refracted) light accounts for highlights caused by light reflecting (or refracting) primarily in one direction. Specular reflection is mirror-like; it gives rise to shiny spots on surfaces. The amount of specularly reflected light seen by a viewer depends on the angle θ between L and N and the angle φ between the viewer V and the reflected ray R. Specularly reflected light, unlike diffusely reflected light, is view dependent. In drawing the specular component we often refer to the “specular bump" which shows that most light is reflected in a particular direction. Bui-Thong Phong developed a popular approximation to the specular component of light. Phong's model is I = W(θ)Ip cos n (φ); where W(θ) is the fraction striking the surface that is specularly reflected, and n is the Phong specular-reflection exponent. W(θ) is often set to a constant, call it ks, and refer to it as the specular-reflection coefficient or specular reflectivity between 1 and several hundred. The Phong exponent n varies from 1 to several hundred.
  • 10. 10 A setting n = 1 gives broad gentle fall off to the highlight, while large settings of n give focused highlight. The Complete Illumination Model Light is additive. To model reflected light we simply add the ambient, diffuse, and specular terms. That is, our basic illumination model is Iβ = ka. Iaβ .Odβ + Ipβ [ kd .Odβ .(N . L) + ks . Osβ .(R .V )n ] Where O sβ is the object specular color component and β represents color component.
  • 11. 11 Shading Models & Phongs Shading Basically OpenGL supports have two types of shading techniques : 1. Flat Shading 2. Smooth Shading We may choose either, but smooth shading is usually more pleasing and can be more realistic. Unless there is a sound reason to use flat shading in order to represent data or other communication concepts more accurately, we will probably want to use smooth shading for our images. Flat shading of a polygon displays all the points in a polygon with a single color. This is the effect if you set a color for the polygon, or define a polygon with glMaterial calls, and then display the polygon with a simple glBegin(...) - glEnd() pair that includes one single normal vector definition for each polygon. Smooth shading of a polygon displays the points in a polygon with smoothly- changing colors across the surface of the polygon. This requires us to define a separate color for each vertex of our polygon, because the smooth color change is computed by interpolating the vertex colors across the interior of the triangle. Computing the color for each vertex is done as usual for a full lighting model, with the material properties defined, but it requires us to define a normal vector for each vertex of the polygon because the color of the vertex is determined by the lighting model that includes this normal. Figure 8.1 shows see two different images of the same function surface, one with flat shading (left) and one with smooth shading (right), to illustrate the difference.
  • 12. 12 Clearly the smooth-shaded image is much cleaner, but there are still some areas where the triangles change direction very quickly and the boundaries between the triangles still show in the smoothly-shaded image. Smooth shading is very nice, but it isn't perfect. The difference between the programming for these two shading models is that the flat-shaded model uses only one normal per polygon and the smooth-shaded model uses a separate normal per vertex. It can take a bit more work to compute the normal at each vertex instead of only once per polygon, but that is the price for smoothing. Smooth shading attempts to de-emphasize edges between faces by computing colors at more points on each face. The two principal types of smooth shading are Gouraud shading and Phong shading .OpenGL supports only Gouraud shading. Gouraud Shading Gouaraud shading computes a different value of color for each pixel. Gouraud applies the illumination only at triangle vertices, and linearly interpolates the resulting colors across the triangle. Linear interpolation, however, cannot express the light intensity peaks, or highlights, at regions of high curvature. Gouraud shading has a common artifact that it is easy to recognize the underlying triangular mesh, particularly for low-resolution meshes. This results from the fact that the derivative of the piece-wise linear color function is not continuous across the triangle edges. These discontinuities are accentuated by the human visual system, through a psychophysical Phenomenon know as Mach banding . Triangle in Gouraud shading
  • 13. 13 In the triangle shown above in the figure in Gouraud shading the three vertex normals for the vertex A,B,C will be calculated , so that the color at these vertices can be known and then this color can be interpolated across at each point on the surface of the triangle. The above picture demonstrate the assignment of vectors per vertex of the triangle in the presence of a light source while the picture below demonstrate the process of interpolation.
  • 14. 14 Phongs Shading Phong shading was introduced by Phong as the appropriate shading method to go along with his illumination model. Triangles are shaded by linearly interpolating the surface normal, defined at each vertex, and re-evaluating the illumination equation at each pixel. Qualitatively, images generated using Phong shading are superior to those generated by other methods in the standard rendering pipeline. However, Phong shading is computationally demanding and it does not run in real- time even on modern hardware. Phong shading is expensive not only because illumination has to be evaluated at each pixel, but also because linearly interpolating the normal is not as simple as linearly interpolating a scalar. Most commonly, the normal is interpolated by linearly interpolating each of its scalar components and re-normalizing at each pixel. Normalization includes a divide, a square root, and a few multiplications and additions.
  • 15. 15 Some Common aspects of Phongs shading model are as follows: Phongs shading is a normal - vector interpolating shading. The normals at vertices are computed as in Goaraud shading. The normals are interpolated across triangle edges and between edges on scan line. The interpolation can be done incrementally for each scan line. At each pixel, the normal is made to be unit vector and inversed mapped into world coordinates. The illumination equation is evaluated to determine the intensity at the pixel. Phong shading is better than Gouraud when specular components appear in the illumination model. *) Gouraud shading may miss highlight altogether if they don’t appear at vertices. *) Gouraud shading spreads the highlights at a vertex across the surface. *)Mach bands are reduced in most cases.
  • 16. 16 The above three pictures describe and demonstrate the phongs shading procedure.
  • 17. 17 Comparison between Flat , Gouraud and phongs shading model generated pictures A cow generated by Flat Shading
  • 18. 18 A cow generated by Gouraud shading
  • 19. 19 A cow generated by Phongs shading
  • 20. 20 The Key Programming Portion Since the major aim of this project was to shade any polygonal surface with the phongs shading model so much obviously it becomes the most important part of the programming part indeed . As the theory above states that to implement phongs shading we must find the intensity per pixel by interpolating the vertex normals all across the surface ; so in the code written in C++ for this project a function called void phong(float p[3][3],float n[3][3]) has been created to accomplish this task , this is done by a triangle subdivision technique which specifically is to divide the mesh triangle in to 9 smaller triangles as shown in the picture below: And this way only the trialgle is recursively subdivided until the it goes to the pixel level.this is how exactly phongs shading has been done in this project. The second comes computing vertex normals which is done by the function void computeVertexNormals()
  • 21. 21 Results & Outputs The pyramid and round octahedron meshes are used for the shading purpose and below are the results of them along with their Gouraud counterpart: Pyramid with phong shading Pyramid with Gouraud shading
  • 22. 22 Round Octa with Phongs shading Round Octa with Gouraud shading The above results clearly show that the phongs shading generarated results are far better then generated with Gouraud shading.
  • 23. 23 Summary The quality of rendering good 3D scenes with OpenGL is directly proportional to the amount of time spend with 3D and OpenGL text and programming environment .To shade any polygonal surface by Phongs shading and by storing the surface characteristics in face list ,vertex list and edge list requires a thorough understanding of meshes used to skin the surfaces. The real chore is to make the Phongs shading happen , since OpenGL itself does a lot of work ,in fact flat and Gouraud shading are what OpenGL does on its own just by using few simple predefined functions .But the process of implementing of Phongs shading is what which can be regarded as the findings of the project. The way in which almost each and every pixel of the surface is reached and the interpolation of the vertex normals is carried out to conduct the action is the heart and soul of the whole task. To get done with the shading it’s really vital to know that where in the graphics pipeline the shading is done, in OpenGL the shading process is applied during the projection matrix after which it’s clipped and viewed . One major problem that came up during the course of this work was the limitation of separate dedicated graphics card for high computations because of per pixel shading but this problem could be rectified by using high end hardware support and the graphics support.
  • 24. 24 References Accomplishment of any work requires the efforts accumulated from various sources and this piece of work is no exception either, the project is developed with the help from following source: Books *) “Computer Graphics using OpenGL” by F.S.Hill ,Jr. *) “OpenGL Super bible” by Richard .S. Wright. *)“The Red Book”. Web pages: . http://local.cis.strath.ac.uk/teaching/ug/classes/52.359/lect13.pdf . http://groups.csail.mit.edu/graphics/pubs/thesis_drdaniel2.pdf . http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490- 95to96/guo/report.html . http://www.cc.gatech.edu/classes/AY2004/cs4451a_fall/smodels/linint.html The notes provided by Prof. Suzuki Hiromasa during his recent visit to PDPM IIITDM, Jabalpur on OpenGL programming.