Professional Documents
Culture Documents
Unit No. V Shading, Animation & Gaming
Unit No. V Shading, Animation & Gaming
V
Shading, Animation & Gaming
* 1
Constant Shading
* 2
Gouraud Shading
* 3
Gouraud Shading
* 4
Gourad Shading
• IP=(YP-YB/YA-YB) IA + (YA-YP/YA-YB)IB
• IQ=(XR-XQ/XR-XP) IP + (XQ-XP/XR-XP)IR
• A
• P Q R
• B C
* 5
Phong Shading
N2
P Q R
N1 N3
* 7
Difference Between Phong & Gouraud
Shading
Sr. No. Phong Shading Gouraud shading
1 It displays more realistic 1. It removes the intensity
highlights on a surface. discontinuities exist in constant shading
model.
2 It greatly reduces the Mach-Band 2. It can be combined with a hidden
effect. surface algorithm to fill in the visible
polygons along each scan line.
3 It gives more accurate results. 3. Highlights on the surface are
sometimes displayed with wrong
shapes.
4 It requires more calculations and 4. The linear intensity interpolation can
greatly increases the cost of result bright or dark intensity streaks to
shading steeply. appear on the surface. These bright or
dark intensity streaks are called “Mach
bands”. The Mach Band effect can be
reduced by breaking the surface into a
* greater number of smaller polygons. 8
Difference Between Phong & Gouraud
Shading
Sr. No. Phong Shading Gouraud shading
5 In this method we can calculate In this method we can calculate vertex
the pixel intensity of each scan intensity.
line.
6 This method interpolates the Polygon surfaces are rendered by
normal vectors at the bounding linearly interpolating intensity values.
points along scan line.
7 Using interpolation of two We can calculate normal vector N at
normal vector, we can get vertex V using average of normal vectors
normal vector N. of polygons.
8 It is very effective in dealing with It is effective for shading surfaces.
specular highlights.
9 It is very expensive than gouraud It is less expensive.
shading.
* 9
Difference Between Phong & Gouraud
Shading
Sr. No. Phong Shading Gouraud shading
10 It works better in reflective It does not work better in reflective
model. model.
11 Phong interpolates the Gouraud interpolates the calculated
calculated vertex normals. vertex colours.
12 It is independent on the It is dependent on the relative positions
underlying polygons. of underlying polygons.
* 10
Halftone Shading
• Applications
* 11
Animation
Definition of Animation
* 12
Types of Animation
• Hand-drawn Animation
• Stop-motion Animation
• Computer animation
• Motion-capture animation
Hand-drawn Animation
• In this type of animation, a series of drawings is
photographed
• Each drawing makes up one frame of the film
• The position of the character or object changes very
slightly from frame to frame
• This technique is known as cell animation because
the first animations were drawn on thin plastic
sheets called celluloid
• In 1937, Walt Disney released Snow White and the
Seven Dwarfs, the first full-length animated film
using cell animation
Stop-Motion Animation
• In Stop-Motion Animation,
models are photographed on a
set one frame at a time.
• The frames are played in
sequence to create movement
• Early stop-motion models were
made of modeling clay (ex.
Gumby)
Computer Animation
• Computer Animation
software can be used to
create an animation scene,
cartoon, a video game, or
even a full-length movie
• Computer Animation
reduces the time needed to
produce an animated film
• Software can be
two-dimensional (2D) or
three-dimensional (3D)
Motion Capture Animation
• Motion Capture
Animation is a 3D
representation of a live
performance
• It can be done using 3
different technologies:
» Magnetic
» Optical
» Electro-Mechan
ical
Principles of Animation
• Squash and Stretch
• Illustration of the "squash and stretch"-principle:
Example A shows a ball bouncing with a rigid, non-dynamic movement. In
example B the ball is "squashed" at impact, and "stretched" during fall and
rebound. The movement also accelerates during the fall, and slows down
towards the apex (see "slow in and slow out").
• Animated sequence of a race horse galloping. Photos taken by Eadweard
Muybridge. The horse's body demonstrates squash and stretch in natural
musculature.
• The most important principle is "squash and stretch",[4] the purpose of
which is to give a sense of weight and flexibility to drawn objects. It can be
applied to simple objects, like a bouncing ball, or more complex
constructions, like the musculature of a human face.[5][5][6] Taken to an
extreme point, a figure stretched or squashed to an exaggerated degree
can have a comical effect.[7] In realistic animation, however, the most
important aspect of this principle is the fact that an object's volume does
not change when squashed or stretched. If the length of a ball is stretched
vertically, its width (in three dimensions, also its depth) needs to contract
correspondingly horizontally.
* 18
Anticipation
* 19
Staging
* 20
Straight Ahead Action and Pose to Pose
* 21
Follow Through and Overlapping Action
• Follow through and overlapping actionFollow through and overlapping action is a general
heading for two closely related techniques which help to render movement more
realistically, and help to give the impression that characters follow the laws of physicsFollow
through and overlapping action is a general heading for two closely related techniques which
help to render movement more realistically, and help to give the impression that characters
follow the laws of physics, including the principle of inertiaFollow through and overlapping
action is a general heading for two closely related techniques which help to render
movement more realistically, and help to give the impression that characters follow the laws
of physics, including the principle of inertia. "Follow through" means that loosely tied parts of
a body should continue moving after the character has stopped and the parts should keep
moving beyond the point where the character stopped to be "pulled back" only subsequently
towards the center of massFollow through and overlapping action is a general heading for
two closely related techniques which help to render movement more realistically, and help
to give the impression that characters follow the laws of physics, including the principle of
inertia. "Follow through" means that loosely tied parts of a body should continue moving
after the character has stopped and the parts should keep moving beyond the point where
the character stopped to be "pulled back" only subsequently towards the center of mass
and/or exhibiting various degrees of oscillationFollow through and overlapping action is a
general heading for two closely related techniques which help to render movement more
realistically, and help to give the impression that characters follow the laws of physics,
including the principle of inertia. "Follow through" means that loosely tied parts of a body
should continue moving after the character has stopped and the parts should keep moving
* beyond the point where the character stopped to be "pulled back" only subsequently 22
towards the center of mass and/or exhibiting various degrees of oscillation damping.
Slow In and Slow Out
* 23
Arc
* 24
Secondary Action
* 26
Exaggeration
* 27
Solid drawing
* 28
Appeal
* 29
Introduction to Animation
Computer Animation
* 30
Animation Sequences
• Conventional Animation
• Storyboard
• Key frames
• In-between
• Pencil Test
• Cels
• Route-Sheet
• Exposure Sheet
* 31
Steps in Design of Animation Sequence
• Story of Animation
• Detailed Layout
• Sound Recording
• To draw Key frames
• To obtain pencil test frames
• To transfer pencil test frames to cels.
• To give color & prepare a film.
* 32
Animation sequences
1. Storyboard layout:
– a series of sketches or photographs
showing the sequence of shots or images
planned for a film
• It is outline of the action
• Set of basic events that are to take place in specific order
• It gives motion sequence
• It consists of rough sketches
* 33
Animation sequences
2.object definition :
* 34
Animation sequences
3.Key frame specification
– Key frame is detailed drawing of the scene at certain time in
animation sequence
– They are positioned according to time for that frame
4 . In-between frames
– These are intermediate frames between the key frames
– Usually there are 3 to 5 in-between frames between two key
frames
– E.g. film requires 24 frames per second
* 35
Computer Based Animation
• Digitization
• Composition
• In-Between Frames
• Equivalent of pencil test
• Generation of In-between Frames.
* 36
Methods of Controlling Animation
* 37
Guidelines of Animation
• Illustration
• Effect
• Relationship
• Transition
• Feedback
* 38
Rules Required for Animation
• Do’s
• Illustration animations
• Effect Animations
• Relationship Animations
• Transition Animations
• Feedback Animations
• Don’ts
* 39
Animation Languages
• Linear List Notations
• Graphical Languages
* 40
Computer animation Languages
* 43
Gaming Platforms
• A gaming Platform is also called as a videogame platform or videogame system
• There are some advantages and disadvantages of PC & console gaming Platform.
• Advantages of PC:
• 1. Multiple uses other than gaming.
• 2. Great multi-player capability via the Internet.
• 3. Upgradeable.
• Disadvantages of PC:
• 1. Expensive
• 2. Smaller library of games
• Advantages of Console:
• 1. Relatively inexpensive
• 2. Huge variety of games
• 3. Sports games thrive on consoles.
• Disadvantages of Console:
• Not upgradeable
• Limited multi-player capability.
* 44
Intel i860
• The Intel i860 is also known as 80860. The i860 was a RISC
microprocessor from Intel, first released in 1989.
• Features : VLIW & Powerful support for high speed floating
point operations.
• The design mounted a 32 bit ALU “Core” along with a 64 bit
FPU that was itself built in three parts: an adder, a multiplier
and a graphics processor.
• The system had separate pipelines for the ALU, floating point
adder and multiplier.
• The CPU could execute the majority of floating-point
instructions either in pipelined mode or in scalar mode.
* 45
Intel i860
* 46
Workstation
• Introduction
* 47
Block Diagram of NVDIA Workstation
* 48
Graphics Memory Pipeline
Modeling
Transform Prevertex Viewing Primitive
ation Lighting Transformation Generation
Projection
Transformation Clipping Rasterization
* 50
Functions of OpenGL
• Display List
• Feedback
• Alpha Bending
• Pixel Operations
• Texture Mapping
• Color Index Mode
• Polynomial Evaluators
* 51
Features of OpenGL
• Scaling & Rotation
• Performance
• Transparency
• Alpha Bending
• Rendering in 3D
• Primitive Operations
• Hardware
* 52
Sample Program
• #include<stdio.h>
• #include<GL/gl.h>
• #include<GL/glu.h>
• #include<GL/glut.h>
• int x,y;
• void Init()
• {
• glClearColor(1,1,1,0);
• glColor3f(0,0,0);
• /* glViewport(0 , 0 , 640 , 480); */
• /* glMatrixMode(GL_PROJECTION); */
• /* glLoadIdentity(); */
• gluOrtho2D(0 , 640 , 0 , 480);
• }
•
* 53
Sample Program
* 54
Sample Program
• void draw(void)
• {
• char *text;
• text = "Sandeep";
• //Background color
• glClearColor(0,1,0,1);
• glClear(GL_COLOR_BUFFER_BIT );
• //Draw order
• glBegin(GL_LINES);
• glVertex2i(10,10);
• glVertex2i(100,100);
• glEnd();
• glBegin(GL_LINES);
• glVertex2i(glutGet(GLUT_WINDOW_WIDTH)/2,0);
• glVertex2i(glutGet(GLUT_WINDOW_WIDTH)/2,glutGet(GLUT_WINDOW_HEIGHT));
• glEnd();
• glBegin(GL_POINTS);
•
• glVertex2i(x,y);
• glEnd();
• renderBitmapString(200,200, text);
• glFlush();
• }
* 55
Sample Program
• glutDisplayFunc(draw);
• glutMainLoop();
• return 0;
• }
* 56
Output
Sandeep
* 57
DDA Line Drawing Program Using
OpenGL
• #include <stdio.h>
• #include <math.h>
• #include <GL/glut.h>
• #include <GL/glu.h>
• #include <GL/gl.h>
• float round_value(float v)
• {
• return floor(v + 0.5);
• }
* 58
DDA Line Drawing Program Using
OpenGL
• void LineDDA(void)
• {
• double dx=(X2-X1);
• double dy=(Y2-Y1);
• double steps;
• float xInc,yInc,x=X1,y=Y1;
• /* Find out whether to increment x or y */
• steps=(abs(dx)>abs(dy))?(abs(dx)):(abs(dy));
• xInc=dx/(float)steps;
• yInc=dy/(float)steps;
* 60
DDA Line Drawing Program Using
OpenGL
• void main(int argc, char **argv)
• {
• printf("Enter two end points of the line to be drawn:\n");
• printf("\n************************************");
• printf("\nEnter Point1( X1 , Y1):\n");
• scanf("%lf%lf",&X1,&Y1);
• printf("\n************************************");
• printf("\nEnter Point1( X2 , Y2):\n");
• scanf("%lf%lf",&X2,&Y2);
•
• /* Initialise GLUT library */
• glutInit(&argc,argv);
• /* Set the initial display mode */
• glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
• /* Set the initial window position and size */
• glutInitWindowPosition(0,0);
• glutInitWindowSize(640,480);
• /* Create the window with title "DDA_Line" */
• glutCreateWindow("DDA_Line");
• /* Initialize drawing colors */
• Init();
• /* Call the displaying function */
• glutDisplayFunc(LineDDA);
• /* Keep displaying untill the program is closed */
• glutMainLoop();
• }
* 61
* 62