Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Presented by Adil
how to install openGL package
• open visual studio and click on tools tab
2nd:select library package manager and
click package manager console
3rd:console window will appear at
the bottom of screen and write the
following command
Install-Package freeglut
see next s...
adilm717@gmail.com Adiil (Mcs)
install-package freeglut
what is shading?
• The appearance of lights and darks found in a
work of art.
• In computer graphics, shading is a method ...
some real word examples
Type of shading
• Flat shading
– glShadeModel(GL_FLAT)
• Smooth (Gouraud) shading
– glShadeModel(GL_SMOOTH)
Flat Shading
• The simplest shading algorithm, called flat shading,
consists of using an illumination model to determine t...
Gourand Shading
• This shading algorithm was first described by H.
Gouraud in 1971. It is also called bilinear intensity
i...
complete coding#include <Gl/glut.h>
void Draw() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TE...
// Draw a triangle with one red, green, and blue vertex.
glBegin(GL_TRIANGLES);
glMaterialfv(GL_FRONT, GL_AMBIENT, qaRed);...
OUT PUT
Shading and two type of shading flat shading and gauraud shading with coding exampe
Shading and two type of shading flat shading and gauraud shading with coding exampe
Upcoming SlideShare
Loading in …5
×

Shading and two type of shading flat shading and gauraud shading with coding exampe

3,069 views

Published on

what is shading and type of shading flat shading and gauraud shading with coding example

Published in: Education
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Shading and two type of shading flat shading and gauraud shading with coding exampe

  1. 1. Presented by Adil
  2. 2. how to install openGL package • open visual studio and click on tools tab
  3. 3. 2nd:select library package manager and click package manager console
  4. 4. 3rd:console window will appear at the bottom of screen and write the following command Install-Package freeglut see next slide
  5. 5. adilm717@gmail.com Adiil (Mcs) install-package freeglut
  6. 6. what is shading? • The appearance of lights and darks found in a work of art. • In computer graphics, shading is a method used to create or enhance the illusion of depth in an image by varying the amount of darkness in the image. As you can see, three levels of shading are used in the example of a rectangular object, thus making it appear to be three dimensional. Shading can also be used to make some objects appear to be in front of or behind other objects in the image
  7. 7. some real word examples
  8. 8. Type of shading • Flat shading – glShadeModel(GL_FLAT) • Smooth (Gouraud) shading – glShadeModel(GL_SMOOTH)
  9. 9. Flat Shading • The simplest shading algorithm, called flat shading, consists of using an illumination model to determine the corresponding intensity value for the incident light, then shade the entire polygon according to this value. Flat shading is also known as constant shading or constant intensity shading. Its main advantage is that it is easy it implement. • In the case of curved objects, when the surface changes gradually and the light source and viewer are far from the surface. • In general, when there are large numbers of plane surfaces. • when problem is not light, some thing else
  10. 10. Gourand Shading • This shading algorithm was first described by H. Gouraud in 1971. It is also called bilinear intensity interpolation. Gouraud shading is easier to understand in the context of the scan-line algorithm used in hidden surface removal, For now, assume that each pixel is examined according to its horizontal (scan-line) placement • here edges are visible • In modern graphics hardware, gourand shading is probably at least as fast as flat shading,and faster than phong shading. • Gouraud is enabled by default
  11. 11. complete coding#include <Gl/glut.h> void Draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); // Set material properties GLfloat qaBlack[] = {0.0, 0.0, 0.0, 1.0}; GLfloat qaGreen[] = {0.0, 1.0, 0.0, 1.0}; GLfloat qaRed[] = {1.0, 0.0, 0.0, 1.0}; GLfloat qaBlue[] = {0.0, 0.0, 1.0, 1.0}; GLfloat qaWhite[] = {1.0, 1.0, 1.0, 1.0}; GLfloat qaLowAmbient[] = {0.2, 0.2, 0.2, 1.0}; GLfloat qaFullAmbient[] = {1.0, 1.0, 1.0, 1.0}; for (int iIndex = 0; iIndex < 2; ++iIndex) { if (iIndex == 0) { glShadeModel(GL_FLAT); } else { glShadeModel(GL_SMOOTH); } //Set, ambient, diffuse and specular lighting. Set ambient to 20%. glMaterialfv(GL_FRONT, GL_AMBIENT, qaGreen); glMaterialfv(GL_FRONT, GL_DIFFUSE, qaGreen); glMaterialfv(GL_FRONT, GL_SPECULAR, qaWhite); glMaterialf(GL_FRONT, GL_SHININESS, 128.0); glLightfv(GL_LIGHT0, GL_AMBIENT, qaLowAmbient); // Draw a sphere glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glTranslatef(-0.5 + (float)iIndex, 0.5, -2.0); glutSolidSphere(.5, 20, 20); glPopMatrix(); // Turn off diffuse and specular reflection. Set ambient light to full. glMaterialfv(GL_FRONT, GL_DIFFUSE, qaBlack); glMaterialfv(GL_FRONT, GL_SPECULAR, qaBlack); glLightfv(GL_LIGHT0, GL_AMBIENT, qaFullAmbient);
  12. 12. // Draw a triangle with one red, green, and blue vertex. glBegin(GL_TRIANGLES); glMaterialfv(GL_FRONT, GL_AMBIENT, qaRed); glVertex3f(-.5 + (float)iIndex, 0.0, -.2); glMaterialfv(GL_FRONT, GL_AMBIENT, qaGreen); glVertex3f(-.933 + (float)iIndex, -.75, -.2); glMaterialfv(GL_FRONT, GL_AMBIENT, qaBlue); glVertex3f(-.067 + (float)iIndex, -.75, -.2); glEnd(); } glFlush(); } void Initialize() { glClearColor(0.0, 0.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -3.0, 3.0); // Lighting set up glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // Set lighting intensity and color GLfloat qaAmbientLight[] = {0.2, 0.2, 0.2, 1.0}; GLfloat qaDiffuseLight[] = {0.8, 0.8, 0.8, 1.0}; GLfloat qaSpecularLight[] = {1.0, 1.0, 1.0, 1.0}; glLightfv(GL_LIGHT0, GL_AMBIENT, qaAmbientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, qaDiffuseLight); glLightfv(GL_LIGHT0, GL_SPECULAR, qaSpecularLight); // Set the light position GLfloat qaLightPosition[] = {0.0, 1.0, -.5, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, qaLightPosition); } int main(int iArgc, char** cppArgv) { glutInit(&iArgc, cppArgv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(250, 250); glutInitWindowPosition(200, 200); glutCreateWindow("XoaX.net"); Initialize(); glutDisplayFunc(Draw); glutMainLoop(); return 0;
  13. 13. OUT PUT

×