Active In SP
Joined: Sep 2010
01-01-2011, 03:07 PM
shading.doc (Size: 1.79 MB / Downloads: 56)
B’TECH MBA CSE
In computer graphics, Shading refers to the process of altering a color based on its angle to lights and its distance from lights to create a photorealistic effect. Shading is performed during the rendering process.
Angle to light source
Shading alters the colors of faces in a 3D model based on the angle of the surface to the sun or other 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.
In the field of computer graphics, a shader is a set of software instructions, which is used primarily to calculate rendering effects on graphics hardware with a high degree of flexibility.
Shaders are used to program the graphics processing unit (GPU) programmable rendering pipeline, which has mostly superseded the fixed-function pipeline that allowed only common geometry transformation and pixel shading functions.
Shaders are simple programs that describe the traits of either a vertex or a pixel. Vertex shaders describe the traits (position, texture coordinates, colors, etc.) of a vertex, while pixel shaders describe the traits (color, z depth and alpha value) of a pixel.
A vertex shader is called for each vertex in a primitive thus one vertex in - one vertex out. Each vertex is then rendered as a series of pixels onto a surface that will eventually be sent to the screen.
Shaders replace a section of video hardware that's typically called the Fixed Function Pipeline (FFP). This is because it performs lighting and texture mapping in a hard-coded manner, while shaders let you replace this hard-coded approach with a programmable one.
Types of Shaders
The Direct3D and OpenGL graphic libraries use three types of shaders.
Vertex shaders are run once for each vertex given to the graphics processor. The purpose is to transform each vertex's 3D position in virtual space to the 2D coordinate at which it appears on the screen. Vertex Shaders can manipulate properties such as position, color, and texture coordinate, but cannot create new vertices.
Geometry Shaders can add and remove vertices from a mesh. Geometry shaders can be used to generate geometry procedurally or to add volumetric detail to existing meshes that would be too costly to process on the CPU. If geometry shaders are being used, the output is then sent to the rasterizer.
Pixel Shaders, also known as fragment shaders, calculate the color of individual pixels. The input to this stage comes from the rasterizer, which fills in the polygons being sent through the graphics pipeline. Pixel shaders are typically used for scene lighting and related effects such as bump mapping and color toning.
We can say that 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 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. The term has been recently generalized to mean that Shaders are applied.
Light patterns, such as objects having light areas and shaded areas, help when creating the illusion of depth on paper and on computer screens.