Shading
Encyclopedia
Shading refers to depicting depth perception
Depth perception
Depth perception is the visual ability to perceive the world in three dimensions and the distance of an object. Depth sensation is the ability to move accurately, or to respond consistently, based on the distances of objects in an environment....

 in 3D models or illustration
Illustration
An illustration is a displayed visualization form presented as a drawing, painting, photograph or other work of art that is created to elucidate or dictate sensual information by providing a visual representation graphically.- Early history :The earliest forms of illustration were prehistoric...

s by varying levels of darkness
Darkness
Darkness, in contrast with brightness, is a relative absence of visible light. It is the appearance of black in a color space. When light is not present, rod and cone cells within the eye are not stimulated. This lack of stimulation means photoreceptor cells are unable to distinguish color...

.

Drawing

Shading is a process used in drawing for depicting levels of darkness on paper by applying media more densely or with a darker shade for darker areas, and less densely or with a lighter shade for lighter areas. There are various techniques of shading including cross hatching
Hatching
Hatching is an artistic technique used to create tonal or shading effects by drawing closely spaced parallel lines...

 where perpendicular lines of varying closeness are drawn in a grid pattern to shade an area. The closer the lines are together, the darker the area appears. Likewise, the farther apart the lines are, the lighter the area appears.

Light patterns, such as objects having light and shaded areas, help when creating the illusion of depth on paper.

Simple tutorials and lessons are available at numerous locations online to help learn the tips and tricks of shading to improve sketches.

Computer graphics

In computer graphics, Shading refers to the process of altering the color of an object/surface/polygon in the 3D scene, based on its angle to lights and its distance from lights to create a photorealistic effect. Shading is performed during the rendering
Rendering (computer graphics)
Rendering is the process of generating an image from a model , by means of computer programs. A scene file contains objects in a strictly defined language or data structure; it would contain geometry, viewpoint, texture, lighting, and shading information as a description of the virtual scene...

 process.

Why Shade?

• Human vision uses shading as a cue to form, position, and depth

• Total handling of light is very expensive

• Shading models can give us a good approximation of what would “really” happen, much less expensively

• Average and approximate

Angle to light source

Shading alters the colors of faces in a 3D model based on the angle of the surface to a light source or light sources.

The very first image below has the faces of the box rendered, but all in the same color. Edge lines have been rendered here as well which makes the image easier to see.

The second image is the same model rendered without edge lines. It is difficult to tell where one face of the box ends and the next begins.

The third image has shading enabled, which makes the image more realistic and makes it easier to see which face is which.

Lighting

Usually, upon rendering a scene a number of different lighting techniques will be used to make the rendering look more realistic. For this matter, a number of different types of light sources exist to provide customization for the shading of objects.

Ambient lighting

An ambient light source represents a fixed-intensity and fixed-color light source that affects all objects in the scene equally. Upon rendering, all objects in the scene are brightened with the specified intensity and color. This type of light source is mainly used to provide the scene with a basic view of the different objects in it.

Directional lighting

A directional light source illuminates all objects equally from a given direction, like an area light of infinite size and infinite distance from the scene; there is shading, but cannot be any distance falloff

Point lighting

Point, originates from a single point
Point (geometry)
In geometry, topology and related branches of mathematics a spatial point is a primitive notion upon which other concepts may be defined. In geometry, points are zero-dimensional; i.e., they do not have volume, area, length, or any other higher-dimensional analogue. In branches of mathematics...

, and spreads outward in all directions

Spotlight lighting

Spotlight
Searchlight
A searchlight is an apparatus that combines a bright light source with some form of curved reflector or other optics to project a powerful beam of light of approximately parallel rays in a particular direction, usually constructed so that it can be swiveled about.-Military use:The Royal Navy used...

, originates from a single point, and spreads outward in a coned direction

Area lighting

Area, originates from a single plane
Plane (mathematics)
In mathematics, a plane is a flat, two-dimensional surface. A plane is the two dimensional analogue of a point , a line and a space...

 and illuminates all objects in a given direction beginning from that plane

Volumetric lighting

Volume
Volumetric lighting
Volumetric lighting is a technique used in 3D computer graphics to add lighting effects to a rendered scene. It allows the viewer to see beams of light shining through the environment; seeing sunbeams streaming through an open window is an example of volumetric lighting, also known as crepuscular...

, an enclosed space lighting objects within that space


Shading is interpolated based on how the angle of these light sources reach the objects within a scene. Of course, these light sources can be and often are combined in a scene. The renderer
3D rendering
3D rendering is the 3D computer graphics process of automatically converting 3D wire frame models into 2D images with 3D photorealistic effects on a computer.-Rendering methods:...

 then interpolates how these lights must be combined, and produces a 2d image to be displayed on the screen accordingly.

Distance falloff

Theoretically, two surfaces which are parallel
Parallel (geometry)
Parallelism is a term in geometry and in everyday life that refers to a property in Euclidean space of two or more lines or planes, or a combination of these. The assumed existence and properties of parallel lines are the basis of Euclid's parallel postulate. Two lines in a plane that do not...

, are illuminated the same amount from a distant light source, such as the sun. Even though one surface is further away, your eye sees more of it in the same space, so the illumination appears the same.

Notice in the first image that the color on the front faces of the two boxes is exactly the same. It appears that there is a slight difference where the two faces meet, but this is an optical illusion because of the vertical edge below where the two faces meet.

