grphics07 - textures

24
TEXTURES Michael Heron

Upload: michael-heron

Post on 01-Nov-2014

109 views

Category:

Technology


0 download

DESCRIPTION

This is a course on the theoretical underpinnings of 3D Graphics in computing, suitable for students with a suitable grounding in technical computing.

TRANSCRIPT

Page 1: GRPHICS07 - Textures

TEXTURESMichael Heron

Page 2: GRPHICS07 - Textures

INTRODUCTION

Textures are used to add variability to a surface. Mirrors the different ‘look and feel’ of materials.

Texture mapping used to mimic real world properties. Not a straightforward process to apply to a

discontinuous approximation.

Page 3: GRPHICS07 - Textures

TEXTURES Textures are often represented through

the use of a 2D bitmap.Applied to a polymesh like a wallpaper.Pattern can be applied once, or repeatedly.

Used to simulate fine-grained detail. Ingrain wallpaperTree barkPleats on clothing

Proper way to handle this is through approximation by extremely small polygons.Prohibitively expensive.

Page 4: GRPHICS07 - Textures

TEXTURE DIFFICULTIES

Polymeshes are approximations of real world shapes. How do you wrap a 2D texture around an

approximation? Imagine trying to paste wallpaper into an

irregularly shaped rock.

2D texture

?

Page 5: GRPHICS07 - Textures

TEXTURE MAPPING

Common approach to make use of texture-mapping. Mapping takes pixels from an image and maps

them on to pixels in the rasterised image. Pixels in the texture often referred to as texels.

Texel information must be combined with light, shadow and shading information.

Page 6: GRPHICS07 - Textures

TEXTURE MAPPING

Pixel on the monitor maps onto a point on the 3D representation on the object, which in turn maps onto an appropriate texel.

Page 7: GRPHICS07 - Textures

TEXTURE PROJECTION For simple shapes, a projection can be

applied that permits reasonably clean application of a texture. Flat Cube Tube Sphere

The first two are easiest to visualise. Imagine it like using digital projectors.

Page 8: GRPHICS07 - Textures

TEXTURE PROJECTION

Page 9: GRPHICS07 - Textures

TEXTURE MAPPING

Texture mapping is a complex task. As usual, many different models exist for

managing it. Two part mapping process is much used in

real-time rendering. First, we map the texture onto an ‘easy’

intermediate surface It is then shrink-wrapped onto the object

Can cause distortion problems

Page 10: GRPHICS07 - Textures

TWO-PART MAPPING

Then, ‘shrink-wrapped’ onto object

textureshaped texture

Page 11: GRPHICS07 - Textures

TWO-PART MAPPING

Working out these projections allows the algorithm to build up a mapping of textures to objects

Page 12: GRPHICS07 - Textures

BUMP MAPPING Bump mapping is used to allow a surface to

appear dimpled without actually changing the object space. Texture is applied and alters the normals through

the use of a specified heightmap. About the fine-grained shape of the object more

than the actual colour. Interacts primarily with light representation of a shape.

This is also known as normal mapping.

Page 13: GRPHICS07 - Textures

BUMP MAPPING

Letters here applied with a bump map – perturbation of surface normals handles the greater definition.

The shape itself is not changed – only the calculation for light with regards to the surface normal.

This can be seen in the silhouette and shadows of objects.

Good enough for most applications.

Page 14: GRPHICS07 - Textures

BUMP MAPPING

Bump maps represented by colours. Colours in the R,G and B wavelengths represent the X, Y, and Z perturbations of the surface normal.

Page 15: GRPHICS07 - Textures

BUMP MAPPING

Bump map pixels represent a single unit length.Thus, (x*x) + (y*y) + (z*z) == 1

X, Y, and Z must lie between -1 and 1 Bumps represented as:

R = (X+1) / 2G = (Y+1) / 2B = (Z+1) / 2

All combinations of unit normals can be represented this way.Since we are representing bumps usually

primarily in the Z axis, bump maps tend to be blue.

Page 16: GRPHICS07 - Textures

ENVIRONMENT MAPPING

Environment mapping is used to reflect the surrounding environment.As if in a mirror.

Environment stored as a precomputed texture map.More efficient way of handling ‘ray tracing’

style rendering. More on this later.

Only handles direct illumination.Limitation of a local reflection model.

Page 17: GRPHICS07 - Textures

ENVIRONMENT MAPPING

Effect can be convincing, but lacks the details present using more computationally expensive techniques such as ray tracing.

Effect suffers from limitation – reflection calculated from the object’s centre, not its actual reflecting surface.

Page 18: GRPHICS07 - Textures

ENVIRONMENT MAPPING

Objects look artificially far away, because calculation is done from object’s exact centre.

However, it is quick to process and does away with the need to do expensive ray-tracing passes.

Page 19: GRPHICS07 - Textures

ENVIRONMENT MAPPING Handled via reflected rays.

Trace a ray from the viewpoint of the object and then trace the resultant ray backwards.

Cannot react instantly to environmental changes. Texture is pre-computed and stored. Changes in lighting or object placement require

recalculation. Relatively low cost, thus can be done in real time.

Optimisations must be applied regardless.

Page 20: GRPHICS07 - Textures

THAT’S RENDERING!

Rendering is a complex process. Involving the combination of many differing

elements. Let’s talk about how this all fits together

inside the computer. The order and type of processes applied are

performed according to the graphics pipeline.

Page 21: GRPHICS07 - Textures

THE GRAPHICS PIPELINE

First of all, models are oriented in the 3D world space of the model.Often includes various transforms, and so

is known as modelling transformation. Next, all geometry in the scene is lit

according to light sources.Only at the vertexes, and thus this is

known as per-vertex lighting. The various parts of the scene are

transformed in 3D space in relation to the viewport camera.Viewing Transformation

Page 22: GRPHICS07 - Textures

THE GRAPHICS PIPELINE Next, the geometry represented by the 3D

images is rendered in 2D viewing space Projection Transformation

Culling is done to remove polygons that need not be rendered. Clipping

Rasterisation builds up the image in the framebuffer. With the combination of z-buffering

Page 23: GRPHICS07 - Textures

THE GRAPHICS PIPLEINE

Texture maps are applied to the appropriate pixels based on interpolation of pixels in the frame buffer.Texturing

Finalised pixels are lit and shaded appropriatelyFragment shading

Finally, the rendered image is displayed on the screen as a rasterised bitmap.The size of the raster is dependant on the

resolution of the monitor.

Page 24: GRPHICS07 - Textures

SUMMARY

Textures are a useful approximation of fine-grained surface detail.They do away with the need to vastly

increase polygon counts. They can be simple texture maps

Used to give a colour mapping to a polygon

They can be bump mapsUsed to pertubate surface normals.

The graphics pipeline ensures all parts of the rendering process occur at the right times.