0% found this document useful (0 votes)
158 views22 pages

Game Programm Notes

3D transformations allow modifying and repositioning 3D graphics objects. There are various 3D transformation techniques including translation, which moves an object from one position to another in 3D space by adding translation values to the original coordinates. Quaternions represent 3D rotations and are useful for computer graphics, while 3D modeling involves creating 3D objects and rendering produces photorealistic images of modeled scenes through ray tracing to realistically simulate light interactions.

Uploaded by

Jitender Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views22 pages

Game Programm Notes

3D transformations allow modifying and repositioning 3D graphics objects. There are various 3D transformation techniques including translation, which moves an object from one position to another in 3D space by adding translation values to the original coordinates. Quaternions represent 3D rotations and are useful for computer graphics, while 3D modeling involves creating 3D objects and rendering produces photorealistic images of modeled scenes through ray tracing to realistically simulate light interactions.

Uploaded by

Jitender Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

3D Transformation in Computer Graphics-

In Computer graphics,

Transformation is a process of modifying and re-positioning the existing graphics.

 3D Transformations take place in a three dimensional plane.


 3D Transformations are important and a bit more complex than 2D Transformations.
 Transformations are helpful in changing the position, size, orientation, shape etc of the
object.
Transformation Techniques-
In computer graphics, various transformation techniques are-

3D Translation in Computer Graphics-

In Computer graphics,3D Translation is a process of moving an object from one position to another
in a three dimensional plane.

Consider a point object O has to be moved from one position to another in a 3D plane.
Let-

 Initial coordinates of the object O = (Xold, Yold, Zold)


 New coordinates of the object O after translation = (Xnew, Ynew, Zold)
 Translation vector or Shift vector = (Tx, Ty, Tz)
 
Given a Translation vector (Tx, Ty, Tz)-

 Tx defines the distance the Xold coordinate has to be moved.


 Ty defines the distance the Yold coordinate has to be moved.
 Tz defines the distance the Zold coordinate has to be moved.

 
This translation is achieved by adding the translation coordinates to the old coordinates of the object
as-

 Xnew = Xold + Tx(This denotes translation towards X axis)


 Ynew = Yold + Ty(This denotes translation towards Y axis)
 Znew = Zold + Tz(This denotes translation towards Z axis)
In Matrix form, the above translation equations may be represented as-

QUATERNIONS
In mathematics, the quaternions are a number system that extends the complex numbers. They
were first described by Irish mathematician William Rowan Hamilton in 1843[1][2] and applied to
mechanics in three-dimensional space. A feature of quaternions is that multiplication of two
quaternions is noncommutative. Hamilton defined a quaternion as the quotient of two directed lines
in a three-dimensional space[3] or equivalently as the quotient of two vectors.[4]
Quaternions are generally represented in the form:

where a, b, c, and d are real numbers, and i, j, and k are the fundamental quaternion units.
Quaternions are used in pure mathematics, and also have practical uses in applied mathematics—in
particular for calculations involving three-dimensional rotations such as in three-dimensional
computer graphics, computer vision, and crystallographic texture analysis.[5] In practical
applications, they can be used alongside other methods, such as Euler angles and rotation matrices,
or as an alternative to them, depending on the application.
In modern mathematical language, quaternions form a four-dimensional associative normed
division algebra over the real numbers, and therefore also a domain. In fact, the quaternions were
the first noncommutative division algebra to be discovered. The algebra of quaternions is often
denoted by H (for Hamilton), or in blackboard bold by (Unicode U+210D, ℍ). It can also be given
by the Clifford algebra classifications Cℓ0,2(ℝ) ≅ Cℓ03,0(ℝ). The algebra H holds a special place in
analysis since, according to the Frobenius theorem, it is one of only two finite-dimensional division
rings containing the real numbers as a proper subring, the other being the complex numbers. These
rings are also Euclidean Hurwitz algebras, of which quaternions are the largest associative algebra.
Further extending the quaternions yields the non-associative octonions, which is the last normed
division algebra over the reals (the extension of the octonions, sedenions, has zero divisors and so
cannot be a normed division algebra).[6]

The unit quaternions can be thought of as a choice of a group structure on the 3-sphere S 3 that gives
the group Spin(3), which is isomorphic to SU(2) and also to the universal cover of
SO(3).

Definition
A quaternion is an expression of the form

where a, b, c, d, are real numbers, and i, j, k, are symbols that can be interpreted as unit-vectors
pointing along the three spatial axes. In practice, if one of a, b, c, d is 0, the corresponding term is
omitted; if a, b, c, d are all zero, the quaternion is the zero quaternion, denoted 0; if one of b, c, d
equals 1, the corresponding term is written simply i, j, or k.
Hamilton describes a quaternion , as consisting of a scalar part and a vector part. The quaternion is
called the vector part (sometimes imaginary part) of q, and a is the scalar part (sometimes real
part) of q. A quaternion that equals its real part (that is, its vector part is zero) is called a scalar, and
is identified with the corresponding real number. That is, the real numbers are a subset of the
quaternions. A quaternion that equals its vector part is called a vector quaternion.
The set of quaternions is made a 4 dimensional vector space over the real numbers, with as a basis,
by the componentwise addition and the componentwise scalar multiplication
A multiplicative group structure, called the Hamilton product, denoted by juxtaposition, can be
defined on the quaternions in the following way:

 The real quaternion 1 is the identity element.


 The real quaternions commute with all other quaternions, that is aq = qa for every
quaternion q and every real quaternion a. In algebraic terminology this is to say that the field
of real quaternions are the center of this quaternion algebra.
 The product is first given for the basis elements (see next subsection), and then extended to
all quaternions by using the distributive property and the center property of the real
quaternions. The Hamilton product is not commutative, but associative, thus the quaternions
form an associative algebra over the reals.
 Additionally, every nonzero quaternion has an inverse with respect to the Hamilton product:
Thus the quaternions form a division algebra.

3D Modeling
3D modeling is utilized as a part of a wide range of ventures, including virtual reality, computer
games, 3D printing, showcasing, TV and movies, logical and medicinal imaging and CAD process
and assembling CAD/CAM.
3D modeling is a way of making 3-dimensional objects. 3D modeling is frequently done through
3D files that can be influenced to the desired measurements of the print.
Without a 3D model, a 3D print is incomprehensible. Subsequently, a 3D visualization is impossible
without a 3D model. Thus, Modeling is the pre-production stage and Rendering is the post-
production stage.
SketchUp, Blender, 3DS Max, Revit, Maya are some of the software used for creating 3D models.
3DRendering

3D rendering is an innovative procedure that is like photography. A real-time rendering of a 3D


model often gives an object or clients a clearer vision of a design than a plotted drawing.
The industries utilizing the 3D rendering are Architecture, Engineering, Marketing, Advertising,
Cinema,Gaming.
Rendering is the way toward making a raster picture in light of the 3D objects in a scene.
A renderer is utilized to figure the look of the materials joined to the articles in a scene, and how
lighting and shadows are ascertained in view of the lights put in a scene.
Ecological and exposure settings of the renderer can be adjusted to control the final rendered
picture.
High-quality 3D scene rendering can take many days for preparing a single picture.
Before 3D visualization of the scene, artists need to do modeling and animating process. Hence, this
is the basic element of 3D modeling- 3D visualization differences.
Autodesk Maya, Lumion, V-Ray, I-Ray, Maxwell Render are the few software used in 3D
rendering.
Summing up the 3D modeling- 3D Visualization differences:

3D Modeling 3D Rendering

 Empowers better venture arrangement.  Demonstrate the properties to clients.


 Showcasing of any conceivable impedance
among building frameworks.  Before construction, it empowers better
 Identifies any issues to dispose of design related choices
significant system clashes before
establishments.  Represents ideas in still renderings, virtual
 Envisions schematic structures before tours, animated 3D walk-through, floor
development. arranges etc.

 Encourages design examination,3D


visualization presentation, and marketing.

What is ray tracing?


Ray tracing is a rendering technique that can produce incredibly realistic lighting effects.
Essentially, an algorithm can trace the path of light, and then simulate the way that the light
interacts with the virtual objects it ultimately hits in the computer-generated world. 
We've seen in-game lighting effects become more and more realistic over the years, but the benefits
of ray tracing are less about the light itself and more about how it interacts with the world. 
Ray tracing allows for dramatically more lifelike shadows and reflections, along with much-
improved translucence and scattering. The algorithm takes into account where the light hits and
calculates the interaction and interplay much like the human eye would process real light, shadows,
and reflections, for example. The way light hits objects in the world also affects which colors you
see.
With enough computational power available, it's possible to produce incredibly realistic CG images
that are nearly indistinguishable from real life. But that's the problem: even a well-equipped gaming
PC only has so much GPU power to work with, let alone a modern game console.
Ray tracing is used extensively when developing computer graphics imagery for films and TV
shows, but that's because studios can harness the power of an entire server farm (or cloud
computing) to get the job done. And even then, it can be a long, laborious process. Doing it on the
fly has been far too taxing for existing gaming hardware.
Traditionally, video games have used rasterization instead. This is a speedier way to render
computer graphics. It converts the 3D graphics into 2D pixels to display on your screen, but
rasterization requires shaders to depict realistic lighting. Luckily, we’re starting to see a lot of PC
games take advantage of the specialized hardware in the latest Nvidia graphics cards to use real
time ray tracing instead, though rasterization will still be needed in most games, at least until it’s
feasible to fully ray trace lighting engines in games. 
So, even if right now the results aren’t super mind-blowing, we’re seeing a groundwork being laid
out that should lead to some incredible effects. We could see a total revolution in the way PC games
are rendered, and we’re at the ground floor right now.

Ray tracing games


Right now, there are only 5 games that use Nvidia ray tracing tech, and only a few big name AAA
titles. However, because this is the hot new graphics technology on the block, you can expect plenty
more ray tracing games to show up over the next year or so. And, if the PS5 and Xbox Project
Scarlett have large libraries of ray traced games, you can bet your bottom dollar that the PC will get
them too. Here are all the ray tracing games you can play right now, and the flavor of RTX effects
they use.

 Battlefield V – Ray traced reflections


 Metro Exodus – Ray traced global illumination
 Shadow of the Tomb Raider – Ray traced shadows
 Stay in the Light – Ray traced global illumination and reflections
 Quake II RTX – Ray traced global illumination
Now, admittedly that’s not a lot of games that showcase Nvidia’s premiere technology, but don’t
worry – there are plenty of other games that will soon use ray tracing. For instance, Remedy’s
Control will use Nvidia’s RTX tech to great effect, with ray traced reflections, shadows and global
illumination – you can expect this game to be gorgeous, and it may even melt your computer (in a
good way).
And, at Gamescom 2019, we got a look at a ton of new games that will be implementing this
technology, and how it will look in each of these games. Nvidia isn't holding any developer back,
and we're starting to see some incredibly powerful implementations of the technology. For instance,
Minecraft will have fully path-traced lighting. We were able to get our hands on the extremely
popular game and we can honestly say that it completely transforms the way the game looks.
Even now that we have a larger roster of upcoming games that are featuring the technology, we
have a better idea of what ray tracing in games will look like. Still, because the technology is so
new, we're sure that developers will keep finding ways to surprise us. Until then, though, here are
all the announced ray tracing games coming in the future.

 Cyberpunk 2077
 Call of Duty: Modern Warfare– Ray traced shadows and ambient occlusion
 Control– Ray traced reflections, ray traced global illumination and ray traced shadows
 Enlisted
 Justice Online
 MechWarrior V
 Wolfenstein Youngblood – Ray traced reflections
 Vampire: The Masquerade – Bloodlines 2– Ray traced reflections
 Watch Dogs: Legion– Ray traced reflections
 Minecraft – Fully path-traced lighting
 Synched: Off Planet – Ray traced reflections, ray traced shadows
Either way, we’re sure many more developers are willing to jump on the ray-traced bandwagon, and
we’ll update this page just as soon as we hear of any others.
Shader Model

In the field of 3D computer graphics, the Unified Shader Model (known in Direct3D 10 as "Shader
Model 4.0") refers to a form of shader hardware in a graphical processing unit (GPU) where all of
the shader stages in the rendering pipeline (geometry, vertex, pixel, etc.) have the same capabilities.
They can all read textures and buffers, and they use instruction sets that are almost identica
Earlier GPUs generally included two types of shader hardware, with the vertex shaders having
considerably more instructions than the simpler pixel shaders. This lowered the cost of
implementation of the GPU as a whole, and allowed more shaders in total on a single unit. This was
at the cost of making the system less flexible, and sometimes leaving one set of shaders idle if the
workload used one more than the other. As improvements in fabrication continued, this distinction
became less useful. ATI Technologies introduced a unified architecture on the hardware they
developed for the Xbox 360, and then introduced this in card form in the TeraScale line. Nvidia
quickly followed with their Tesla design. The concept has been universal since then.
Early shader abstractions (such as Shader Model 1.x) used very different instruction sets for vertex
and pixel shaders, with vertex shaders having much more flexible instruction set. Later shader
models (such as Shader Model 2.x and 3.0) reduced the differences, approaching Unified Shader
Model. Even in the Unified model the instruction set may not be completely the same between
different shader types; different shader stages may have a few distinctions. Fragment/pixel shaders
can compute implicit texture coordinate gradients, while geometry shaders can emit rendering
primitives.
Shader Models are components used to help render graphics sent from the CPU to the graphic
card. The version of shader model your computer can support is based in the combination
between your DirectX version and the version your graphics card can support.
DirectX 10.0 and higher will not run in Windows XP.
Lighting
Lighting or illumination is the deliberate use of light to achieve practical or aesthetic effects.
Lighting includes the use of both artificial light sources like lamps and light fixtures, as well as
natural illumination by capturing daylight. Daylighting (using windows, skylights, or light shelves)
is sometimes used as the main source of light during daytime in buildings. This can save energy in
place of using artificial lighting, which represents a major component of energy consumption in
buildings. Proper lighting can enhance task performance, improve the appearance of an area, or
have positive psychological effects on occupants.
Indoor lighting is usually accomplished using light fixtures, and is a key part of interior design.
Lighting can also be an intrinsic component of landscape projects.

Types
List of types of lighting

A demonstration of the effects of different kinds of lighting


Lighting is classified by intended use as general, accent, or task lighting, depending largely on the
distribution of the light produced by the fixture.

 Task lighting is mainly functional and is usually the most concentrated, for purposes such as
reading or inspection of materials. For example, reading poor-quality reproductions may
require task lighting levels up to 1500 lux (150 footcandles), and some inspection tasks or
surgical procedures require even higher levels.
 Accent lighting is mainly decorative, intended to highlight pictures, plants, or other elements
of interior design or landscaping.
 General lighting (sometimes referred to as ambient light) fills in between the two and is
intended for general illumination of an area. Indoors, this would be a basic lamp on a table
or floor, or a fixture on the ceiling. Outdoors, general lighting for a parking lot may be as
low as 10-20 lux (1-2 footcandles) since pedestrians and motorists already used to the dark
will need little light for crossing the area.

Methods
 Downlighting is most common, with fixtures on or recessed in the ceiling casting light
downward. This tends to be the most used method, used in both offices and homes. Although
it is easy to design it has dramatic problems with glare and excess energy consumption due
to large number of fittings.[9] The introduction of LED lighting has greatly improved this by
approx. 90% when compared to a halogen downlight or spotlight. LED lamps or bulbs are
now available to retro fit in place of high energy consumption lamps.
 Uplighting is less common, often used to bounce indirect light off the ceiling and back
down. It is commonly used in lighting applications that require minimal glare and uniform
general illuminance levels. Uplighting (indirect) uses a diffuse surface to reflect light in a
space and can minimize disabling glare on computer displays and other dark glossy surfaces.
It gives a more uniform presentation of the light output in operation. However indirect
lighting is completely reliant upon the reflectance value of the surface. While indirect
lighting can create a diffused and shadow free light effect it can be regarded as an
uneconomical lighting principle.[10][11]
 Front lighting is also quite common, but tends to make the subject look flat as its casts
almost no visible shadows. Lighting from the side is the less common, as it tends to produce
glare near eye level.

 Backlighting either around or through an object is mainly for accent. Backlighting is used to
illuminate a background or backdrop. This adds depth to an image or scene. Others use it to
achieve a more dramatic effect.
The Game Loop
The game loop is the overall flow control for the entire game program. It’s a loop because the game
keeps doing a series of actions over and over again until the user quits. Each iteration of the game
loop is known as a frame. Most real-time games update several times per second: 30 and 60 are the
two most common intervals. If a game runs at 60 FPS (frames per second), this means that the
game loop completes 60 iterations every second.
There can be many variations of the game loop, depending on a number of factors, most notably the
target hardware. Let’s first discuss the traditional game loop before exploring a more advanced
formulation that’s designed for more modern hardware.

Traditional Game Loop


A traditional game loop is broken up into three distinct phases: processing inputs, updating the
game world, and generating outputs. At a high level, a basic game loop might look like this:
while game is running
process inputs
update game world
generate outputs
loop

Each of these three phases has more depth than might be apparent at first glance. For instance,
processing inputs clearly involves detecting any inputs from devices such as a keyboard, mouse, or
controller. But those aren’t the only inputs to be considered; any external input must be processed
during this phase of the game loop.
As one example, consider a game that supports online multiplayer. An important input for such a
game is any data received over the Internet, because the state of the game world will directly be
affected by this information. Or take the case of a sports game that supports instant replay. When a
previous play is being viewed in replay mode, one of the inputs is the saved replay information. In
certain types of mobile games, another input might be what’s visible by the camera, or perhaps GPS
information. So there are quite a few potential input options, depending on the particular game and
hardware it’s running on.
Updating the game world involves going through everything that is active in the game and updating
it as appropriate. This could be hundreds or even thousands of objects. Later in this chapter, we will
cover exactly how we might represent said game objects.
As for generating outputs, the most computationally expensive output is typically the graphics,
which may be 2D or 3D. But there are other outputs as well—for example, audio, including sound
effects, music, and dialogue, is just as important as visual outputs. Furthermore, most console
games have “rumble” effects, where the controller begins to shake when something exciting
happens in the game. The technical term for this is force feedback, and it, too, is another output
that must be generated. And, of course, for an online multiplayer game, an additional output would
be data sent to the other players over the Internet.
We’ll fill in these main parts of the game loop further as this chapter continues. But first, let’s look
at how this style of game loop applies to the classic Namco arcade game Pac-Man.
The primary input device in the arcade version of Pac-Man is a quad-directional joystick, which
enables the player to control Pac-Man’s movement. However, there are other inputs to consider: the
coin slot that accepts quarters and the Start button. When a Pac-Man arcade cabinet is not being
played, it simply loops in a demo mode that tries to attract potential players. Once a quarter is
inserted into the machine, it then asks the user to press Start to commence the actual game.
When in a maze level, there are only a handful of objects to update in Pac-Man—the main character
and the four ghosts. Pac-Man’s position gets updated based on the processed joystick input. The
game then needs to check if Pac-Man has run into any ghosts, which could either kill him or the
ghosts, depending on whether or not Pac-Man has eaten a power pellet. The other thing Pac-Man
can do is eat any pellets or fruits he moves over, so the update portion of the loop also needs to
check for this. Because the ghosts are fully AI controlled, they also must update their logic.
Finally, in classic Pac-Man the only outputs are the audio and video. There isn’t any force feedback,
networking, or anything else necessary to output. A high-level version of the Pac-Man game loop
during the gameplay state would look something like what is shown in Listing 1.1.

Listing 1.1 Theoretical Pac-Man Game Loop


while player.lives > 0
// Process Inputs
JoystickData j = grab raw data from joystick

// Update Game World


update player.position based on j
foreach Ghost g in world
if player collides with g
kill either player or g
else
update AI for g based on player.position
end
loop

// Pac-Man eats any pellets


...

// Generate Outputs
draw graphics
update audio
loop

Note that the actual code for Pac-Man does have several different states, including the
aforementioned attract mode, so these states would have to be accounted for in the full game’s code.
However, for simplicity the preceding pseudo-code gives a representation of what the main game
loop might look like if there were only one state.

Multithreaded Game Loops


Although many mobile and independent titles still use a variant of the traditional game loop, most
AAA console and PC titles do not. That’s because newer hardware features CPUs that have multiple
cores. This means the CPU is physically capable of running multiple lines of execution, or threads,
at the same time.
All of the major consoles, most new PCs, and even some mobile devices now feature multicore
CPUs. In order to achieve maximum performance on such systems, the game loop should be
designed to harness all available cores. Several different methods take advantage of multiple cores,
but most are well beyond the scope of this book. However, multithreaded programming is
something that has become prevalent in video games, so it bears mentioning at least one basic
multithreaded game loop technique.
Rendering graphics is an extremely time-consuming operation for AAA games. There are numerous
steps in the rendering pipeline, and the amount of data that needs to be processed is rather massive;
some console games now render well over a million polygons per frame. Suppose it takes 30
milliseconds to render the entire scene for a particular game. It also takes an additional 20
milliseconds to perform the game world update. If this is all running on a single thread, it will take a
total of 50 milliseconds to complete a frame, which will result in an unacceptably low 20 FPS. But
if the rendering and world update could be completed in parallel, it would only take 30 milliseconds
to complete a frame, which means that a 30 FPS target can be achieved.
In order for this to work, the main game loop thread must be changed so it processes all inputs,
updates the game world, and outputs anything other than the graphics. It then must hand off any
relevant data to a secondary rendering thread, which can then draw all the graphics.
But there is a catch to this: What should the main thread do while the rendering thread is drawing?
We don’t want it to simply wait for the drawing to finish, because that would be no faster than
performing all the actions on one thread. The way this problem is solved is by having the rendering
thread always lag one frame behind the main thread. So every frame, the main thread is updating
the world while the rendering thread draws the results of the last main thread update.
One big drawback of this delay is an increase of input lag, or how long it takes for a player’s action
to be visible onscreen. Suppose the “jump” button is pressed during frame 2. In the multithreaded
loop, the input will not get processed until the beginning of frame 3, and the graphics will not be
visible until the end of frame 4. This is illustrated in Figure 1.1.

Figure 1.1 The jump is delayed a couple of frames due to input lag.
If a particular game relies on extremely quick response time, including fighting games such as
Street Fighter, this increased input lag may be deemed unacceptable. But for most other genres, the
increased lag may not be particularly noticeable. Several other factors increase input lag. The game
loop can be one of these factors, and some, like the display lag most LCD panels have, might be out
of the programmer’s control. For more information on this topic, check the references at the end of
this chapter, which includes an interesting set of articles on the topic of measuring and solving input
lag in games.
COLOR
Color (American English), or colour (Commonwealth English), is the characteristic of visual
perception described through color categories, with names such as red, orange, yellow, green, blue,
or purple. This perception of color derives from the stimulation of photoreceptor cells (in particular
cone cells in the human eye and other vertebrate eyes) by electromagnetic radiation (in the visible
spectrum in the case of humans). Color categories and physical specifications of color are
associated with objects through the wavelength of the light that is reflected from them. This
reflection is governed by the object's physical properties such as light absorption, emission spectra,
etc.
By defining a color space, colors can be identified numerically by coordinates, which in 1931 were
also named in global agreement with internationally agreed color names like mentioned above (red,
orange, etc.) by the International Commission on Illumination. The RGB color space for instance is
a color space corresponding to human trichromacy and to the three cone cell types that respond to
three bands of light: long wavelengths, peaking near 564–580 nm (red); medium-wavelength,
peaking near 534–545 nm (green); and short-wavelength light, near 420–440 nm (blue).[1][2] There
may also be more than three color dimensions in other color spaces, such as in the CMYK color
model, wherein one of the dimensions relates to a color's colorfulness).
The photo-receptivity of the "eyes" of other species also varies considerably from that of humans
and so results in correspondingly different color perceptions that cannot readily be compared to one
another. Honeybees and bumblebees for instance have trichromatic color vision sensitive to
ultraviolet but is insensitive to red. Papilio butterflies possess six types of photoreceptors and may
have pentachromatic vision.[3] The most complex color vision system in the animal kingdom has
been found in stomatopods (such as the mantis shrimp) with up to 12 spectral receptor types thought
to work as multiple dichromatic units.[4]
The science of color is sometimes called chromatics, colorimetry, or simply color science. It
includes the study of the perception of color by the human eye and brain, the origin of color in
materials, color theory in art, and the physics of electromagnetic radiation in the visible range (that
is, what is commonly referred to simply as light).
Physics of Color
Electromagnetic radiation is characterized by its wavelength (or frequency) and its intensity. When
the wavelength is within the visible spectrum (the range of wavelengths humans can perceive,
approximately from 390 nm to 700 nm), it is known as "visible light".
Most light sources emit light at many different wavelengths; a source's spectrum is a distribution
giving its intensity at each wavelength. Although the spectrum of light arriving at the eye from a
given direction determines the color sensation in that direction, there are many more possible
spectral combinations than color sensations. In fact, one may formally define a color as a class of
spectra that give rise to the same color sensation, although such classes would vary widely among
different species, and to a lesser extent among individuals within the same species. In each such
class the members are called metamers of the color in question.
Texturing
Texture mapping[1][2][3] is a method for defining high frequency detail, surface texture, or color
information on a computer-generated graphic or 3D model. The original technique was pioneered
by Edwin Catmull in 1974.[4]
Texture mapping originally referred to diffuse mapping, a method that simply mapped pixels from
a texture to a 3D surface ("wrapping" the image around the object). In recent decades, the advent of
multi-pass rendering, multitexturing, mipmaps, and more complex mappings such as height
mapping, bump mapping, normal mapping, displacement mapping, reflection mapping, specular
mapping, occlusion mapping, and many other variations on the technique (controlled by a materials
system) have made it possible to simulate near-photorealism in real time by vastly reducing the
number of polygons and lighting calculations needed to construct a realistic and functional 3D
scene.
Texture Map
A texture map[5][6] is an image applied (mapped) to the surface of a shape or polygon.[7] This
may be a bitmap image or a procedural texture. They may be stored in common image file formats,
referenced by 3d model formats or material definitions, and assembled into resource bundles.
They may have 1-3 dimensions, although 2 dimensions are most common for visible surfaces. For
use with modern hardware, texture map data may be stored in swizzled or tiled orderings to
improve cache coherency. Rendering APIs typically manage texture map resources (which may be
located in device memory) as buffers or surfaces, and may allow 'render to texture' for additional
effects such as post processing or environment mapping.
They usually contain RGB color data (either stored as direct color, compressed formats, or indexed
color), and sometimes an additional channel for alpha blending (RGBA) especially for billboards
and decal overlay textures. It is possible to use the alpha channel (which may be convenient to store
in formats parsed by hardware) for other uses such as specularity.
Multiple texture maps (or channels) may be combined for control over specularity, normals,
displacement, or subsurface scattering e.g. for skin rendering.
Multiple texture images may be combined in texture atlases or array textures to reduce state
changes for modern hardware. (They may be considered a modern evolution of tile map graphics).
Modern hardware often supports cube map textures with multiple faces for environment mapping.

Texture application
This process is akin to applying patterned paper to a plain white box. Every vertex in a polygon is
assigned a texture coordinate (which in the 2d case is also known as UV coordinates). This may be
done through explicit assignment of vertex attributes, manually edited in a 3D modelling package
through UV unwrapping tools. It is also possible to associate a procedural transformation from 3d
space to texture space with the material. This might be accomplished via planar projection or,
alternatively, cylindrical or spherical mapping. More complex mappings may consider the distance
along a surface to minimize distortion. These coordinates are interpolated across the faces of
polygons to sample the texture map during rendering. Textures may be repeated or mirrored to
extend a finite rectangular bitmap over a larger area, or they may have a one-to-one unique
"injective" mapping from every piece of a surface (which is important for render mapping and light
mapping, also known as baking).

Texture space
Texture mapping maps the model surface (or screen space during rasterization) into texture space;
in this space, the texture map is visible in its undistorted form. UV unwrapping tools typically
provide a view in texture space for manual editing of texture coordinates. Some rendering
techniques such as subsurface scattering may be performed approximately by texture-space
operations.

Multitexturing
Multitexturing is the use of more than one texture at a time on a polygon.[8] For instance, a light
map texture may be used to light a surface as an alternative to recalculating that lighting every time
the surface is rendered. Microtextures or detail textures are used to add higher frequency details,
and dirt maps may add weathering and variation; this can greatly reduce the apparent periodicity of
repeating textures. Modern graphics may use more than 10 layers, which are combined using
shaders, for greater fidelity. Another multitexture technique is bump mapping, which allows a
texture to directly control the facing direction of a surface for the purposes of its lighting
calculations; it can give a very good appearance of a complex surface (such as tree bark or rough
concrete) that takes on lighting detail in addition to the usual detailed coloring. Bump mapping has
become popular in recent video games, as graphics hardware has become powerful enough to
accommodate it in real-time.[9]
Texture filtering
The way that samples (e.g. when viewed as pixels on the screen) are calculated from the texels
(texture pixels) is governed by texture filtering. The cheapest method is to use the nearest-
neighbour interpolation, but bilinear interpolation or trilinear interpolation between mipmaps are
two commonly used alternatives which reduce aliasing or jaggies. In the event of a texture
coordinate being outside the texture, it is either clamped or wrapped. Anisotropic filtering better
eliminates directional artefacts when viewing textures from oblique viewing angles.

Baking
As an optimization, it is possible to render detail from a complex, high-resolution model or
expensive process (such as global illumination) into a surface texture (possibly on a low-resolution
model). Baking is also known as render mapping. This technique is most commonly used for light
maps, but may also be used to generate normal maps and displacement maps. Some computer
games (e.g. Messiah) have used this technique. The original Quake software engine used on-the-fly
baking to combine light maps and colour maps ("surface caching").
Baking can be used as a form of level of detail generation, where a complex scene with many
different elements and materials may be approximated by a single element with a single texture,
which is then algorithmically reduced for lower rendering cost and fewer drawcalls. It is also used
to take high-detail models from 3D sculpting software and point cloud scanning and approximate
them with meshes more suitable for realtime rendering.

Rasterisation algorithms
Various techniques have evolved in software and hardware implementations. Each offers different
trade-offs in precision, versatility and performance.

Forward texture mapping


Some hardware systems e.g. Sega Saturn and the NV1 traverse texture coordinates directly,
interpolating the projected position in screen space through texture space and splatting the texels
into a frame buffer. (in the case of the NV1, quadratic interpolation was used allowing curved
rendering). Sega provided tools for baking suitable per-quad texture tiles from UV mapped models.
This has the advantage that texture maps are read in a simple linear fashion.
Forward texture mapping may also sometimes produce more natural looking results than affine
texture mapping if the primitives are aligned with prominent texture directions (e.g. road markings
or layers of bricks). This provides a limited form of perspective correction. However, perspective
distortion is still visible for primitives near the camera (e.g. the Saturn port of Sega Rally exhibited
texture-squashing artifacts as nearby polygons were near clipped without UV coordinates).
This technique is not used in modern hardware because UV coordinates have proved more versatile
for modelling and more consistent for clipping.
Inverse texture mapping
Most approaches use inverse texture mapping, which traverses the rendering primitives in screen
space whilst interpolating texture coordinates for sampling. This interpolation may be affine or
perspective correct. One advantage is that each output pixel is guaranteed to only be traversed once;
generally the source texture map data is stored in some lower bit-depth or compressed form whilst
the frame buffer uses a higher bit-depth. Another is greater versatility for UV mapping. A texture
cache becomes important for buffering reads, since the memory access pattern in texture space is
more complex.

Affine texture mapping


Because affine texture mapping does not take into account the depth information about a polygon's
vertices, where the polygon is not perpendicular to the viewer, it produces a noticeable defect.
Affine texture mapping linearly interpolates texture coordinates across a surface, and so is the
fastest form of texture mapping. Some software and hardware (such as the original PlayStation)
project vertices in 3D space onto the screen during rendering and linearly interpolate the texture
coordinates in screen space between them ("inverse texture mapping"[citation needed]). This may
be done by incrementing fixed point UV coordinates, or by an incremental error algorithm akin to
Bresenham's line algorithm.
In contrast to perpendicular polygons, this leads to noticeable distortion with perspective
transformations (see figure: the checker box texture appears bent), especially as primitives near the
camera. Such distortion may be reduced with the subdivision of the polygon into smaller ones.
Character animation is a specialized area of the animation process, which involves bringing
animated characters to life. The role of a Character Animator is analogous to that of a film or stage
actor, and character animators are often said to be "actors with a pencil" (or a mouse). Character
animators breathe life in their characters, creating the illusion of thought, emotion and personality.
Character animation is often distinguished from creature animation, which involves bringing photo-
realistic animals and creatures to life.
Games
Though typical examples of character animation are found in animated feature films, the role of
character animation within the gaming industry is rapidly increasing. Game developers are using
more complicated characters that allow the gamer to more fully connect with the gaming
experience. Prince of Persia, God of War, Team Fortress II or Resident Evil contain examples of
character animation in games.[citation needed]

Visual effects and creature animation


Character animation is often contrasted with creature animation, in which specialised animators
bring to life realistic animals and creatures, such as dinosaurs and fantasy creatures. Visual effects
animators specialise in animating vehicles, machinery, and natural phenomena such as rain, snow,
lightning and water, as well as the "non-natural" effects often seen in science fiction films. There is
a good deal of overlap between these areas. Sometimes, visual effects animators will use the same
principles of character animation; an early example is the pseudopod in The Abyss.[3]
On-going computer science research on character animation deals with the question of generating
multi-layer level of detail at run-time to allow large crowd rendering in real-time applications.[4
SCENE Graph
A scene graph is a general data structure commonly used by vector-based graphics editing
applications and modern computer games, which arranges the logical and often spatial
representation of a graphical scene. It is a collection of nodes in a graph or tree structure. A tree
node may have many children but only a single parent, with the effect of a parent applied to all its
child nodes; an operation performed on a group automatically propagates its effect to all of its
members. In many programs, associating a geometrical transformation matrix (see also
transformation and matrix) at each group level and concatenating such matrices together is an
efficient and natural way to process such operations. A common feature, for instance, is the ability
to group related shapes and objects into a compound object that can then be manipulated as easily
as a single object.

Scene graphs in graphics editing tools


In vector-based graphics editing, each leaf node in a scene graph represents some atomic unit of the
document, usually a shape such as an ellipse or Bezier path. Although shapes themselves
(particularly paths) can be decomposed further into nodes such as spline nodes, it is practical to
think of the scene graph as composed of shapes rather than going to a lower level of representation.
Another useful and user-driven node concept is the layer. A layer acts like a transparent sheet upon
which any number of shapes and shape groups can be placed. The document then becomes a set of
layers, any of which can be conveniently made invisible, dimmed, or locked (made read-only).
Some applications place all layers in a linear list, while others support layers within layers to any
desired depth.
Internally, there may be no real structural difference between layers and groups at all, since they are
both just nodes of a scene graph. If differences are needed, a common type declaration in C++
would be to make a generic node class, and then derive layers and groups as subclasses. A visibility
member, for example, would be a feature of a layer, but not necessarily of a group.

Scene graphs in games and 3D applications


Scene graphs are useful for modern games using 3D graphics and increasingly large worlds or
levels. In such applications, nodes in a scene graph (generally) represent entities or objects in the
scene.
For instance, a game might define a logical relationship between a knight and a horse so that the
knight is considered an extension to the horse. The scene graph would have a 'horse' node with a
'knight' node attached to it.
The scene graph may also describe the spatial, as well as the logical, relationship of the various
entities: the knight moves through 3D space as the horse moves.
In these large applications, memory requirements are major considerations when designing a scene
graph. For this reason, many large scene graph systems use geometry instancing to reduce memory
costs and increase speed. In our example above, each knight is a separate scene node, but the
graphical representation of the knight (made up of a 3D mesh, textures, materials and shaders) is
instanced. This means that only a single copy of the data is kept, which is then referenced by any
'knight' nodes in the scene graph. This allows a reduced memory budget and increased speed, since
when a new knight node is created, the appearance data needs not be duplicated.

Scene graph implementation


The simplest form of scene graph uses an array or linked list data structure, and displaying its
shapes is simply a matter of linearly iterating the nodes one by one. Other common operations, such
as checking to see which shape intersects the mouse pointer are also done via linear searches. For
small scene graphs, this tends to suffice.

Scene graph operations and dispatch


Applying an operation on a scene graph requires some way of dispatching an operation based on a
node's type. For example, in a render operation, a transformation group node would accumulate its
transformation by matrix multiplication, vector displacement, quaternions or Euler angles. After
which a leaf node sends the object off for rendering to the renderer. Some implementations might
render the object directly, which invokes the underlying rendering API, such as DirectX or
OpenGL. But since the underlying implementation of the rendering API usually lacks portability,
one might separate the scene graph and rendering systems instead. In order to accomplish this type
of dispatching, several different approaches can be taken.
In object-oriented languages such as C++, this can easily be achieved by virtual functions, where
each represents an operation that can be performed on a node. Virtual functions are simple to write,
but it is usually impossible to add new operations to nodes without access to the source code.
Alternatively, the visitor pattern can be used. This has a similar disadvantage in that it is similarly
difficult to add new node types.
Other techniques involve the use of RTTI (Run-Time Type Information). The operation can be
realised as a class that is passed to the current node; it then queries the node's type using RTTI and
looks up the correct operation in an array of callbacks or functors. This requires that the map of
types to callbacks or functors be initialized at runtime, but offers more flexibility, speed and
extensibility.
Variations on these techniques exist, and new methods can offer added benefits. One alternative is
scene graph rebuilding, where the scene graph is rebuilt for each of the operations performed. This,
however, can be very slow, but produces a highly optimised scene graph. It demonstrates that a
good scene graph implementation depends heavily on the application in which it is used.
Traversals
Traversals are the key to the power of applying operations to scene graphs. A traversal generally
consists of starting at some arbitrary node (often the root of the scene graph), applying the
operation(s) (often the updating and rendering operations are applied one after the other), and
recursively moving down the scene graph (tree) to the child nodes, until a leaf node is reached. At
this point, many scene graph engines then traverse back up the tree, applying a similar operation.
For example, consider a render operation that takes transformations into account: while recursively
traversing down the scene graph hierarchy, a pre-render operation is called. If the node is a
transformation node, it adds its own transformation to the current transformation matrix. Once the
operation finishes traversing all the children of a node, it calls the node's post-render operation so
that the transformation node can undo the transformation. This approach drastically reduces the
necessary amount of matrix multiplication.[citation needed]
Some scene graph operations are actually more efficient when nodes are traversed in a different
order – this is where some systems implement scene graph rebuilding to reorder the scene graph
into an easier-to-parse format or tree.
For example, in 2D cases, scene graphs typically render themselves by starting at the tree's root
node and then recursively draw the child nodes. The tree's leaves represent the most foreground
objects. Since drawing proceeds from back to front with closer objects simply overwriting farther
ones, the process is known as employing the Painter's algorithm. In 3D systems, which often
employ depth buffers, it is more efficient to draw the closest objects first, since farther objects often
need only be depth-tested instead of actually rendered, because they are occluded by nearer objects.

Scene graphs and bounding volume hierarchies (BVHs)


Bounding Volume Hierarchies (BVHs) are useful for numerous tasks – including efficient culling
and speeding up collision detection between objects. A BVH is a spatial structure, but doesn't have
to partition the geometry (see spatial partitioning below).
A BVH is a tree of bounding volumes (often spheres, axis-aligned bounding boxes or oriented
bounding boxes). At the bottom of the hierarchy, the size of the volume is just large enough to
encompass a single object tightly (or possibly even some smaller fraction of an object in high
resolution BVHs). As one ascends the hierarchy, each node has its own volume that tightly
encompasses all the volumes beneath it. At the root of the tree is a volume that encompasses all the
volumes in the tree (the whole scene).
BVHs are useful for speeding up collision detection between objects. If an object's bounding
volume does not intersect a volume higher in the tree, it cannot intersect any object below that node
(so they are all rejected very quickly).
There are some similarities between BVHs and scene graphs. A scene graph can easily be adapted
to include/become a BVH – if each node has a volume associated or there is a purpose-built "bound
node" added in at convenient location in the hierarchy. This may not be the typical view of a scene
graph, but there are benefits to including a BVH in a scene graph.
Scene graphs and spatial partitioning
An effective way of combining spatial partitioning and scene graphs is by creating a scene leaf node
that contains the spatial partitioning data.[clarification needed] This can increase computational
efficiency of rendering.
Spatial data is usually static and generally contains non-moving scene data in some partitioned
form.[clarification needed] Some systems may have the systems and their rendering separately.
This is fine and there are no real advantages to either method. In particular, it is bad to have the
scene graph contained within the spatial partitioning system, as the scene graph is better thought of
as the grander system to the spatial partitioning.[neutrality is disputed]
Very large drawings, or scene graphs that are generated solely at runtime (as happens in ray tracing
rendering programs), require defining of group nodes in a more automated fashion. A raytracer, for
example, will take a scene description of a 3D model and build an internal representation that
breaks up its individual parts into bounding boxes (also called bounding slabs). These boxes are
grouped hierarchically so that ray intersection tests (as part of visibility determination) can be
efficiently computed. A group box that does not intersect an eye ray, for example, can entirely skip
testing any of its members.
A similar efficiency holds in 2D applications as well. If the user has magnified a document so that
only part of it is visible on his computer screen, and then scrolls in it, it is useful to use a bounding
box (or in this case, a bounding rectangle scheme) to quickly determine which scene graph elements
are visible and thus actually need to be drawn.
Depending on the particulars of the application's drawing performance, a large part of the scene
graph's design can be impacted by rendering efficiency considerations. In 3D video games such as
Quake, binary space partitioning (BSP) trees are heavily favored to minimize visibility tests. BSP
trees, however, take a very long time to compute from design scene graphs, and must be
recomputed if the design scene graph changes, so the levels tend to remain static, and dynamic
characters aren't generally considered in the spatial partitioning scheme.
Scene graphs for dense regular objects such as heightfields and polygon meshes tend to employ
quadtrees and octrees, which are specialized variants of a 3D bounding box hierarchy. Since a
heightfield occupies a box volume itself, recursively subdividing this box into eight subboxes
(hence the 'oct' in octree) until individual heightfield elements are reached is efficient and natural. A
quadtree is simply a 2D octree.

Standards

PHIGS
PHIGS was the first commercial scene graph specification, and became an ANSI standard in 1988.
Disparate implementations were provided by Unix hardware vendors. The HOOPS 3D Graphics
System appears to have been the first commercial scene graph library provided by a single software
vendor. It was designed to run on disparate lower-level 2D and 3D interfaces, with the first major
production version (v3.0) completed in 1991. Shortly thereafter, Silicon Graphics released IRIS
Inventor 1.0 (1992), which was a scene graph built on top of the IRIS GL 3D API. It was followed
up with Open Inventor in 1994, a portable scene graph built on top of OpenGL. More 3D scene
graph libraries can be found in Category:3D scenegraph APIs.
X3D
X3D is a royalty-free open standards file format and run-time architecture to represent and
communicate 3D scenes and objects using XML. It is an ISO-ra
tified standard that provides a system for the storage, retrieval and playback of real-time graphics
content embedded in applications, all within an open architecture to support a wide array of
domains and user scenarios.

You might also like