Notice in the second image that the surfaces on the boxes are bright on the front box and darker on the back box. Also the floor goes from light to dark as it gets farther away.

This distance falloff effect produces images which appear more realistic without having to add additional lights to achieve the same effect.


Distance falloff can be calculated in a number of ways:
  • None - The light intensity received is the same regardless of the distance between the point and the light source.
  • Linear - For a given point at a distance x from the light source, the light intensity received is proportional to .
  • Quadratic - This is how light intensity decreases in reality if the light has a free path (i.e. no fog
    Fog
    Fog is a collection of water droplets or ice crystals suspended in the air at or near the Earth's surface. While fog is a type of stratus cloud, the term "fog" is typically distinguished from the more generic term "cloud" in that fog is low-lying, and the moisture in the fog is often generated...

     or any other thing in the air that can absorb
    Absorption (electromagnetic radiation)
    In physics, absorption of electromagnetic radiation is the way by which the energy of a photon is taken up by matter, typically the electrons of an atom. Thus, the electromagnetic energy is transformed to other forms of energy for example, to heat. The absorption of light during wave propagation is...

     or scatter the light). For a given point at a distance x from the light source, the light intensity received is proportional to .
  • Factor of n - For a given point at a distance x from the light source, the light intensity received is proportional to .
  • Any number of other mathematical functions
    Function (mathematics)
    In mathematics, a function associates one quantity, the argument of the function, also known as the input, with another quantity, the value of the function, also known as the output. A function assigns exactly one output to each input. The argument and the value may be real numbers, but they can...

     may also be used.


Flat shading

Flat shading is a lighting technique used in 3D computer graphics to shade each polygon of an object based on the angle between the polygon's surface normal and the direction of the light source, their respective colors and the intensity of the light source. It is usually used for high speed rendering where more advanced shading techniques are too computationally expensive. As a result of flat shading all of the polygon's vertices are colored with one color, allowing differentiation between adjacent polygons. Specular highlights are rendered poorly with flat shading: If there happens to be a large specular component at the representative vertex, that brightness is drawn uniformly over the entire face. If a specular highlight doesn’t fall on the representative point, it is missed entirely. Consequently, we usually do not include the specular reflection component in the shading computation.

Smooth shading

Smooth shading of a polygon displays the points in a polygon with smoothly-changing colors across the surface of the polygon. This requires you to define a separate color for each vertex of your polygon, because the smooth color change is computed by interpolating the vertex colors across the interior of the triangle with the standard kind of interpolation we saw in the graphics pipeline discussion. Computing the color for each vertex is done with the usual computation of a standard lighting model, but in order to compute the color for each vertex separately you must define a separate normal vector for each vertex of the polygon. This allows the color of the vertex to be determined by the lighting model that includes this unique normal.


Gouraud Shading Algorithm

1. Determine the normal at each polygon vertex
2. Apply an illumination model to each vertex to calculate the vertex intensity
3. Linearly interpolate the vertex intensities over the surface polygon

Data Structures for Gouraud Shading

  • Sometimes vertex normals can be computed directly (e.g. height field with uniform mesh)
  • More generally, need data structure for mesh
  • Key: which polygons meet at each vertex

Benefits of Gouraud Shading

  • Polygons, more complex than triangles, can also have different colors specified for each vertex. In these instances, the underlying logic for shading can become more intricate. Fortunately, you never have to worry about it with OpenGL. No, matter how complex your polygon, OpenGL successfully shades the interior points between each vertex.

Problems with Gouraud Shading

  • Even the smoothness introduced by Gouraud shading may not prevent the appearance of the shading differences between adjacent polygons.
  • Gouraud shading is more CPU intensive and can become a problem when rendering real time environments with many polygons.
  • T-Junctions with adjoining polygons can sometimes result in visual anomalies. In general, T-Junctions should be avoided.

Phong shading

Phong shading, is similar to Gouraud shading except that the Normals are interpolated. Thus, the specular highlights are computed much more precisely than in the Gouraud shading model.

Phong shading algorithm

  1. Compute a normal N for each vertex of the polygon.
  2. From bi-linear interpolation compute a normal, Ni for each pixel. (This must be renormalized each time)
  3. From Ni compute an intensity Ii for each pixel of the polygon.
  4. Paint pixel to shade corresponding to Ii.

Difference between flat and smooth shading

Flat Smooth
Use the same color for every pixel in a face - usually the color of the first vertex. Smooth shading uses linear interpolation of colors between vertices
Edges appear more pronounced than they would on a real object because of a phenomenon in the eye known as lateral inhibition The edges disappear with this technique
Same color for any point of the face Each point of the face has its own color
Individual faces are visualized Visualize underlying surface
Not suitable for smooth objects Suitable for any objects
Less expensive More expensive
GL implements this type of coloring using glShadeModel(GL_FLAT); GL implements this type of coloring using glShadeModel(GL_SMOOTH);

See also

  • 3D computer graphics
    3D computer graphics
    3D computer graphics are graphics that use a three-dimensional representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images...

  • Shading model
  • Zebra striping
    Zebra striping
    Zebra striping is a diagnostic shading technique used in computer graphics to visualize curvature on smooth surfaces. It is primarily used for computer aided design . It is a simulation of the visual effect of placing an object in a tunnel lit by parallel rows of lights...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK