The RGB color model is one of the most widely used color representation method in computer graphics. It use a color coordinate system with three primary colors:
R(red), G(green), B(blue)
Each primary color can take an intensity value ranging from 0(lowest) to 1(highest). Mixing these three primary colors at different intensity levels produces a variety of colors. The collection of all the colors obtained by such a linear combination of red, green and blue forms the cube shaped RGB color space.
The corner of RGB color cube that is at the origin of the coordinate system corresponds to black, whereas the corner of the cube that is diagonally opposite to the origin represents white. The diagonal line connecting black and white corresponds to all the graycolors between black and white, which is also known as gray axis.
In the RGB color model, an arbitrary color within the cubic color space can be specified by its color coordinates: (r, g.b).
Example:
(0, 0, 0) for black, (1, 1, 1) for white,
(1, 1, 0) for yellow, (0.7, 0.7, 0.7) for gray
Color specification using the RGB model is an additive process. We begin with black and add on the appropriate primary components to yield a desired color. The concept RGB color model is used in Display monitor. On the other hand, there is a complementary color model known as CMY color model. The CMY color model use a subtraction process and this concept is used in the printer.
In CMY model, we begin with white and take away the appropriate primary components to yield a desired color.
Example:
If we subtract red from white, what remains consists of green and blue which is cyan. The coordinate system of CMY model use the three primaries’ complementary colors:
C(cray), M(magenta) and Y(yellow)
The corner of the CMY color cube that is at (0, 0, 0) corresponds to white, whereas the corner of the cube that is at (1, 1, 1) represents black. The following formulas summarize the conversion between the two color models:
1. Intensity attenuation refers to any reduction in the strength of a signal.
2. It is relatively compared with the attenuation of peak ground acceleration that is used for engineering design.
3. Knowledge of intensity attenuation is useful in calibrating hazard models against historical experience.
4. Intensity attenuation equation is given by:
I = 3.31 + 1.28 ML-1.22 In R
where
I = Intensity
ML = Local Magnitude
R = Hypocentral distance
5. As radiant energy from a point light source travels through space, its amplitude is attenuated by the factor 1d", where d is the distance that the light has traveled.
6.This means that a surface close to the light source receives higher incident intensity from the source than a distant surface.
1. The Warn model provides a method for simulating studio lighting effectsby controlling light intensity in different directions.
2. Light sources are modeled as points on a reflecting surface, using thePhong model for the surface points. Then, the intensity in differentdirections is controlled by selecting values for the Phong exponent.
3. In addition, light controls, such as “barn doors” and spotlighting, used bystudio photographers can be simulated in the Warn model.
4. Flaps are used to control the amount of light emitted by a source invarious directions.
5. Two flaps are provided for each of the x, y and z-directions.
6. Spotlights are used to control the amount of light emitted within a conewith apex at a point source position.
Q: Explain rendering methods in detail. Write its advantage and disadvantage.
Advantage of illumination method:-
Fast
Acceptable results
Hardware support
Disadvantage of illumination method:-
Point light source
No interaction between objects
Adhoc , not based on model of light propagation.
Different rendering method:-
Constant-intensity shading:-
In this method, a single intensity is calculated for each polygon and all points in the surface of polygon are displayed with the same intensity value.
It is fast and simplest rendering method.
Light source illuminating the object and the viewing position is sufficiently far from the surface of polygon.
Gouraud shading:-
It represent a polygon surface by linearly interpolating intensity across the polygon surface.
Intensity values for each polygon are matched with adjacent polygon along common edge.
It eliminates the intensity discontinuity that can occur in constant-intensity shading.
Phong-shading:-
Phong shading is method which interpolates normal vector and then apply the illumination model to each surface point.
This method interpolates the surface normal vector, instead of the intensity.
FasePhong shading:-
Fast phong shading approximates the intensity calculations using a Taylor-series expansion and triangular surface patches.
Surface rendering with Phong shading can be speeding up by using approximations in the illumination model calculation of normal vectors.
Advantage of rendering method:-
It removes the intensity discontinuity.
It can be combined with hidden surface algorithm to fill in the visible polygon along with each scanline.
It gives more accurate result.
Disadvantage of rendering method:-
It has a problem with specular reflections.
It introduce anomalies known as Mach bands.
It acquires more calculations and increases the cost of shading steeply.
A more accurate method for rendering a polygon surface is to interpolate the normal vector and then apply the illumination model to each surface point. This method developed by Phong Bui Tuong is called Phong Shading or normal vector Interpolation Shading. It displays more realistic highlights on a surface and greatly reduces the Match-band effect.
A polygon surface is rendered using Phong shading by carrying out the following steps:
Determine the average unit normal vector at each polygon vertex.
Linearly & interpolate the vertex normal over the surface of the polygon.
Apply an illumination model along each scan line to calculate projected pixel intensities for the surface points.
Interpolation of the surface normal along a polynomial edge between two vertices as shown in fig:
Incremental methods are used to evaluate normals between scan lines and along each scan line. At each pixel position along a scan line, the illumination model is applied to determine the surface intensity at that point.
Intensity calculations using an approximated normal vector at each point along the scan line produce more accurate results than the direct interpolation of intensities, as in Gouraud Shading. The trade-off, however, is that phong shading requires considerably more calculations.
Specular reflection is a type of surface reflectance often described as a mirror-like reflection of light from the surface. In specular reflection, the incident light is reflected into a single outgoing direction. The name specular is derived from the Latin word speculum, meaning mirror.
Specular reflection obeys the Laws of Reflection and the light is reflected from a smooth surface at a definite angle. Specular reflection occurs for all polished and smooth surfaces, like mirrors. The angle of reflection in specular reflection is equal to the angle of incidence. Rough or unpolished surfaces are not good specular reflectors as they do not reflect light at the same angle as the angle of incidence.
Mirrors that are used for specular reflection are usually made of metals such as aluminum or silver. Specular reflection is measured using incidence reflectometers by scanning a variable wavelength source.
In order to produce realistic images, we must simulate the appearance of surfaces under various lighting conditions
• Illumination Model: Given the illumination incident at a point on a surface, quantifies the reflected light.
Illumination Model Parameters
• Lighting effects are described with models that consider the interaction of light sources with object surfaces
• The factors determining the lighting effects are: –
--The light source parameters:
• Positions
• Electromagnetic Spectrum
• Shape
– The surface parameters
• Position
• Reflectance properties
• Position of nearby surfaces
– The eye (camera) parameters
• Position
• Sensor spectrum sensitivities
Ambient Illumination
• Assume there is some non-directional light in the environment (background light)
• The amount of ambient light incident on each object is constant for all surfaces and over all directions
• Very simple model, not very realistic
• OpenGL default Ambient Illumination
• The reflected intensity Iamb of any point on the surface is:
Lamb = Kala
Ia - ambient light intensity Ka ∈ [0,1] - surface ambient reflectivity
• In principle Ia and Ka are functions of colour, so we have I R amb, I G amb and I B amb
Diffuse Reflection
• Diffuse (Lambertian) surfaces are rough or grainy, like clay, soil, fabric
• The surface appears equally bright from all viewing directions
• The brightness at each point is proportional to cos( θ ) θ N L Diffuse Reflection
• Brightness is proportional to cos( θ) because a surface (a) perpendicular to the light direction is more illuminated than a surface (b) at an oblique angle a
Phong model :-
A more accurate method for rendering a polygon surface is to interpolate the normal vector and then apply the illumination model to each surface point. This method developed by Phong Bui Tuong is called Phong Shading or normal vector Interpolation Shading. It displays more realistic highlights on a surface and greatly reduces the Match-band effect.
It was invented by John Warnock and also called a Warnock Algorithm. It is based on a divide & conquer method. It uses fundamental of area coherence. It is used to resolve the visibility of algorithms. It classifies polygons in two cases i.e. trivial and non-trivial.
Trivial cases are easily handled. Non trivial cases are divided into four equal subwindows. The windows are again further subdivided using recursion until all polygons classified trivial and non trivial.
Classification of Scheme
It divides or classifies polygons in four categories:
Inside surface
Outside surface
Overlapping surface
Surrounding surface
1. Inside surface: It is surface which is completely inside the surrounding window or specified boundary as shown in fig (c)
2. Outside surface: The polygon surface completely outside the surrounding window as shown in fig (a)
3. Overlapping surface: It is polygon surface which completely encloses the surrounding window as shown in fig (b)
4. Overlapping surface: It is surface partially inside or partially outside the surface area as shown in fig (c)
It is an image space algorithm. It processes one line at a time rather than one pixel at a time. It uses the concept area of coherence. This algorithm records edge list, active edge list. So accurate bookkeeping is necessary. The edge list or edge table contains the coordinate of two endpoints. Active Edge List (AEL) contain edges a given scan line intersects during its sweep. The active edge list (AEL) should be sorted in increasing order of x. The AEL is dynamic, growing and shrinking.
Following figures shown edges and active edge list. The active edge list for scan line AC1contain e1,e2,e5,e6 edges. The active edge list for scan line AC2contain e5,e6,e1.
Scan line can deal with multiple surfaces. As each scan line is processed, this line will intersect many surfaces. The intersecting line will determine which surface is visible. Depth calculation for each surface is done. The surface rear to view plane is defined. When the visibility of a surface is determined, then intensity value is entered into refresh buffer.
Algorithm
Step1: Start algorithm
Step2: Initialize the desired data structure
Create a polygon table having color, edge pointers, coefficients
Establish edge table contains information regarding, the endpoint of edges, pointer to polygon, inverse slope.
Create Active edge list. This will be sorted in increasing order of x.
Create a flag F. It will have two values either on or off.
Step3: Perform the following steps for all scan lines
Enter values in Active edge list (AEL) in sorted order using y as value
Scan until the flag, i.e. F is on using a background color
When one polygon flag is on, and this is for surface S1enter color intensity as I1into refresh buffer
When two or image surface flag are on, sort the surfaces according to depth and use intensity value Sn for the nth surface. This surface will have least z depth value
Use the concept of coherence for remaining planes.
One of the most challenging problems in computer graphics is the removal of hidden parts from images of solid objects.
In real life, the opaque material of these objects obstructs the light rays from hidden parts and prevents us from seeing them.
In the computer generation, no such automatic elimination takes place when objects are projected onto the screen coordinate system.
Instead, all parts of every object, including many parts that should be invisible are displayed.
To remove these parts to create a more realistic image, we must apply a hidden line or hidden surface algorithm to set of objects.
The algorithm operates on different kinds of scene models, generate various forms of output or cater to images of different complexities.
All use some form of geometric sorting to distinguish visible parts of objects from those that are hidden.
Just as alphabetical sorting is used to differentiate words near the beginning of the alphabet from those near the ends.
Types of hidden surface detection algorithms
Object space methods
Image space methods
Object space methods: In this method, various parts of objects are compared. After comparison visible, invisible or hardly visible surface is determined. These methods generally decide visible surface. In the wireframe model, these are used to determine a visible line. So these algorithms are line based instead of surface based. Method proceeds by determination of parts of an object whose view is obstructed by other object and draws these parts in the same color.
Image space methods: Here positions of various pixels are determined. It is used to locate the visible surface instead of a visible line. Each point is detected for its visibility. If a point is visible, then the pixel is on, otherwise off. So the object close to the viewer that is pierced by a projector through a pixel is determined. That pixel is drawn is appropriate color.
These methods are also called a Visible Surface Determination. The implementation of these methods on a computer requires a lot of processing time and processing power of the computer.
A-Buffer method in computer graphics is a general hidden face detection mechanism suited to medium scale virtual memory computers. This method is also known as anti-aliased or area-averaged or accumulation buffer. This method extends the algorithm of depth-buffer (or Z Buffer) method. As the depth buffer method can only be used for opaque object but not for transparent object, the A-buffer method provides advantage in this scenario. Although the A buffer method requires more memory, but different surface colors can be correctly composed using it. Being a descendent of the Z-buffer algorithm, each position in the buffer can reference a linked list of surfaces. The key data structure in the A buffer is the accumulation buffer.
Each position in the A buffer has 2 fields :
1) Depth field
2) Surface data field or Intensity field
A depth field stores a positive or negative real number. A surface data field can stores surface intensity information or a pointer to a linked list of surfaces that contribute to that pixel position.
As shown in the above figure, if the value of depth is >= 0, the number stored at that position is the depth of single surface overlapping the corresponding pixel area. The 2nd field, i.e, the intensity field then stores the RGB components of the surface color at that point and the percent of
pixel coverage.
As shown in the above figure, multiple-surface contributions to the pixel intensity is indicated by depth < 0. The 2nd field, i.e, the intensity field then stores a pointer to a linked list of surface data.
A buffer method is slightly costly than Z-buffer method because it requires more memory in comparison to the Z-buffer method. It proceeds just like the depth buffer algorithm. Here, the depth and opacity are used to determine the final colour of the pixel. As shown in the figure below, the A buffer method can be used to show the transparent objects.
The surface buffer in the A buffer method includes :
Depth
Surface Identifier
Opacity Parameter
Percent of area coverage
RGB intensity components
Pointer to the next surface
Q: List the advantage and disadvantage of back-face detection and A-buffer method. Write the algorithm for back-face detection. [AKTU 2015-16 15M]
Ans:-
Advantage of back-face detection method:-
It is fast.
It is a simple object space method.
Disadvantage of back-face detection method:-
It can only be used on solid objects modelled as polygon mesh.
It works fine for convex polyhedra but not necessary for concave polyhedra.
Advantage of A-buffer method:-
More than one surface intensity can be taken into consideration at each pixel position.
It also anti-aliased the object edges.
In this, surface are divided into polygon mesh and clipped against the pixel boundaries.
The intensity of pixel is determined by considering opacity parameter and percentage of overlaps of the overlapping surface.
Disadvantage of A-buffer method:-
This algorithm processes multiple object at a time. The total number of polygon in a picture can be arbitrary large.
It is also called a Depth Buffer Algorithm. Depth buffer algorithm is simplest image space algorithm. For each pixel on the display screen, we keep a record of the depth of an object within the pixel that lies closest to the observer. In addition to depth, we also record the intensity that should be displayed to show the object. Depth buffer is an extension of the frame buffer. Depth buffer algorithm requires 2 arrays, intensity and depth each of which is indexed by pixel coordinates (x, y).
Algorithm
For all pixels on the screen, set depth [x, y] to 1.0 and intensity [x, y] to a background value.
For each polygon in the scene, find all pixels (x, y) that lie within the boundaries of a polygon when projected onto the screen. For each of these pixels:
(a) Calculate the depth z of the polygon at (x, y)
(b) If z < depth [x, y], this polygon is closer to the observer than others already recorded for this pixel. In this case, set depth [x, y] to z and intensity [x, y] to a value corresponding to polygon's shading. If instead z > depth [x, y], the polygon already recorded at (x, y) lies closer to the observer than does this new polygon, and no action is taken.
3. After all, polygons have been processed; the intensity array will contain the solution.
4. The depth buffer algorithm illustrates several features common to all hidden surface algorithms.
5. First, it requires a representation of all opaque surface in scene polygon in this case.
6. These polygons may be faces of polyhedral recorded in the model of scene or may simply represent thin opaque 'sheets' in the scene.
7. The IInd important feature of the algorithm is its use of a screen coordinate system. Before step 1, all polygons in the scene are transformed into a screen coordinate system using matrix multiplication.
Limitations of Depth Buffer
The depth buffer Algorithm is not always practical because of the enormous size of depth and intensity arrays.
Generating an image with a raster of 500 x 500 pixels requires 2, 50,000 storage locations for each array.
Even though the frame buffer may provide memory for intensity array, the depth array remains large.
To reduce the amount of storage required, the image can be divided into many smaller images, and the depth buffer algorithm is applied to each in turn.
For example, the original 500 x 500 faster can be divided into 100 rasters each 50 x 50 pixels.
Processing each small raster requires array of only 2500 elements, but execution time grows because each polygon is processed many times.
Subdivision of the screen does not always increase execution time instead it can help reduce the work required to generate the image. This reduction arises because of coherence between small regions of the screen.
It is used to plot only surfaces which will face the camera. The objects on the back side are not visible. This method will remove 50% of polygons from the scene if the parallel projection is used. If the perspective projection is used then more than 50% of the invisible area will be removed. The object is nearer to the center of projection, number of polygons from the back will be removed.
It applies to individual objects. It does not consider the interaction between various objects. Many polygons are obscured by front faces, although they are closer to the viewer, so for removing such faces back face removal algorithm is used.
When the projection is taken, any projector ray from the center of projection through viewing screen to object pieces object at two points, one is visible front surfaces, and another is not visible back surface.
This algorithm acts a preprocessing step for another algorithm. The back face algorithm can be represented geometrically. Each polygon has several vertices. All vertices are numbered in clockwise. The normal M1 is generated a cross product of any two successive edge vectors. M1represent vector perpendicular to face and point outward from polyhedron surface
N1=(v2-v1 )(v3-v2) If N1.P≥0 visible N1.P<0 invisible
Advantage
It is a simple and straight forward method.
It reduces the size of databases, because no need of store all surfaces in the database, only the visible surface is stored.
Back Face Removed Algorithm
Repeat for all polygons in the scene.
Do numbering of all polygons in clockwise direction i.e. v1 v2 v3.....vz
Calculate normal vector i.e. N1 N1=(v2-v1 )*(v3-v2)
Consider projector P, it is projection from any vertex Calculate dot product Dot=N.P
Test and plot whether the surface is visible or not. If Dot ≥ 0 then surface is visible else Not visible